Added .gitignore and created delete window.
This commit is contained in:
1 parent
8c53024d5c
commit
8249d9a27b
14 files changed
+188
-127
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
/PcgsInvUi/bin/
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="PcgsInvUi.App"
|
x:Class="PcgsInvUi.App"
|
||||||
xmlns:local="using:PcgsInvUi"
|
xmlns:local="using:PcgsInvUi"
|
||||||
RequestedThemeVariant="Dark">
|
RequestedThemeVariant="Light">
|
||||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
<Application.DataTemplates>
|
<Application.DataTemplates>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using PcgsInvUi.Services;
|
||||||
using PcgsInvUi.ViewModels;
|
using PcgsInvUi.ViewModels;
|
||||||
using PcgsInvUi.Views;
|
using PcgsInvUi.Views;
|
||||||
|
|
||||||
|
|||||||
+52
-13
@@ -5,12 +5,12 @@ namespace PcgsInvUi.Models;
|
|||||||
|
|
||||||
public class Coin : ReactiveObject
|
public class Coin : ReactiveObject
|
||||||
{
|
{
|
||||||
public int PcgsNumber
|
public string PCGSNo
|
||||||
{
|
{
|
||||||
get => _pcgsNumber;
|
get => _pcgsNo;
|
||||||
set => this.RaiseAndSetIfChanged(ref _pcgsNumber, value);
|
set => this.RaiseAndSetIfChanged(ref _pcgsNo, value);
|
||||||
}
|
}
|
||||||
private int _pcgsNumber;
|
private string _pcgsNo;
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
@@ -50,8 +50,13 @@ public class Coin : ReactiveObject
|
|||||||
public double PriceGuideValue
|
public double PriceGuideValue
|
||||||
{
|
{
|
||||||
get => _priceGuideValue;
|
get => _priceGuideValue;
|
||||||
set => this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
set
|
||||||
|
{
|
||||||
|
TotalPrice = value * Quantity;
|
||||||
|
this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _priceGuideValue;
|
private double _priceGuideValue;
|
||||||
|
|
||||||
public string CoinFactsLink
|
public string CoinFactsLink
|
||||||
@@ -82,12 +87,12 @@ public class Coin : ReactiveObject
|
|||||||
}
|
}
|
||||||
private string _dieVariety;
|
private string _dieVariety;
|
||||||
|
|
||||||
public string Series
|
public string SeriesName
|
||||||
{
|
{
|
||||||
get => _series;
|
get => _seriesName;
|
||||||
set => this.RaiseAndSetIfChanged(ref _series, value);
|
set => this.RaiseAndSetIfChanged(ref _seriesName, value);
|
||||||
}
|
}
|
||||||
private string _series;
|
private string _seriesName;
|
||||||
|
|
||||||
public string Category
|
public string Category
|
||||||
{
|
{
|
||||||
@@ -113,11 +118,21 @@ public class Coin : ReactiveObject
|
|||||||
public int Quantity
|
public int Quantity
|
||||||
{
|
{
|
||||||
get => _quantity;
|
get => _quantity;
|
||||||
set => this.RaiseAndSetIfChanged(ref _quantity, value);
|
set
|
||||||
|
{
|
||||||
|
TotalPrice = value * PriceGuideValue;
|
||||||
|
this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _quantity;
|
private int _quantity;
|
||||||
|
|
||||||
public double TotalPrice => Quantity * PriceGuideValue;
|
public double TotalPrice
|
||||||
|
{
|
||||||
|
get => _totalPrice;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalPrice, value);
|
||||||
|
}
|
||||||
|
private double _totalPrice;
|
||||||
|
|
||||||
public double PaidFor
|
public double PaidFor
|
||||||
{
|
{
|
||||||
@@ -126,10 +141,34 @@ public class Coin : ReactiveObject
|
|||||||
}
|
}
|
||||||
private double _paidFor;
|
private double _paidFor;
|
||||||
|
|
||||||
public String Notes
|
public string Notes
|
||||||
{
|
{
|
||||||
get => _notes;
|
get => _notes;
|
||||||
set => this.RaiseAndSetIfChanged(ref _notes, value);
|
set => this.RaiseAndSetIfChanged(ref _notes, value);
|
||||||
}
|
}
|
||||||
private string _notes;
|
private string _notes;
|
||||||
|
|
||||||
|
public Coin()
|
||||||
|
{
|
||||||
|
PCGSNo = "";
|
||||||
|
Name = "";
|
||||||
|
Year = 0;
|
||||||
|
Denomination = "";
|
||||||
|
MintMark = "";
|
||||||
|
Grade = "";
|
||||||
|
PriceGuideValue = 0;
|
||||||
|
CoinFactsLink = "";
|
||||||
|
MajorVariety = "";
|
||||||
|
MinorVariety = "";
|
||||||
|
DieVariety = "";
|
||||||
|
SeriesName = "";
|
||||||
|
Category = "";
|
||||||
|
Designation = "";
|
||||||
|
CertificateNumber = 0;
|
||||||
|
Quantity = 0;
|
||||||
|
PaidFor = 0;
|
||||||
|
Notes = "";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,12 @@
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
// using Newtonsoft.Json;
|
||||||
using PcgsInvUi.Models;
|
using PcgsInvUi.Models;
|
||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace PcgsInvUi.Services;
|
namespace PcgsInvUi.Services;
|
||||||
|
|
||||||
public class PcgsClient
|
public class PcgsClient
|
||||||
@@ -14,23 +17,30 @@ public class PcgsClient
|
|||||||
|
|
||||||
public PcgsClient(string apiKey)
|
public PcgsClient(string apiKey)
|
||||||
{
|
{
|
||||||
_apiKey = apiKey;
|
// _apiKey = apiKey;
|
||||||
|
_apiKey =
|
||||||
|
"E8xivTVN_k4Q8ubk8Xv_uU11U91WX0wDht4S4m4BAf2HPmKnGrZ0J2f9nccM7Ns1VkGoT1SXYR74I7aNaMKqXlJGEy3oobseKV0nGiqu1IKvFkOTVjhV37SWUVExSDFMC6FLzs7xJQIHwkcxr5JFOQNmc4ZytEh_-hmCN3NL-z0fEk98tzBmPJ_F7bq_xNru86QMD2A9yalu_dWe-lCysfyE2bCA2EDqwvWenRYf-0XnNtp6qlxxCMlCd-TDqqRKLC3qefCwpXSemwBiNSP5gbC9pwcKrZugkruuJ0nyxxThZymm";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Coin> GetCoinFactsByGrade(int pcgsNumber, int grade, bool plusGrade)
|
public async Task<Coin> GetCoinFactsByGrade(int pcgsNumber, string grade, bool plusGrade = false)
|
||||||
{
|
{
|
||||||
Coin newCoin = null;
|
Coin newCoin = null;
|
||||||
using (HttpClient client = new HttpClient())
|
using (HttpClient client = new HttpClient())
|
||||||
{
|
{
|
||||||
|
var gradeParam = GetGradeFromString(grade);
|
||||||
|
|
||||||
string requestUri =
|
string requestUri =
|
||||||
$"{_apiUri}/coindetail/GetCoinFactsByGrade/?PCGSNo={pcgsNumber}&GradeNo={grade}&PlusGrade={plusGrade}";
|
$"{_apiUri}/coindetail/GetCoinFactsByGrade/?PCGSNo={pcgsNumber}&GradeNo={gradeParam}&PlusGrade={plusGrade}";
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", _apiKey);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", _apiKey);
|
||||||
|
Console.WriteLine($"Sending request to {requestUri}");
|
||||||
HttpResponseMessage response = await client.GetAsync(requestUri);
|
HttpResponseMessage response = await client.GetAsync(requestUri);
|
||||||
|
Console.WriteLine("Got response.");
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
string jsonResponse = await response.Content.ReadAsStringAsync();
|
string jsonResponse = await response.Content.ReadAsStringAsync();
|
||||||
newCoin = ParseJsonResponse(jsonResponse);
|
newCoin = ParseJsonResponse(jsonResponse);
|
||||||
|
Console.WriteLine("Coin created.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -40,12 +50,25 @@ public class PcgsClient
|
|||||||
|
|
||||||
return newCoin;
|
return newCoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Will eventually create the other methods that are included in the Public API.
|
|
||||||
|
|
||||||
|
private int GetGradeFromString(string grade)
|
||||||
|
{
|
||||||
|
var actualGrade = int.Parse(grade.Substring(grade.Length - 2));
|
||||||
|
Console.WriteLine($"Grade is {actualGrade}");
|
||||||
|
return actualGrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Will eventually create the other methods that are included in the Public API.
|
||||||
|
|
||||||
private Coin ParseJsonResponse(string json)
|
private Coin ParseJsonResponse(string json)
|
||||||
{
|
{
|
||||||
Coin newCoin = JsonConvert.DeserializeObject<Coin>(json);
|
Console.WriteLine(json);
|
||||||
|
Coin newCoin = JsonSerializer.Deserialize<Coin>(json);
|
||||||
|
Console.WriteLine($"New Coin has pcgs number {newCoin.PCGSNo}");
|
||||||
|
|
||||||
|
string test = JsonSerializer.Serialize(newCoin);
|
||||||
|
Console.WriteLine(test);
|
||||||
|
|
||||||
return newCoin;
|
return newCoin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Xml;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
|
public class DeleteWindowViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public ReactiveCommand<Unit, object> OkCommand { get; } = ReactiveCommand.Create(() => (object)true);
|
||||||
|
public ReactiveCommand<Unit, object> CancelCommand { get; } = ReactiveCommand.Create(() => (object)false);
|
||||||
|
}
|
||||||
@@ -16,10 +16,10 @@ public class EditViewModel : ViewModelBase
|
|||||||
CurrentCoin = coin;
|
CurrentCoin = coin;
|
||||||
|
|
||||||
var okEnabled = this.WhenAnyValue(
|
var okEnabled = this.WhenAnyValue(
|
||||||
x => x.CurrentCoin.PcgsNumber,
|
x => x.CurrentCoin.PCGSNo,
|
||||||
x => x.CurrentCoin.Grade,
|
x => x.CurrentCoin.Grade,
|
||||||
x => x.CurrentCoin.Quantity,
|
x => x.CurrentCoin.Quantity,
|
||||||
(id, grade, quantity) => (id != 0) &&
|
(id, grade, quantity) => !string.IsNullOrWhiteSpace(id) &&
|
||||||
!string.IsNullOrWhiteSpace(grade) &&
|
!string.IsNullOrWhiteSpace(grade) &&
|
||||||
(quantity != 0)
|
(quantity != 0)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reactive.Linq;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Reactive.Linq;
|
||||||
|
using System.Windows.Input;
|
||||||
using PcgsInvUi.Models;
|
using PcgsInvUi.Models;
|
||||||
using PcgsInvUi.Services;
|
using PcgsInvUi.Services;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
@@ -10,11 +10,6 @@ namespace PcgsInvUi.ViewModels;
|
|||||||
|
|
||||||
public class MainWindowViewModel : ViewModelBase
|
public class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public bool PaneOpen
|
|
||||||
{
|
|
||||||
get => _paneOpen;
|
|
||||||
set => this.RaiseAndSetIfChanged(ref _paneOpen, value);
|
|
||||||
}
|
|
||||||
public ViewModelBase SidebarContent
|
public ViewModelBase SidebarContent
|
||||||
{
|
{
|
||||||
get => _sideContent;
|
get => _sideContent;
|
||||||
@@ -31,54 +26,39 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
get => _totalValue;
|
get => _totalValue;
|
||||||
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
||||||
}
|
}
|
||||||
|
public ICommand DeleteCommand { get; }
|
||||||
|
public Interaction<DeleteWindowViewModel, Boolean> ShowDeleteWindow { get; }
|
||||||
|
|
||||||
private ViewModelBase? _sideContent;
|
private ViewModelBase? _sideContent;
|
||||||
private Coin? _selectedCoin;
|
private Coin? _selectedCoin;
|
||||||
private bool _paneOpen;
|
|
||||||
private double _totalValue;
|
private double _totalValue;
|
||||||
|
private PcgsClient _pcgsClient;
|
||||||
|
|
||||||
public MainWindowViewModel(CoinCollection coins)
|
public MainWindowViewModel(CoinCollection coins)
|
||||||
{
|
|
||||||
CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddItem()
|
|
||||||
{
|
{
|
||||||
var newViewModel = new NewViewModel();
|
var newViewModel = new NewViewModel();
|
||||||
|
|
||||||
Observable.Merge(
|
|
||||||
newViewModel.OkCommand,
|
|
||||||
newViewModel.CancelCommand.Select(_ => (Coin?)null))
|
|
||||||
.Take(1)
|
|
||||||
.Subscribe(newCoin =>
|
|
||||||
{
|
|
||||||
if (newCoin != null)
|
|
||||||
{
|
|
||||||
// This raises a CollectionChanged event, which *should* update the UI, but doesn't.
|
|
||||||
CoinCollection.Add(newCoin);
|
|
||||||
// Update view
|
|
||||||
TotalValue += newCoin.TotalPrice;
|
|
||||||
|
|
||||||
// Setting main content to null and then back to the main view model works just fine.
|
|
||||||
// TotalValue updates just fine.
|
|
||||||
}
|
|
||||||
|
|
||||||
SidebarContent = null;
|
|
||||||
PaneOpen = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
SidebarContent = newViewModel;
|
SidebarContent = newViewModel;
|
||||||
PaneOpen = true;
|
CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
||||||
}
|
_pcgsClient = new PcgsClient("eAb8gS0I2XAvT_5gJeiGJaglMia1Tk-oB4kJUK6kuafyrny_S61vIJY-Ikl4nCQM67wrdxzUqLVWTV2kBSxD3d5XNBHxHnYBhcSS6dOPug0hZaF3qAv56df3gYSzOGh9Tif5y0eP3Iw0LrqKDr1Hj-dk6SV6GKog2IIqCPQhhHH8FMTWBTYO-_O8cx7qLdM5GM8KlTsic6g3VRUhM8EA_4OO04dCfmNLGhqINRl3jGZ0Q4ziI8fng2bVWsIyteqiPzUn10rIQ3-OPpqVZG_DxeOmOejj4GzbUNyqUOajy-nr5rYY");
|
||||||
|
|
||||||
public void EditItem()
|
|
||||||
{
|
|
||||||
var editViewModel = new EditViewModel(SelectedCoin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteItem()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
ShowDeleteWindow = new Interaction<DeleteWindowViewModel, bool>();
|
||||||
|
DeleteCommand = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
{
|
||||||
|
var deleteViewModel = new DeleteWindowViewModel();
|
||||||
|
var result = await ShowDeleteWindow.Handle(deleteViewModel);
|
||||||
|
if (result) CoinCollection.Remove(SelectedCoin);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Subscribe to SidebarContent.OkCommand, which is an IObservable<(int, string, int)>
|
||||||
|
// This is the same as the above, but with a different syntax.
|
||||||
|
newViewModel.OkCommand
|
||||||
|
.Subscribe(async requestStructure =>
|
||||||
|
{
|
||||||
|
var newCoin = await _pcgsClient.GetCoinFactsByGrade(requestStructure.Item1, requestStructure.Item2);
|
||||||
|
newCoin.Quantity = requestStructure.Item3;
|
||||||
|
CoinCollection.Add(newCoin);
|
||||||
|
TotalValue += newCoin.Quantity * newCoin.PriceGuideValue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FindItem()
|
public void FindItem()
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
using System;
|
using System.Reactive;
|
||||||
using System.Reactive;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using PcgsInvUi.Models;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class NewViewModel : ViewModelBase
|
public class NewViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private string _pcgsNumber;
|
private string _pcgsNumber = "";
|
||||||
private string _grade;
|
private string _grade = "";
|
||||||
private string _quantity;
|
private string _quantity = "";
|
||||||
|
|
||||||
public string PcgsNumber
|
public string PcgsNumber
|
||||||
{
|
{
|
||||||
@@ -40,15 +38,23 @@ public class NewViewModel : ViewModelBase
|
|||||||
!string.IsNullOrWhiteSpace(quantity));
|
!string.IsNullOrWhiteSpace(quantity));
|
||||||
|
|
||||||
// This will eventually send our request to the public API, then construct our coin.
|
// This will eventually send our request to the public API, then construct our coin.
|
||||||
|
// OkCommand = ReactiveCommand.Create(
|
||||||
|
// () => new Coin { PcgsNumber = Int32.Parse(PcgsNumber),
|
||||||
|
// Grade = Grade,
|
||||||
|
// Quantity = Int32.Parse(Quantity)
|
||||||
|
// },
|
||||||
|
// okEnabled);
|
||||||
|
|
||||||
OkCommand = ReactiveCommand.Create(
|
OkCommand = ReactiveCommand.Create(
|
||||||
() => new Coin { PcgsNumber = Int32.Parse(PcgsNumber),
|
() => (int.Parse(PcgsNumber), Grade, int.Parse(Quantity)),
|
||||||
Grade = Grade,
|
|
||||||
Quantity = Int32.Parse(Quantity),
|
|
||||||
PriceGuideValue = 100.0
|
|
||||||
},
|
|
||||||
okEnabled);
|
okEnabled);
|
||||||
|
|
||||||
CancelCommand = ReactiveCommand.Create(() => { });
|
ClearCommand = ReactiveCommand.Create(() =>
|
||||||
|
{
|
||||||
|
PcgsNumber = "";
|
||||||
|
Grade = "";
|
||||||
|
Quantity = "";
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize grade values for use in the view.
|
// Initialize grade values for use in the view.
|
||||||
// This must be typed out manually, as there is no way to get a list of grades from the API.
|
// This must be typed out manually, as there is no way to get a list of grades from the API.
|
||||||
@@ -86,8 +92,8 @@ public class NewViewModel : ViewModelBase
|
|||||||
"MS-70"
|
"MS-70"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Coin> OkCommand { get; }
|
public ReactiveCommand<Unit, (int, string, int)> OkCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
|
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:viewModels="clr-namespace:PcgsInvUi.ViewModels"
|
||||||
d:DesignWidth="325" d:DesignHeight="100"
|
d:DesignWidth="325" d:DesignHeight="100"
|
||||||
x:Class="PcgsInvUi.Views.DeleteWindow"
|
x:Class="PcgsInvUi.Views.DeleteWindow" x:DataType="viewModels:DeleteWindowViewModel"
|
||||||
Width="325" Height="100" WindowStartupLocation="CenterOwner"
|
Width="325" Height="100" WindowStartupLocation="CenterOwner"
|
||||||
Title="DeleteWindow">
|
Title="DeleteWindow">
|
||||||
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
|
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
Width="100"
|
Width="100"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Content="Yes" Click="AcceptClicked"/>
|
Content="Yes" Command="{Binding OkCommand}"/>
|
||||||
<Button Grid.Row="1" Grid.Column="1" Margin="5"
|
<Button Grid.Row="1" Grid.Column="1" Margin="5"
|
||||||
Width="100"
|
Width="100"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Content="No" Click="CancelClicked"/>
|
Content="No" Command="{Binding CancelCommand}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -1,27 +1,16 @@
|
|||||||
using Avalonia.Controls;
|
using PcgsInvUi.ViewModels;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.ReactiveUI;
|
||||||
|
using ReactiveUI;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
public partial class DeleteWindow : Window
|
public partial class DeleteWindow : ReactiveWindow<DeleteWindowViewModel>
|
||||||
{
|
{
|
||||||
public bool Accepted { get; set; }
|
|
||||||
|
|
||||||
public DeleteWindow()
|
public DeleteWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Accepted = false;
|
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
||||||
}
|
|
||||||
|
|
||||||
public void AcceptClicked(object source, RoutedEventArgs args)
|
|
||||||
{
|
|
||||||
// TODO Delete the SelectedCoin?
|
|
||||||
Accepted = true;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CancelClicked(object source, RoutedEventArgs args)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,16 @@
|
|||||||
xmlns:viewModels="clr-namespace:PcgsInvUi.ViewModels"
|
xmlns:viewModels="clr-namespace:PcgsInvUi.ViewModels"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="PcgsInvUi.Views.MainWindow" x:DataType="viewModels:MainWindowViewModel"
|
x:Class="PcgsInvUi.Views.MainWindow" x:DataType="viewModels:MainWindowViewModel"
|
||||||
Title="MainWindow">
|
Title="MainWindow"
|
||||||
<SplitView IsPaneOpen="{Binding PaneOpen}"
|
WindowStartupLocation="CenterOwner">
|
||||||
DisplayMode="Overlay"
|
<SplitView IsPaneOpen="True"
|
||||||
PanePlacement="Right">
|
DisplayMode="Inline"
|
||||||
|
PanePlacement="Right" >
|
||||||
<SplitView.Pane>
|
<SplitView.Pane>
|
||||||
<UserControl VerticalAlignment="Center" Content="{Binding SidebarContent}"/>
|
<Grid RowDefinitions="Auto, *">
|
||||||
|
<UserControl Grid.Row="0" Margin="10, 20, 10, 10" VerticalAlignment="Center" Content="{Binding SidebarContent}"/>
|
||||||
|
<TextBox Grid.Row="1" Margin="5" Watermark="Notes..."/>
|
||||||
|
</Grid>
|
||||||
</SplitView.Pane>
|
</SplitView.Pane>
|
||||||
<Grid RowDefinitions="*, Auto" ShowGridLines="True">
|
<Grid RowDefinitions="*, Auto" ShowGridLines="True">
|
||||||
<DataGrid Grid.Row="0" HorizontalAlignment="Stretch"
|
<DataGrid Grid.Row="0" HorizontalAlignment="Stretch"
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
CanUserResizeColumns="True">
|
CanUserResizeColumns="True">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Series" Width="*"
|
<DataGridTextColumn Header="Series" Width="*"
|
||||||
Binding="{Binding Series}"
|
Binding="{Binding SeriesName}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="Year"
|
<DataGridTextColumn Header="Year"
|
||||||
Binding="{Binding Year}"
|
Binding="{Binding Year}"
|
||||||
@@ -45,25 +49,21 @@
|
|||||||
Binding="{Binding PriceGuideValue}"
|
Binding="{Binding PriceGuideValue}"
|
||||||
IsReadOnly="False"/>
|
IsReadOnly="False"/>
|
||||||
<DataGridTextColumn Header="PCGS #" Width="*"
|
<DataGridTextColumn Header="PCGS #" Width="*"
|
||||||
Binding="{Binding PcgsNumber}"
|
Binding="{Binding PCGSNo}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="Quantity" Width="*"
|
<DataGridTextColumn Header="Quantity" Width="*"
|
||||||
Binding="{Binding Quantity}"
|
Binding="{Binding Quantity}"
|
||||||
IsReadOnly="False"/>
|
IsReadOnly="False"/>
|
||||||
<DataGridTextColumn Header="Total Price" Width="*"
|
<DataGridTextColumn Header="Total Price" Width="*"
|
||||||
Binding="{Binding TotalPrice}"
|
Binding="{Binding TotalPrice, StringFormat='${0:0.00}'}"
|
||||||
IsReadOnly="True" />
|
IsReadOnly="True" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<DockPanel Grid.Row="1">
|
<DockPanel Grid.Row="1">
|
||||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto, Auto, Auto" DockPanel.Dock="Left">
|
<Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto" DockPanel.Dock="Left">
|
||||||
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="New..."
|
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
||||||
Command="{Binding AddItem}"/>
|
Command="{Binding DeleteCommand}"/>
|
||||||
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Edit..."
|
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Find..."
|
||||||
Command="{Binding EditItem}"/>
|
|
||||||
<Button Grid.Column="2" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
|
||||||
Command="{Binding DeleteItem}"/>
|
|
||||||
<Button Grid.Column="3" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Find..."
|
|
||||||
Command="{Binding FindItem}"/>
|
Command="{Binding FindItem}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto" DockPanel.Dock="Right">
|
<Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto" DockPanel.Dock="Right">
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Avalonia;
|
using System;
|
||||||
using Avalonia.Controls;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using PcgsInvUi.ViewModels;
|
using PcgsInvUi.ViewModels;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
|||||||
{
|
{
|
||||||
// TODO New window.
|
// TODO New window.
|
||||||
// TODO Edit window.
|
// TODO Edit window.
|
||||||
// TODO Delete window.
|
|
||||||
// TODO Find window.
|
// TODO Find window.
|
||||||
// TODO Export window.
|
// TODO Export window.
|
||||||
// TODO Error handling.
|
// TODO Error handling.
|
||||||
@@ -22,9 +21,18 @@ public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
|||||||
// TODO API request tracker (1000 per day)
|
// TODO API request tracker (1000 per day)
|
||||||
// TODO API update schedules (per month? manual override? needs to store a date of last update in the coin object)
|
// TODO API update schedules (per month? manual override? needs to store a date of last update in the coin object)
|
||||||
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.WhenActivated(d => d(ViewModel!.ShowDeleteWindow.RegisterHandler(ShowDeleteWindowAsync)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ShowDeleteWindowAsync(InteractionContext<DeleteWindowViewModel, Boolean> interaction)
|
||||||
|
{
|
||||||
|
var window = new DeleteWindow();
|
||||||
|
window.DataContext = interaction.Input;
|
||||||
|
|
||||||
|
var result = await window.ShowDialog<bool>(this);
|
||||||
|
interaction.SetOutput(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<Button Grid.Column="0" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
<Button Grid.Column="0" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
Width="90" HorizontalContentAlignment="Center" Content="OK" Command="{Binding OkCommand}"/>
|
Width="90" HorizontalContentAlignment="Center" Content="OK" Command="{Binding OkCommand}"/>
|
||||||
<Button Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
<Button Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
Width="90" HorizontalContentAlignment="Center" Content="Cancel" Command="{Binding CancelCommand}" />
|
Width="90" HorizontalContentAlignment="Center" Content="Clear" Command="{Binding ClearCommand}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
Reference in new issue
Block a user