Created frame for FindWindow, shortened CoinCollection
This commit is contained in:
1 parent
f298296471
commit
3234b12184
11 files changed
+70
-19
No files matched your search
@@ -27,6 +27,7 @@ public class MainWindowViewModel : ViewModelBase
|
||||
private set => this.RaiseAndSetIfChanged(ref _sideContent, value);
|
||||
}
|
||||
public ObservableCollection<Coin> CoinCollection { get; set; }
|
||||
public ObservableCollection<Coin> DisplayedList { get; set; }
|
||||
public Coin? SelectedCoin
|
||||
{
|
||||
get => _selectedCoin;
|
||||
@@ -39,6 +40,8 @@ public class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
public ReactiveCommand<Unit, Unit> DeleteCommand { get; }
|
||||
public Interaction<DeleteWindowViewModel, Boolean> ShowDeleteWindow { get; }
|
||||
public ReactiveCommand<Unit, Coin> FindCommand { get; }
|
||||
public Interaction<FindWindowViewModel, int> 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<Coin>(coins.GetItems());
|
||||
DisplayedList = CoinCollection = new ObservableCollection<Coin>(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<DeleteWindowViewModel, bool>();
|
||||
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<FindWindowViewModel, int>();
|
||||
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.
|
||||
|
||||
Reference in new issue
Block a user