Added the NewControl as a content replacement for the MainWindow.

This commit is contained in:
alphafetus committed 2023-10-09 14:56:06 -04:00
1 parent 8c7e1b917f
commit 0e5be04b02
31 files changed
+262 -153

No files matched your search

+49 -3
View File
@@ -1,5 +1,6 @@
using System;
using System.Reactive;
using System.Collections.Generic;
using PcgsInvUi.Models;
using ReactiveUI;
@@ -26,17 +27,62 @@ public class NewViewModel : ViewModelBase
get => _quantity;
set => this.RaiseAndSetIfChanged(ref _quantity, value);
}
public List<string> GradesList { get; }
public NewViewModel()
{
var okEnabled = this.WhenAnyValue(
x => x.PcgsNumber,
x => !string.IsNullOrWhiteSpace(x));
x => x.Grade,
x => x.Quantity,
(id, grade, quantity) => !string.IsNullOrWhiteSpace(id) &&
!string.IsNullOrWhiteSpace(grade) &&
!string.IsNullOrWhiteSpace(quantity));
// This will eventually send our request to the public API, then construct our coin.
OkCommand = ReactiveCommand.Create(
() => new Coin { PcgsNumber = Int32.Parse(PcgsNumber) },
() => new Coin { PcgsNumber = Int32.Parse(PcgsNumber),
Grade = Grade,
Quantity = Int32.Parse(Quantity) },
okEnabled);
CancelCommand = ReactiveCommand.Create(() => { });
// 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.
GradesList = new List<string>()
{
"P-01",
"FR-02",
"AG-03",
"G-04",
"G-06",
"VG-08",
"VG-10",
"F-12",
"F-15",
"VF-20",
"VF-25",
"VF-30",
"VF-35",
"EF-40",
"EF-45",
"AU-50",
"AU-53",
"AU-55",
"AU-58",
"MS-60",
"MS-61",
"MS-62",
"MS-63",
"MS-64",
"MS-65",
"MS-66",
"MS-67",
"MS-68",
"MS-69",
"MS-70"
};
}
public ReactiveCommand<Unit, Coin> OkCommand { get; }