Initial commit
This commit is contained in:
commit
8c7e1b917f
180 files changed
+7747
No files matched your search
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using PcgsInvUi.Models;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class CoinListViewModel : ViewModelBase
|
||||
{
|
||||
public ObservableCollection<Coin> CoinCollection { get; set; }
|
||||
private float _totalValue;
|
||||
public float TotalValue
|
||||
{
|
||||
get => _totalValue;
|
||||
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
||||
}
|
||||
public Coin? SelectedCoin { get; set; }
|
||||
|
||||
public CoinListViewModel(IEnumerable<Coin> items)
|
||||
{
|
||||
CoinCollection = new ObservableCollection<Coin>(items);
|
||||
TotalValue = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using PcgsInvUi.Models;
|
||||
using PcgsInvUi.Services;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public CoinListViewModel List { get; }
|
||||
private ViewModelBase _content;
|
||||
|
||||
public MainWindowViewModel(CoinCollection coins)
|
||||
{
|
||||
List = new CoinListViewModel(coins.GetItems());
|
||||
Content = List;
|
||||
}
|
||||
|
||||
public ViewModelBase Content
|
||||
{
|
||||
get => _content;
|
||||
private set => this.RaiseAndSetIfChanged(ref _content, value);
|
||||
}
|
||||
|
||||
public void AddItem()
|
||||
{
|
||||
Console.WriteLine("You hit the button!");
|
||||
var newViewModel = new NewViewModel();
|
||||
|
||||
Observable.Merge(
|
||||
newViewModel.OkCommand,
|
||||
newViewModel.CancelCommand.Select(_ => (Coin?)null))
|
||||
.Take(1)
|
||||
.Subscribe(model =>
|
||||
{
|
||||
if (model != null)
|
||||
List.CoinCollection.Add(model);
|
||||
|
||||
Content = List;
|
||||
});
|
||||
|
||||
Content = newViewModel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using PcgsInvUi.Models;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class NewViewModel : ViewModelBase
|
||||
{
|
||||
private string _pcgsNumber;
|
||||
private string _grade;
|
||||
private string _quantity;
|
||||
|
||||
public string PcgsNumber
|
||||
{
|
||||
get => _pcgsNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _pcgsNumber, value);
|
||||
}
|
||||
public string Grade
|
||||
{
|
||||
get => _grade;
|
||||
set => this.RaiseAndSetIfChanged(ref _grade, value);
|
||||
}
|
||||
public string Quantity
|
||||
{
|
||||
get => _quantity;
|
||||
set => this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||
}
|
||||
|
||||
public NewViewModel()
|
||||
{
|
||||
var okEnabled = this.WhenAnyValue(
|
||||
x => x.PcgsNumber,
|
||||
x => !string.IsNullOrWhiteSpace(x));
|
||||
|
||||
OkCommand = ReactiveCommand.Create(
|
||||
() => new Coin { PcgsNumber = Int32.Parse(PcgsNumber) },
|
||||
okEnabled);
|
||||
CancelCommand = ReactiveCommand.Create(() => { });
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Coin> OkCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class ViewModelBase : ReactiveObject
|
||||
{
|
||||
}
|
||||
Reference in new issue
Block a user