diff --git a/.idea/.idea.pcgs-inv/.idea/avalonia.xml b/.idea/.idea.pcgs-inv/.idea/avalonia.xml
index 2e6f308..94e266f 100644
--- a/.idea/.idea.pcgs-inv/.idea/avalonia.xml
+++ b/.idea/.idea.pcgs-inv/.idea/avalonia.xml
@@ -6,6 +6,7 @@
+
diff --git a/PcgsInvUi/Services/CoinCollection.cs b/PcgsInvUi/Services/CoinCollection.cs
index 56badb3..7852adf 100644
--- a/PcgsInvUi/Services/CoinCollection.cs
+++ b/PcgsInvUi/Services/CoinCollection.cs
@@ -10,19 +10,5 @@ public class CoinCollection
new Coin(),
new Coin(),
new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
- new Coin(),
};
}
\ No newline at end of file
diff --git a/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs b/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
index 076b93e..409a067 100644
--- a/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
+++ b/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
@@ -6,11 +6,12 @@ namespace PcgsInvUi.ViewModels;
public class DeleteWindowViewModel : ViewModelBase
{
- public ReactiveCommand OkCommand { get; } = ReactiveCommand.Create(() => (object)true);
+ public ReactiveCommand OkCommand { get; }
public ReactiveCommand CancelCommand { get; }
public DeleteWindowViewModel()
{
+ OkCommand = ReactiveCommand.Create(() => (object)true);
CancelCommand = ReactiveCommand.Create(window => window.Close());
}
}
\ No newline at end of file
diff --git a/PcgsInvUi/ViewModels/FindWindowViewModel.cs b/PcgsInvUi/ViewModels/FindWindowViewModel.cs
new file mode 100644
index 0000000..f3551de
--- /dev/null
+++ b/PcgsInvUi/ViewModels/FindWindowViewModel.cs
@@ -0,0 +1,9 @@
+using System.Reactive;
+using ReactiveUI;
+
+namespace PcgsInvUi.ViewModels;
+
+public class FindWindowViewModel : ViewModelBase
+{
+ public ReactiveCommand OkCommand { get; } = ReactiveCommand.Create(() => (object)1);
+}
\ No newline at end of file
diff --git a/PcgsInvUi/ViewModels/MainWindowViewModel.cs b/PcgsInvUi/ViewModels/MainWindowViewModel.cs
index d8576ca..39b1b7b 100644
--- a/PcgsInvUi/ViewModels/MainWindowViewModel.cs
+++ b/PcgsInvUi/ViewModels/MainWindowViewModel.cs
@@ -27,6 +27,7 @@ public class MainWindowViewModel : ViewModelBase
private set => this.RaiseAndSetIfChanged(ref _sideContent, value);
}
public ObservableCollection CoinCollection { get; set; }
+ public ObservableCollection DisplayedList { get; set; }
public Coin? SelectedCoin
{
get => _selectedCoin;
@@ -39,6 +40,8 @@ public class MainWindowViewModel : ViewModelBase
}
public ReactiveCommand DeleteCommand { get; }
public Interaction ShowDeleteWindow { get; }
+ public ReactiveCommand FindCommand { get; }
+ public Interaction ShowFindWindow { get; }
private ViewModelBase _sideContent;
private Coin? _selectedCoin;
@@ -49,9 +52,10 @@ public class MainWindowViewModel : ViewModelBase
{
var newViewModel = new NewViewModel();
_sideContent = newViewModel;
- CoinCollection = new ObservableCollection(coins.GetItems());
+ DisplayedList = CoinCollection = new ObservableCollection(coins.GetItems());
_pcgsClient = new PcgsClient("eAb8gS0I2XAvT_5gJeiGJaglMia1Tk-oB4kJUK6kuafyrny_S61vIJY-Ikl4nCQM67wrdxzUqLVWTV2kBSxD3d5XNBHxHnYBhcSS6dOPug0hZaF3qAv56df3gYSzOGh9Tif5y0eP3Iw0LrqKDr1Hj-dk6SV6GKog2IIqCPQhhHH8FMTWBTYO-_O8cx7qLdM5GM8KlTsic6g3VRUhM8EA_4OO04dCfmNLGhqINRl3jGZ0Q4ziI8fng2bVWsIyteqiPzUn10rIQ3-OPpqVZG_DxeOmOejj4GzbUNyqUOajy-nr5rYY");
+ // Set up the ability to open the delete window.
ShowDeleteWindow = new Interaction();
var deleteEnabled = this.WhenAnyValue(x => x.SelectedCoin)
.Select(x => x != null);
@@ -61,6 +65,19 @@ public class MainWindowViewModel : ViewModelBase
var result = await ShowDeleteWindow.Handle(deleteViewModel);
if (result) CoinCollection.Remove(SelectedCoin); // possible null deref - ignored due to button being disabled.
}, deleteEnabled);
+
+ // Set up the ability to open the find window.
+ ShowFindWindow = new Interaction();
+ var findEnabled = this.WhenAnyValue(x => x.CoinCollection.Count,
+ x => x > 0);
+ FindCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ var findViewModel = new FindWindowViewModel();
+ 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.
+ // Perhaps a secondary viewmodel?
+ return new Coin();
+ }, findEnabled);
// Subscribe to SidebarContent.OkCommand, which is an IObservable<(int, string, int)>
// This is the same as the above, but with a different syntax.
diff --git a/PcgsInvUi/ViewModels/NewViewModel.cs b/PcgsInvUi/ViewModels/NewViewModel.cs
index db4504c..5bacdac 100644
--- a/PcgsInvUi/ViewModels/NewViewModel.cs
+++ b/PcgsInvUi/ViewModels/NewViewModel.cs
@@ -50,7 +50,7 @@ public class NewViewModel : ViewModelBase
// 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()
+ GradesList = new List
{
"P-01",
"FR-02",
diff --git a/PcgsInvUi/Views/DeleteWindow.axaml.cs b/PcgsInvUi/Views/DeleteWindow.axaml.cs
index 8c2104e..c51a5c5 100644
--- a/PcgsInvUi/Views/DeleteWindow.axaml.cs
+++ b/PcgsInvUi/Views/DeleteWindow.axaml.cs
@@ -3,7 +3,6 @@ using Avalonia.ReactiveUI;
using ReactiveUI;
using System;
-
namespace PcgsInvUi.Views;
public partial class DeleteWindow : ReactiveWindow
diff --git a/PcgsInvUi/Views/FindWindow.axaml b/PcgsInvUi/Views/FindWindow.axaml
new file mode 100644
index 0000000..e211b56
--- /dev/null
+++ b/PcgsInvUi/Views/FindWindow.axaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/PcgsInvUi/Views/FindWindow.axaml.cs b/PcgsInvUi/Views/FindWindow.axaml.cs
new file mode 100644
index 0000000..bd3ab73
--- /dev/null
+++ b/PcgsInvUi/Views/FindWindow.axaml.cs
@@ -0,0 +1,15 @@
+using Avalonia.ReactiveUI;
+using PcgsInvUi.ViewModels;
+using ReactiveUI;
+using System;
+
+namespace PcgsInvUi.Views;
+
+public partial class FindWindow : ReactiveWindow
+{
+ public FindWindow()
+ {
+ InitializeComponent();
+ this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
+ }
+}
\ No newline at end of file
diff --git a/PcgsInvUi/Views/MainWindow.axaml b/PcgsInvUi/Views/MainWindow.axaml
index b796068..8cec53b 100644
--- a/PcgsInvUi/Views/MainWindow.axaml
+++ b/PcgsInvUi/Views/MainWindow.axaml
@@ -19,7 +19,7 @@
diff --git a/PcgsInvUi/Views/MainWindow.axaml.cs b/PcgsInvUi/Views/MainWindow.axaml.cs
index da0674a..6938c9d 100644
--- a/PcgsInvUi/Views/MainWindow.axaml.cs
+++ b/PcgsInvUi/Views/MainWindow.axaml.cs
@@ -22,4 +22,13 @@ public partial class MainWindow : ReactiveWindow
var result = await window.ShowDialog(this);
interaction.SetOutput(result);
}
+
+ public async Task ShowFindWindowAsync(InteractionContext interaction)
+ {
+ var window = new FindWindow();
+ window.DataContext = interaction.Input;
+
+ var result = await window.ShowDialog(this);
+ interaction.SetOutput(result);
+ }
}
\ No newline at end of file