Reformatted and cleaned up code across whole project.
This commit is contained in:
1 parent
42a7871ed4
commit
99cb9268dd
25 files changed
+272
-319
No files matched your search
+3
-3
@@ -3,12 +3,12 @@
|
|||||||
x:Class="PcgsInvUi.App"
|
x:Class="PcgsInvUi.App"
|
||||||
xmlns:local="using:PcgsInvUi"
|
xmlns:local="using:PcgsInvUi"
|
||||||
RequestedThemeVariant="Light">
|
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>
|
||||||
<local:ViewLocator/>
|
<local:ViewLocator />
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
||||||
|
|||||||
+7
-12
@@ -7,23 +7,18 @@ using PcgsInvUi.Views;
|
|||||||
|
|
||||||
namespace PcgsInvUi;
|
namespace PcgsInvUi;
|
||||||
|
|
||||||
public partial class App : Application
|
public partial class App : Application {
|
||||||
{
|
public override void Initialize() {
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted() {
|
||||||
{
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
|
||||||
{
|
|
||||||
var coins = new Services.CoinCollection();
|
var coins = new Services.CoinCollection();
|
||||||
|
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.MainWindow = new MainWindow {
|
||||||
{
|
|
||||||
DataContext = new MainWindowViewModel(coins),
|
DataContext = new MainWindowViewModel(coins),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-49
@@ -3,55 +3,52 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Models;
|
namespace PcgsInvUi.Models;
|
||||||
|
|
||||||
public class Coin : ReactiveObject
|
public class Coin : ReactiveObject {
|
||||||
{
|
public string PCGSNo {
|
||||||
public string PCGSNo
|
|
||||||
{
|
|
||||||
get => _pcgsNo;
|
get => _pcgsNo;
|
||||||
set => this.RaiseAndSetIfChanged(ref _pcgsNo, value);
|
set => this.RaiseAndSetIfChanged(ref _pcgsNo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _pcgsNo;
|
private string _pcgsNo;
|
||||||
|
|
||||||
public string Name
|
public string Name {
|
||||||
{
|
|
||||||
get => _name;
|
get => _name;
|
||||||
set => this.RaiseAndSetIfChanged(ref _name, value);
|
set => this.RaiseAndSetIfChanged(ref _name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _name;
|
private string _name;
|
||||||
|
|
||||||
public int Year
|
public int Year {
|
||||||
{
|
|
||||||
get => _year;
|
get => _year;
|
||||||
set => this.RaiseAndSetIfChanged(ref _year, value);
|
set => this.RaiseAndSetIfChanged(ref _year, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _year;
|
private int _year;
|
||||||
|
|
||||||
public string Denomination
|
public string Denomination {
|
||||||
{
|
|
||||||
get => _denomination;
|
get => _denomination;
|
||||||
set => this.RaiseAndSetIfChanged(ref _denomination, value);
|
set => this.RaiseAndSetIfChanged(ref _denomination, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _denomination;
|
private string _denomination;
|
||||||
|
|
||||||
public string MintMark
|
public string MintMark {
|
||||||
{
|
|
||||||
get => _mintMark;
|
get => _mintMark;
|
||||||
set => this.RaiseAndSetIfChanged(ref _mintMark, value);
|
set => this.RaiseAndSetIfChanged(ref _mintMark, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _mintMark;
|
private string _mintMark;
|
||||||
|
|
||||||
public string Grade
|
public string Grade {
|
||||||
{
|
|
||||||
get => _grade;
|
get => _grade;
|
||||||
set => this.RaiseAndSetIfChanged(ref _grade, value);
|
set => this.RaiseAndSetIfChanged(ref _grade, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _grade;
|
private string _grade;
|
||||||
|
|
||||||
public double PriceGuideValue
|
public double PriceGuideValue {
|
||||||
{
|
|
||||||
get => _priceGuideValue;
|
get => _priceGuideValue;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
TotalPrice = value * Quantity;
|
TotalPrice = value * Quantity;
|
||||||
this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
||||||
}
|
}
|
||||||
@@ -59,67 +56,65 @@ public class Coin : ReactiveObject
|
|||||||
|
|
||||||
private double _priceGuideValue;
|
private double _priceGuideValue;
|
||||||
|
|
||||||
public string CoinFactsLink
|
public string CoinFactsLink {
|
||||||
{
|
|
||||||
get => _coinFactsLink;
|
get => _coinFactsLink;
|
||||||
set => this.RaiseAndSetIfChanged(ref _coinFactsLink, value);
|
set => this.RaiseAndSetIfChanged(ref _coinFactsLink, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _coinFactsLink;
|
private string _coinFactsLink;
|
||||||
|
|
||||||
public string MajorVariety
|
public string MajorVariety {
|
||||||
{
|
|
||||||
get => _majorVariety;
|
get => _majorVariety;
|
||||||
set => this.RaiseAndSetIfChanged(ref _majorVariety, value);
|
set => this.RaiseAndSetIfChanged(ref _majorVariety, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _majorVariety;
|
private string _majorVariety;
|
||||||
|
|
||||||
public string MinorVariety
|
public string MinorVariety {
|
||||||
{
|
|
||||||
get => _minorVariety;
|
get => _minorVariety;
|
||||||
set => this.RaiseAndSetIfChanged(ref _minorVariety, value);
|
set => this.RaiseAndSetIfChanged(ref _minorVariety, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _minorVariety;
|
private string _minorVariety;
|
||||||
|
|
||||||
public string DieVariety
|
public string DieVariety {
|
||||||
{
|
|
||||||
get => _dieVariety;
|
get => _dieVariety;
|
||||||
set => this.RaiseAndSetIfChanged(ref _dieVariety, value);
|
set => this.RaiseAndSetIfChanged(ref _dieVariety, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _dieVariety;
|
private string _dieVariety;
|
||||||
|
|
||||||
public string SeriesName
|
public string SeriesName {
|
||||||
{
|
|
||||||
get => _seriesName;
|
get => _seriesName;
|
||||||
set => this.RaiseAndSetIfChanged(ref _seriesName, value);
|
set => this.RaiseAndSetIfChanged(ref _seriesName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _seriesName;
|
private string _seriesName;
|
||||||
|
|
||||||
public string Category
|
public string Category {
|
||||||
{
|
|
||||||
get => _category;
|
get => _category;
|
||||||
set => this.RaiseAndSetIfChanged(ref _category, value);
|
set => this.RaiseAndSetIfChanged(ref _category, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _category;
|
private string _category;
|
||||||
|
|
||||||
public string Designation
|
public string Designation {
|
||||||
{
|
|
||||||
get => _designation;
|
get => _designation;
|
||||||
set => this.RaiseAndSetIfChanged(ref _designation, value);
|
set => this.RaiseAndSetIfChanged(ref _designation, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _designation;
|
private string _designation;
|
||||||
|
|
||||||
public int CertificateNumber
|
public int CertificateNumber {
|
||||||
{
|
|
||||||
get => _certificateNumber;
|
get => _certificateNumber;
|
||||||
set => this.RaiseAndSetIfChanged(ref _certificateNumber, value);
|
set => this.RaiseAndSetIfChanged(ref _certificateNumber, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _certificateNumber;
|
private int _certificateNumber;
|
||||||
|
|
||||||
public int Quantity
|
public int Quantity {
|
||||||
{
|
|
||||||
get => _quantity;
|
get => _quantity;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
TotalPrice = value * PriceGuideValue;
|
TotalPrice = value * PriceGuideValue;
|
||||||
this.RaiseAndSetIfChanged(ref _quantity, value);
|
this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||||
}
|
}
|
||||||
@@ -127,29 +122,28 @@ public class Coin : ReactiveObject
|
|||||||
|
|
||||||
private int _quantity;
|
private int _quantity;
|
||||||
|
|
||||||
public double TotalPrice
|
public double TotalPrice {
|
||||||
{
|
|
||||||
get => _totalPrice;
|
get => _totalPrice;
|
||||||
set => this.RaiseAndSetIfChanged(ref _totalPrice, value);
|
set => this.RaiseAndSetIfChanged(ref _totalPrice, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _totalPrice;
|
private double _totalPrice;
|
||||||
|
|
||||||
public double PaidFor
|
public double PaidFor {
|
||||||
{
|
|
||||||
get => _paidFor;
|
get => _paidFor;
|
||||||
set => this.RaiseAndSetIfChanged(ref _paidFor, value);
|
set => this.RaiseAndSetIfChanged(ref _paidFor, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
public Coin() {
|
||||||
{
|
|
||||||
PCGSNo = "";
|
PCGSNo = "";
|
||||||
Name = "";
|
Name = "";
|
||||||
Year = 0;
|
Year = 0;
|
||||||
@@ -168,7 +162,5 @@ public class Coin : ReactiveObject
|
|||||||
Quantity = 0;
|
Quantity = 0;
|
||||||
PaidFor = 0;
|
PaidFor = 0;
|
||||||
Notes = "";
|
Notes = "";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+69
-68
@@ -1,85 +1,86 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**"/>
|
||||||
<AvaloniaResource Remove="obj\**" />
|
<AvaloniaResource Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.0.2" />
|
<PackageReference Include="Avalonia" Version="11.0.2"/>
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.2" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.2"/>
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.2" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.2"/>
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2"/>
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.2" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.2"/>
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.2" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.2"/>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||||
</ItemGroup>
|
<PackageReference Include="System.Data.SQLite" Version="1.0.118"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="obj\Debug\net6.0\apphost.exe" />
|
<Content Include="obj\Debug\net6.0\apphost.exe"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\original.dll" />
|
<Content Include="obj\Debug\net6.0\Avalonia\original.dll"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\original.pdb" />
|
<Content Include="obj\Debug\net6.0\Avalonia\original.pdb"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\original.ref.dll" />
|
<Content Include="obj\Debug\net6.0\Avalonia\original.ref.dll"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\references" />
|
<Content Include="obj\Debug\net6.0\Avalonia\references"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\resources" />
|
<Content Include="obj\Debug\net6.0\Avalonia\resources"/>
|
||||||
<Content Include="obj\Debug\net6.0\Avalonia\Resources.Inputs.cache" />
|
<Content Include="obj\Debug\net6.0\Avalonia\Resources.Inputs.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.AssemblyInfoInputs.cache" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.AssemblyInfoInputs.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.assets.cache" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.assets.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.AssemblyReference.cache" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.AssemblyReference.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.CopyComplete" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.CopyComplete"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.CoreCompileInputs.cache" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.CoreCompileInputs.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.FileListAbsolute.txt" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.csproj.FileListAbsolute.txt"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.dll" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.dll"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.GeneratedMSBuildEditorConfig.editorconfig" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.GeneratedMSBuildEditorConfig.editorconfig"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.genruntimeconfig.cache" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.genruntimeconfig.cache"/>
|
||||||
<Content Include="obj\Debug\net6.0\PcgsInvUi.pdb" />
|
<Content Include="obj\Debug\net6.0\PcgsInvUi.pdb"/>
|
||||||
<Content Include="obj\Debug\net6.0\refint\PcgsInvUi.dll" />
|
<Content Include="obj\Debug\net6.0\refint\PcgsInvUi.dll"/>
|
||||||
<Content Include="obj\Debug\net6.0\ref\PcgsInvUi.dll" />
|
<Content Include="obj\Debug\net6.0\ref\PcgsInvUi.dll"/>
|
||||||
<Content Include="obj\PcgsInvUi.csproj.nuget.dgspec.json" />
|
<Content Include="obj\PcgsInvUi.csproj.nuget.dgspec.json"/>
|
||||||
<Content Include="obj\PcgsInvUi.csproj.nuget.g.props" />
|
<Content Include="obj\PcgsInvUi.csproj.nuget.g.props"/>
|
||||||
<Content Include="obj\PcgsInvUi.csproj.nuget.g.targets" />
|
<Content Include="obj\PcgsInvUi.csproj.nuget.g.targets"/>
|
||||||
<Content Include="obj\project.assets.json" />
|
<Content Include="obj\project.assets.json"/>
|
||||||
<Content Include="obj\project.nuget.cache" />
|
<Content Include="obj\project.nuget.cache"/>
|
||||||
<Content Include="obj\project.packagespec.json" />
|
<Content Include="obj\project.packagespec.json"/>
|
||||||
<Content Include="obj\rider.project.model.nuget.info" />
|
<Content Include="obj\rider.project.model.nuget.info"/>
|
||||||
<Content Include="obj\rider.project.restore.info" />
|
<Content Include="obj\rider.project.restore.info"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="obj\Debug\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs" />
|
<Compile Include="obj\Debug\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs"/>
|
||||||
<Compile Include="obj\Debug\net6.0\PcgsInvUi.AssemblyInfo.cs" />
|
<Compile Include="obj\Debug\net6.0\PcgsInvUi.AssemblyInfo.cs"/>
|
||||||
<Compile Remove="obj\**" />
|
<Compile Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaXaml Remove="obj\**" />
|
<AvaloniaXaml Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Remove="obj\**" />
|
<EmbeddedResource Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Remove="obj\**" />
|
<AdditionalFiles Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="obj\**" />
|
<None Remove="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -4,8 +4,7 @@ using System;
|
|||||||
|
|
||||||
namespace PcgsInvUi;
|
namespace PcgsInvUi;
|
||||||
|
|
||||||
class Program
|
class Program {
|
||||||
{
|
|
||||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
// yet and stuff might break.
|
// yet and stuff might break.
|
||||||
@@ -20,4 +19,4 @@ class Program
|
|||||||
.WithInterFont()
|
.WithInterFont()
|
||||||
.LogToTrace()
|
.LogToTrace()
|
||||||
.UseReactiveUI();
|
.UseReactiveUI();
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,8 @@ using PcgsInvUi.Models;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Services;
|
namespace PcgsInvUi.Services;
|
||||||
|
|
||||||
public class CoinCollection
|
public class CoinCollection {
|
||||||
{
|
public IEnumerable<Coin> GetItems() => new[] {
|
||||||
public IEnumerable<Coin> GetItems() => new[]
|
|
||||||
{
|
|
||||||
new Coin(),
|
new Coin(),
|
||||||
new Coin(),
|
new Coin(),
|
||||||
new Coin(),
|
new Coin(),
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace PcgsInvUi.Services;
|
namespace PcgsInvUi.Services;
|
||||||
|
|
||||||
public class Database
|
public class Database {
|
||||||
{
|
public Database() { }
|
||||||
// TODO Create a database using SQLite.
|
|
||||||
}
|
}
|
||||||
@@ -4,31 +4,26 @@ 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;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace PcgsInvUi.Services;
|
namespace PcgsInvUi.Services;
|
||||||
|
|
||||||
public class PcgsClient
|
public class PcgsClient {
|
||||||
{
|
|
||||||
private string _apiUri = "https://api.pcgs.com/publicapi";
|
private string _apiUri = "https://api.pcgs.com/publicapi";
|
||||||
private readonly string _apiKey;
|
private readonly string _apiKey;
|
||||||
|
|
||||||
public PcgsClient(string apiKey)
|
public PcgsClient(string apiKey) {
|
||||||
{
|
|
||||||
// _apiKey = apiKey;
|
// _apiKey = apiKey;
|
||||||
_apiKey =
|
_apiKey =
|
||||||
"E8xivTVN_k4Q8ubk8Xv_uU11U91WX0wDht4S4m4BAf2HPmKnGrZ0J2f9nccM7Ns1VkGoT1SXYR74I7aNaMKqXlJGEy3oobseKV0nGiqu1IKvFkOTVjhV37SWUVExSDFMC6FLzs7xJQIHwkcxr5JFOQNmc4ZytEh_-hmCN3NL-z0fEk98tzBmPJ_F7bq_xNru86QMD2A9yalu_dWe-lCysfyE2bCA2EDqwvWenRYf-0XnNtp6qlxxCMlCd-TDqqRKLC3qefCwpXSemwBiNSP5gbC9pwcKrZugkruuJ0nyxxThZymm";
|
"E8xivTVN_k4Q8ubk8Xv_uU11U91WX0wDht4S4m4BAf2HPmKnGrZ0J2f9nccM7Ns1VkGoT1SXYR74I7aNaMKqXlJGEy3oobseKV0nGiqu1IKvFkOTVjhV37SWUVExSDFMC6FLzs7xJQIHwkcxr5JFOQNmc4ZytEh_-hmCN3NL-z0fEk98tzBmPJ_F7bq_xNru86QMD2A9yalu_dWe-lCysfyE2bCA2EDqwvWenRYf-0XnNtp6qlxxCMlCd-TDqqRKLC3qefCwpXSemwBiNSP5gbC9pwcKrZugkruuJ0nyxxThZymm";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Coin> GetCoinFactsByGrade(int pcgsNumber, string grade, bool plusGrade = false)
|
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);
|
var gradeParam = GetGradeFromString(grade);
|
||||||
|
|
||||||
string requestUri =
|
string requestUri =
|
||||||
$"{_apiUri}/coindetail/GetCoinFactsByGrade/?PCGSNo={pcgsNumber}&GradeNo={gradeParam}&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);
|
||||||
@@ -36,14 +31,12 @@ public class PcgsClient
|
|||||||
HttpResponseMessage response = await client.GetAsync(requestUri);
|
HttpResponseMessage response = await client.GetAsync(requestUri);
|
||||||
Console.WriteLine("Got response.");
|
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.");
|
Console.WriteLine("Coin created.");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
|
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,24 +44,22 @@ public class PcgsClient
|
|||||||
return newCoin;
|
return newCoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetGradeFromString(string grade)
|
private int GetGradeFromString(string grade) {
|
||||||
{
|
|
||||||
var actualGrade = int.Parse(grade.Substring(grade.Length - 2));
|
var actualGrade = int.Parse(grade.Substring(grade.Length - 2));
|
||||||
Console.WriteLine($"Grade is {actualGrade}");
|
Console.WriteLine($"Grade is {actualGrade}");
|
||||||
return actualGrade;
|
return actualGrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Will eventually create the other methods that are included in the Public API.
|
// TODO Will eventually create the other methods that are included in the Public API.
|
||||||
|
|
||||||
private Coin ParseJsonResponse(string json)
|
private Coin ParseJsonResponse(string json) {
|
||||||
{
|
|
||||||
Console.WriteLine(json);
|
Console.WriteLine(json);
|
||||||
Coin newCoin = JsonSerializer.Deserialize<Coin>(json);
|
Coin newCoin = JsonSerializer.Deserialize<Coin>(json);
|
||||||
Console.WriteLine($"New Coin has pcgs number {newCoin.PCGSNo}");
|
Console.WriteLine($"New Coin has pcgs number {newCoin.PCGSNo}");
|
||||||
|
|
||||||
string test = JsonSerializer.Serialize(newCoin);
|
string test = JsonSerializer.Serialize(newCoin);
|
||||||
Console.WriteLine(test);
|
Console.WriteLine(test);
|
||||||
|
|
||||||
return newCoin;
|
return newCoin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,23 +5,19 @@ using PcgsInvUi.ViewModels;
|
|||||||
|
|
||||||
namespace PcgsInvUi;
|
namespace PcgsInvUi;
|
||||||
|
|
||||||
public class ViewLocator : IDataTemplate
|
public class ViewLocator : IDataTemplate {
|
||||||
{
|
public Control Build(object data) {
|
||||||
public Control Build(object data)
|
|
||||||
{
|
|
||||||
var name = data.GetType().FullName!.Replace("ViewModel", "View");
|
var name = data.GetType().FullName!.Replace("ViewModel", "View");
|
||||||
var type = Type.GetType(name);
|
var type = Type.GetType(name);
|
||||||
|
|
||||||
if (type != null)
|
if (type != null) {
|
||||||
{
|
|
||||||
return (Control)Activator.CreateInstance(type)!;
|
return (Control)Activator.CreateInstance(type)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TextBlock { Text = "Not Found: " + name };
|
return new TextBlock { Text = "Not Found: " + name };
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Match(object data)
|
public bool Match(object data) {
|
||||||
{
|
|
||||||
return data is ViewModelBase;
|
return data is ViewModelBase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,19 +5,18 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class CoinListViewModel : ViewModelBase
|
public class CoinListViewModel : ViewModelBase {
|
||||||
{
|
|
||||||
public ObservableCollection<Coin> CoinCollection { get; set; }
|
public ObservableCollection<Coin> CoinCollection { get; set; }
|
||||||
private float _totalValue;
|
private float _totalValue;
|
||||||
public float TotalValue
|
|
||||||
{
|
public float TotalValue {
|
||||||
get => _totalValue;
|
get => _totalValue;
|
||||||
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coin? SelectedCoin { get; set; }
|
public Coin? SelectedCoin { get; set; }
|
||||||
|
|
||||||
public CoinListViewModel(IEnumerable<Coin> items)
|
public CoinListViewModel(IEnumerable<Coin> items) {
|
||||||
{
|
|
||||||
CoinCollection = new ObservableCollection<Coin>(items);
|
CoinCollection = new ObservableCollection<Coin>(items);
|
||||||
TotalValue = 0;
|
TotalValue = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class DeleteWindowViewModel : ViewModelBase
|
public class DeleteWindowViewModel : ViewModelBase {
|
||||||
{
|
|
||||||
public ReactiveCommand<Unit, object> OkCommand { get; }
|
public ReactiveCommand<Unit, object> OkCommand { get; }
|
||||||
public ReactiveCommand<DeleteWindow, Unit> CancelCommand { get; }
|
public ReactiveCommand<DeleteWindow, Unit> CancelCommand { get; }
|
||||||
|
|
||||||
public DeleteWindowViewModel()
|
public DeleteWindowViewModel() {
|
||||||
{
|
OkCommand = ReactiveCommand.Create(() => (object)true);
|
||||||
OkCommand = ReactiveCommand.Create(() => (object)true);
|
|
||||||
CancelCommand = ReactiveCommand.Create<DeleteWindow>(window => window.Close());
|
CancelCommand = ReactiveCommand.Create<DeleteWindow>(window => window.Close());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,12 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class EditViewModel : ViewModelBase
|
public class EditViewModel : ViewModelBase {
|
||||||
{
|
|
||||||
public Coin CurrentCoin { get; set; }
|
public Coin CurrentCoin { get; set; }
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> OkCommand { get; }
|
public ReactiveCommand<Unit, Unit> OkCommand { get; }
|
||||||
|
|
||||||
public EditViewModel(Coin coin)
|
public EditViewModel(Coin coin) {
|
||||||
{
|
|
||||||
CurrentCoin = coin;
|
CurrentCoin = coin;
|
||||||
|
|
||||||
var okEnabled = this.WhenAnyValue(
|
var okEnabled = this.WhenAnyValue(
|
||||||
@@ -23,7 +21,7 @@ public class EditViewModel : ViewModelBase
|
|||||||
!string.IsNullOrWhiteSpace(grade) &&
|
!string.IsNullOrWhiteSpace(grade) &&
|
||||||
(quantity != 0)
|
(quantity != 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Setup OkCommand - all Coin-related properties must be non-whitespace.
|
// Setup OkCommand - all Coin-related properties must be non-whitespace.
|
||||||
OkCommand = ReactiveCommand.Create(() => { });
|
OkCommand = ReactiveCommand.Create(() => { });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class FindWindowViewModel : ViewModelBase
|
public class FindWindowViewModel : ViewModelBase {
|
||||||
{
|
|
||||||
public ReactiveCommand<Unit, object> OkCommand { get; } = ReactiveCommand.Create(() => (object)1);
|
public ReactiveCommand<Unit, object> OkCommand { get; } = ReactiveCommand.Create(() => (object)1);
|
||||||
}
|
}
|
||||||
@@ -19,80 +19,78 @@ namespace PcgsInvUi.ViewModels;
|
|||||||
// 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 class MainWindowViewModel : ViewModelBase
|
public class MainWindowViewModel : ViewModelBase {
|
||||||
{
|
public ViewModelBase SidebarContent {
|
||||||
public ViewModelBase SidebarContent
|
|
||||||
{
|
|
||||||
get => _sideContent;
|
get => _sideContent;
|
||||||
private set => this.RaiseAndSetIfChanged(ref _sideContent, value);
|
private set => this.RaiseAndSetIfChanged(ref _sideContent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<Coin> CoinCollection { get; set; }
|
public ObservableCollection<Coin> CoinCollection { get; set; }
|
||||||
public ObservableCollection<Coin> DisplayedList { get; set; }
|
public ObservableCollection<Coin> DisplayedList { get; set; }
|
||||||
public Coin? SelectedCoin
|
|
||||||
{
|
public Coin? SelectedCoin {
|
||||||
get => _selectedCoin;
|
get => _selectedCoin;
|
||||||
set => this.RaiseAndSetIfChanged(ref _selectedCoin, value);
|
set => this.RaiseAndSetIfChanged(ref _selectedCoin, value);
|
||||||
}
|
}
|
||||||
public double TotalValue
|
|
||||||
{
|
public double TotalValue {
|
||||||
get => _totalValue;
|
get => _totalValue;
|
||||||
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> DeleteCommand { get; }
|
public ReactiveCommand<Unit, Unit> DeleteCommand { get; }
|
||||||
public Interaction<DeleteWindowViewModel, Boolean> ShowDeleteWindow { get; }
|
public Interaction<DeleteWindowViewModel, Boolean> ShowDeleteWindow { get; }
|
||||||
public ReactiveCommand<Unit, Coin> FindCommand { get; }
|
public ReactiveCommand<Unit, Coin> FindCommand { get; }
|
||||||
public Interaction<FindWindowViewModel, int> ShowFindWindow { get; }
|
public Interaction<FindWindowViewModel, int> ShowFindWindow { get; }
|
||||||
|
|
||||||
private ViewModelBase _sideContent;
|
private ViewModelBase _sideContent;
|
||||||
private Coin? _selectedCoin;
|
private Coin? _selectedCoin;
|
||||||
private double _totalValue;
|
private double _totalValue;
|
||||||
private PcgsClient _pcgsClient;
|
private PcgsClient _pcgsClient;
|
||||||
|
|
||||||
public MainWindowViewModel(CoinCollection coins)
|
public MainWindowViewModel(CoinCollection coins) {
|
||||||
{
|
|
||||||
var newViewModel = new NewViewModel();
|
var newViewModel = new NewViewModel();
|
||||||
_sideContent = newViewModel;
|
_sideContent = newViewModel;
|
||||||
DisplayedList = CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
DisplayedList = CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
||||||
_pcgsClient = new PcgsClient("eAb8gS0I2XAvT_5gJeiGJaglMia1Tk-oB4kJUK6kuafyrny_S61vIJY-Ikl4nCQM67wrdxzUqLVWTV2kBSxD3d5XNBHxHnYBhcSS6dOPug0hZaF3qAv56df3gYSzOGh9Tif5y0eP3Iw0LrqKDr1Hj-dk6SV6GKog2IIqCPQhhHH8FMTWBTYO-_O8cx7qLdM5GM8KlTsic6g3VRUhM8EA_4OO04dCfmNLGhqINRl3jGZ0Q4ziI8fng2bVWsIyteqiPzUn10rIQ3-OPpqVZG_DxeOmOejj4GzbUNyqUOajy-nr5rYY");
|
_pcgsClient = new PcgsClient(
|
||||||
|
"eAb8gS0I2XAvT_5gJeiGJaglMia1Tk-oB4kJUK6kuafyrny_S61vIJY-Ikl4nCQM67wrdxzUqLVWTV2kBSxD3d5XNBHxHnYBhcSS6dOPug0hZaF3qAv56df3gYSzOGh9Tif5y0eP3Iw0LrqKDr1Hj-dk6SV6GKog2IIqCPQhhHH8FMTWBTYO-_O8cx7qLdM5GM8KlTsic6g3VRUhM8EA_4OO04dCfmNLGhqINRl3jGZ0Q4ziI8fng2bVWsIyteqiPzUn10rIQ3-OPpqVZG_DxeOmOejj4GzbUNyqUOajy-nr5rYY");
|
||||||
|
|
||||||
// Set up the ability to open the delete window.
|
// Set up the ability to open the delete window.
|
||||||
ShowDeleteWindow = new Interaction<DeleteWindowViewModel, bool>();
|
ShowDeleteWindow = new Interaction<DeleteWindowViewModel, bool>();
|
||||||
var deleteEnabled = this.WhenAnyValue(x => x.SelectedCoin)
|
var deleteEnabled = this.WhenAnyValue(x => x.SelectedCoin)
|
||||||
.Select(x => x != null);
|
.Select(x => x != null);
|
||||||
DeleteCommand = ReactiveCommand.CreateFromTask(async () =>
|
DeleteCommand = ReactiveCommand.CreateFromTask(async () => {
|
||||||
{
|
|
||||||
var deleteViewModel = new DeleteWindowViewModel();
|
var deleteViewModel = new DeleteWindowViewModel();
|
||||||
var result = await ShowDeleteWindow.Handle(deleteViewModel);
|
var result = await ShowDeleteWindow.Handle(deleteViewModel);
|
||||||
if (result) CoinCollection.Remove(SelectedCoin); // possible null deref - ignored due to button being disabled.
|
if (result)
|
||||||
|
CoinCollection.Remove(SelectedCoin); // possible null deref - ignored due to button being disabled.
|
||||||
}, deleteEnabled);
|
}, deleteEnabled);
|
||||||
|
|
||||||
// Set up the ability to open the find window.
|
// Set up the ability to open the find window.
|
||||||
ShowFindWindow = new Interaction<FindWindowViewModel, int>();
|
ShowFindWindow = new Interaction<FindWindowViewModel, int>();
|
||||||
var findEnabled = this.WhenAnyValue(x => x.CoinCollection.Count,
|
var findEnabled = this.WhenAnyValue(x => x.CoinCollection.Count,
|
||||||
x => x > 0);
|
x => x > 0);
|
||||||
FindCommand = ReactiveCommand.CreateFromTask(async () =>
|
FindCommand = ReactiveCommand.CreateFromTask(async () => {
|
||||||
{
|
|
||||||
var findViewModel = new FindWindowViewModel();
|
var findViewModel = new FindWindowViewModel();
|
||||||
var result = await ShowFindWindow.Handle(findViewModel);
|
var result = await ShowFindWindow.Handle(findViewModel);
|
||||||
// Find the coin with the matching ID. The issue is that there could be multiple - so we need to return a list.
|
// Find the coin with the matching ID. The issue is that there could be multiple - so we need to return a list.
|
||||||
// Perhaps a secondary viewmodel?
|
// Perhaps a secondary viewmodel?
|
||||||
return new Coin();
|
return new Coin();
|
||||||
}, findEnabled);
|
}, findEnabled);
|
||||||
|
|
||||||
// Subscribe to SidebarContent.OkCommand, which is an IObservable<(int, string, int)>
|
// Subscribe to SidebarContent.OkCommand, which is an IObservable<(int, string, int)>
|
||||||
// This is the same as the above, but with a different syntax.
|
// This is the same as the above, but with a different syntax.
|
||||||
newViewModel.OkCommand
|
newViewModel.OkCommand
|
||||||
.Subscribe(async requestStructure =>
|
.Subscribe(async requestStructure => {
|
||||||
{
|
|
||||||
var newCoin = await _pcgsClient.GetCoinFactsByGrade(requestStructure.Item1, requestStructure.Item2);
|
var newCoin = await _pcgsClient.GetCoinFactsByGrade(requestStructure.Item1, requestStructure.Item2);
|
||||||
newCoin.Quantity = requestStructure.Item3;
|
newCoin.Quantity = requestStructure.Item3;
|
||||||
CoinCollection.Add(newCoin);
|
CoinCollection.Add(newCoin);
|
||||||
TotalValue += newCoin.Quantity * newCoin.PriceGuideValue;
|
TotalValue += newCoin.Quantity * newCoin.PriceGuideValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Change TotalValue anytime SelectedCoin.TotalPrice changes.
|
// Change TotalValue anytime SelectedCoin.TotalPrice changes.
|
||||||
// Possible null deref - ignored due to null values summing to 0.
|
// Possible null deref - ignored due to null values summing to 0.
|
||||||
this.WhenAnyValue(x => x.SelectedCoin.TotalPrice)
|
this.WhenAnyValue(x => x.SelectedCoin.TotalPrice)
|
||||||
.Subscribe(_ => TotalValue = CoinCollection.Sum(x => x.TotalPrice) );
|
.Subscribe(_ => TotalValue = CoinCollection.Sum(x => x.TotalPrice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,31 +4,29 @@ 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 {
|
||||||
{
|
|
||||||
get => _pcgsNumber;
|
get => _pcgsNumber;
|
||||||
set => this.RaiseAndSetIfChanged(ref _pcgsNumber, value);
|
set => this.RaiseAndSetIfChanged(ref _pcgsNumber, value);
|
||||||
}
|
}
|
||||||
public string Grade
|
|
||||||
{
|
public string Grade {
|
||||||
get => _grade;
|
get => _grade;
|
||||||
set => this.RaiseAndSetIfChanged(ref _grade, value);
|
set => this.RaiseAndSetIfChanged(ref _grade, value);
|
||||||
}
|
}
|
||||||
public string Quantity
|
|
||||||
{
|
public string Quantity {
|
||||||
get => _quantity;
|
get => _quantity;
|
||||||
set => this.RaiseAndSetIfChanged(ref _quantity, value);
|
set => this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GradesList { get; }
|
public List<string> GradesList { get; }
|
||||||
|
|
||||||
public NewViewModel()
|
public NewViewModel() {
|
||||||
{
|
|
||||||
var okEnabled = this.WhenAnyValue(
|
var okEnabled = this.WhenAnyValue(
|
||||||
x => x.PcgsNumber,
|
x => x.PcgsNumber,
|
||||||
x => x.Grade,
|
x => x.Grade,
|
||||||
@@ -40,9 +38,8 @@ public class NewViewModel : ViewModelBase
|
|||||||
OkCommand = ReactiveCommand.Create(
|
OkCommand = ReactiveCommand.Create(
|
||||||
() => (int.Parse(PcgsNumber), Grade, int.Parse(Quantity)),
|
() => (int.Parse(PcgsNumber), Grade, int.Parse(Quantity)),
|
||||||
okEnabled);
|
okEnabled);
|
||||||
|
|
||||||
ClearCommand = ReactiveCommand.Create(() =>
|
ClearCommand = ReactiveCommand.Create(() => {
|
||||||
{
|
|
||||||
PcgsNumber = "";
|
PcgsNumber = "";
|
||||||
Grade = "";
|
Grade = "";
|
||||||
Quantity = "";
|
Quantity = "";
|
||||||
@@ -50,8 +47,7 @@ public class NewViewModel : ViewModelBase
|
|||||||
|
|
||||||
// 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.
|
||||||
GradesList = new List<string>
|
GradesList = new List<string> {
|
||||||
{
|
|
||||||
"P-01",
|
"P-01",
|
||||||
"FR-02",
|
"FR-02",
|
||||||
"AG-03",
|
"AG-03",
|
||||||
@@ -84,8 +80,7 @@ public class NewViewModel : ViewModelBase
|
|||||||
"MS-70"
|
"MS-70"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReactiveCommand<Unit, (int, string, int)> OkCommand { get; }
|
public ReactiveCommand<Unit, (int, string, int)> OkCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
|
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace PcgsInvUi.ViewModels;
|
namespace PcgsInvUi.ViewModels;
|
||||||
|
|
||||||
public class ViewModelBase : ReactiveObject
|
public class ViewModelBase : ReactiveObject { }
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -7,18 +7,18 @@
|
|||||||
Width="325" Height="100" WindowStartupLocation="CenterOwner"
|
Width="325" Height="100" WindowStartupLocation="CenterOwner"
|
||||||
Title="DeleteWindow">
|
Title="DeleteWindow">
|
||||||
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
|
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
|
||||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="10"
|
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="10"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
Content="Are you sure you want to delete this item?"/>
|
Content="Are you sure you want to delete this item?" />
|
||||||
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
<Button Grid.Row="1" Grid.Column="0" Margin="5"
|
||||||
Width="100"
|
Width="100"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Content="Yes" Command="{Binding OkCommand}"/>
|
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" Command="{Binding CancelCommand}"/>
|
Content="No" Command="{Binding CancelCommand}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -5,10 +5,8 @@ using System;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
public partial class DeleteWindow : ReactiveWindow<DeleteWindowViewModel>
|
public partial class DeleteWindow : ReactiveWindow<DeleteWindowViewModel> {
|
||||||
{
|
public DeleteWindow() {
|
||||||
public DeleteWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
x:Class="PcgsInvUi.Views.FindWindow"
|
x:Class="PcgsInvUi.Views.FindWindow"
|
||||||
Title="FindWindow">
|
Title="FindWindow">
|
||||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="*, *">
|
<Grid ColumnDefinitions="Auto, *" RowDefinitions="*, *">
|
||||||
<Label Content="PCGS #:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5"/>
|
<Label Content="PCGS #:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" />
|
||||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5"/>
|
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" />
|
||||||
<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Content="Find"
|
<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Content="Find"
|
||||||
HorizontalAlignment="Center" Margin="5" Width="75"/>
|
HorizontalAlignment="Center" Margin="5" Width="75" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -5,10 +5,8 @@ using System;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
public partial class FindWindow : ReactiveWindow<FindWindowViewModel>
|
public partial class FindWindow : ReactiveWindow<FindWindowViewModel> {
|
||||||
{
|
public FindWindow() {
|
||||||
public FindWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
WindowStartupLocation="CenterOwner">
|
WindowStartupLocation="CenterOwner">
|
||||||
<SplitView IsPaneOpen="True"
|
<SplitView IsPaneOpen="True"
|
||||||
DisplayMode="Inline"
|
DisplayMode="Inline"
|
||||||
PanePlacement="Right" >
|
PanePlacement="Right">
|
||||||
<SplitView.Pane>
|
<SplitView.Pane>
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
<UserControl Grid.Row="0" Margin="10, 20, 10, 10" VerticalAlignment="Center" Content="{Binding SidebarContent}"/>
|
<UserControl Grid.Row="0" Margin="10, 20, 10, 10" VerticalAlignment="Center"
|
||||||
<TextBox Grid.Row="1" Margin="5" Watermark="Notes..."/>
|
Content="{Binding SidebarContent}" />
|
||||||
|
<TextBox Grid.Row="1" Margin="5" Watermark="Notes..." />
|
||||||
</Grid>
|
</Grid>
|
||||||
</SplitView.Pane>
|
</SplitView.Pane>
|
||||||
<Grid RowDefinitions="*, Auto" ShowGridLines="False">
|
<Grid RowDefinitions="*, Auto" ShowGridLines="False">
|
||||||
@@ -26,51 +27,56 @@
|
|||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Series" Width="*"
|
<DataGridTextColumn Header="Series" Width="*"
|
||||||
Binding="{Binding SeriesName}"
|
Binding="{Binding SeriesName}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Year"
|
<DataGridTextColumn Header="Year"
|
||||||
Binding="{Binding Year}"
|
Binding="{Binding Year}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Mint" Width="*"
|
<DataGridTextColumn Header="Mint" Width="*"
|
||||||
Binding="{Binding MintMark}"
|
Binding="{Binding MintMark}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Denomination" Width="*"
|
<DataGridTextColumn Header="Denomination" Width="*"
|
||||||
Binding="{Binding Denomination}"
|
Binding="{Binding Denomination}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Variety" Width="*"
|
<DataGridTextColumn Header="Variety" Width="*"
|
||||||
Binding="{Binding MajorVariety}"
|
Binding="{Binding MajorVariety}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Grade" Width="*"
|
<DataGridTextColumn Header="Grade" Width="*"
|
||||||
Binding="{Binding Grade}"
|
Binding="{Binding Grade}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Designation" Width="*"
|
<DataGridTextColumn Header="Designation" Width="*"
|
||||||
Binding="{Binding Designation}"
|
Binding="{Binding Designation}"
|
||||||
IsReadOnly="True"/>
|
IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Est. Price" Width="*"
|
<DataGridTextColumn Header="Est. Price" Width="*"
|
||||||
Binding="{Binding PriceGuideValue}"
|
Binding="{Binding PriceGuideValue}"
|
||||||
IsReadOnly="False"/>
|
IsReadOnly="False" />
|
||||||
<DataGridTextColumn Header="PCGS #" Width="*"
|
<DataGridTextColumn Header="PCGS #" Width="*"
|
||||||
Binding="{Binding PCGSNo}"
|
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, StringFormat='${0:0.00}'}"
|
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" DockPanel.Dock="Left">
|
<Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto"
|
||||||
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
DockPanel.Dock="Left">
|
||||||
Command="{Binding DeleteCommand}"/>
|
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
||||||
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Find..."
|
Command="{Binding DeleteCommand}" />
|
||||||
Command="{Binding FindCommand}"/>
|
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center"
|
||||||
|
Content="Find..."
|
||||||
|
Command="{Binding FindCommand}" />
|
||||||
</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"
|
||||||
<Label Grid.Column="0" Margin="5" VerticalAlignment="Center" Content="{Binding TotalValue, StringFormat='Total Value: ${0:0.00}'}" />
|
DockPanel.Dock="Right">
|
||||||
<Button Grid.Column="1" Margin="5" Width="150" HorizontalContentAlignment="Center" Content="Export to CSV..." />
|
<Label Grid.Column="0" Margin="5" VerticalAlignment="Center"
|
||||||
|
Content="{Binding TotalValue, StringFormat='Total Value: ${0:0.00}'}" />
|
||||||
|
<Button Grid.Column="1" Margin="5" Width="150" HorizontalContentAlignment="Center"
|
||||||
|
Content="Export to CSV..." />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</SplitView>
|
</SplitView>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -6,26 +6,22 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
public partial class MainWindow : ReactiveWindow<MainWindowViewModel> {
|
||||||
{
|
public MainWindow() {
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(d => d(ViewModel!.ShowDeleteWindow.RegisterHandler(ShowDeleteWindowAsync)));
|
this.WhenActivated(d => d(ViewModel!.ShowDeleteWindow.RegisterHandler(ShowDeleteWindowAsync)));
|
||||||
this.WhenActivated(d => d(ViewModel!.ShowFindWindow.RegisterHandler(ShowFindWindowAsync)));
|
this.WhenActivated(d => d(ViewModel!.ShowFindWindow.RegisterHandler(ShowFindWindowAsync)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ShowDeleteWindowAsync(InteractionContext<DeleteWindowViewModel, Boolean> interaction)
|
public async Task ShowDeleteWindowAsync(InteractionContext<DeleteWindowViewModel, Boolean> interaction) {
|
||||||
{
|
|
||||||
var window = new DeleteWindow();
|
var window = new DeleteWindow();
|
||||||
window.DataContext = interaction.Input;
|
window.DataContext = interaction.Input;
|
||||||
|
|
||||||
var result = await window.ShowDialog<bool>(this);
|
var result = await window.ShowDialog<bool>(this);
|
||||||
interaction.SetOutput(result);
|
interaction.SetOutput(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ShowFindWindowAsync(InteractionContext<FindWindowViewModel, int> interaction)
|
public async Task ShowFindWindowAsync(InteractionContext<FindWindowViewModel, int> interaction) {
|
||||||
{
|
|
||||||
var window = new FindWindow();
|
var window = new FindWindow();
|
||||||
window.DataContext = interaction.Input;
|
window.DataContext = interaction.Input;
|
||||||
|
|
||||||
|
|||||||
@@ -7,19 +7,20 @@
|
|||||||
x:Class="PcgsInvUi.Views.NewView" x:DataType="viewmodels:NewViewModel">
|
x:Class="PcgsInvUi.Views.NewView" x:DataType="viewmodels:NewViewModel">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Grid DockPanel.Dock="Top" ColumnDefinitions="Auto, *" RowDefinitions="*, *, *">
|
<Grid DockPanel.Dock="Top" ColumnDefinitions="Auto, *" RowDefinitions="*, *, *">
|
||||||
<Label Grid.Column="0" Grid.Row="0" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="PCGS #:"/>
|
<Label Grid.Column="0" Grid.Row="0" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="PCGS #:" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="0" Margin="5, 5, 10, 5" Text="{Binding PcgsNumber}"/>
|
<TextBox Grid.Column="1" Grid.Row="0" Margin="5, 5, 10, 5" Text="{Binding PcgsNumber}" />
|
||||||
<Label Grid.Column="0" Grid.Row="1" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="Grade:"/>
|
<Label Grid.Column="0" Grid.Row="1" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="Grade:" />
|
||||||
<ComboBox Name="GradeChoices" Grid.Column="1" Grid.Row="1" SelectedIndex="0" Margin="5, 5, 10, 5" Width="150"
|
<ComboBox Name="GradeChoices" Grid.Column="1" Grid.Row="1" SelectedIndex="0" Margin="5, 5, 10, 5"
|
||||||
ItemsSource="{Binding GradesList}" SelectedItem="{Binding Grade}"/>
|
Width="150"
|
||||||
<Label Grid.Column="0" Grid.Row="2" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="Quantity:"/>
|
ItemsSource="{Binding GradesList}" SelectedItem="{Binding Grade}" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="2" Margin="5, 5, 10, 5" Text="{Binding Quantity}"/>
|
<Label Grid.Column="0" Grid.Row="2" Margin="5, 5, 20, 5" VerticalAlignment="Center" Content="Quantity:" />
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="2" Margin="5, 5, 10, 5" Text="{Binding Quantity}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid DockPanel.Dock="Bottom" ColumnDefinitions="*, *">
|
<Grid DockPanel.Dock="Bottom" ColumnDefinitions="*, *">
|
||||||
<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="Clear" Command="{Binding ClearCommand}" />
|
Width="90" HorizontalContentAlignment="Center" Content="Clear" Command="{Binding ClearCommand}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -4,10 +4,8 @@ using Avalonia.Markup.Xaml;
|
|||||||
|
|
||||||
namespace PcgsInvUi.Views;
|
namespace PcgsInvUi.Views;
|
||||||
|
|
||||||
public partial class NewView : UserControl
|
public partial class NewView : UserControl {
|
||||||
{
|
public NewView() {
|
||||||
public NewView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-13
@@ -1,18 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<!-- This manifest is used on Windows only.
|
<!-- This manifest is used on Windows only.
|
||||||
Don't remove it as it might cause problems with window transparency and embeded controls.
|
Don't remove it as it might cause problems with window transparency and embeded controls.
|
||||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||||
<assemblyIdentity version="1.0.0.0" name="PcgsInvUi.Desktop"/>
|
<assemblyIdentity version="1.0.0.0" name="PcgsInvUi.Desktop"/>
|
||||||
|
|
||||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
<application>
|
<application>
|
||||||
<!-- A list of the Windows versions that this application has been tested on
|
<!-- A list of the Windows versions that this application has been tested on
|
||||||
and is designed to work with. Uncomment the appropriate elements
|
and is designed to work with. Uncomment the appropriate elements
|
||||||
and Windows will automatically select the most compatible environment. -->
|
and Windows will automatically select the most compatible environment. -->
|
||||||
|
|
||||||
<!-- Windows 10 -->
|
<!-- Windows 10 -->
|
||||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
</application>
|
</application>
|
||||||
</compatibility>
|
</compatibility>
|
||||||
</assembly>
|
</assembly>
|
||||||
Reference in new issue
Block a user