Added .gitignore and created delete window.
This commit is contained in:
1 parent
8c53024d5c
commit
8249d9a27b
14 files changed
+188
-127
No files matched your search
@@ -0,0 +1 @@
|
||||
/PcgsInvUi/bin/
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="PcgsInvUi.App"
|
||||
xmlns:local="using:PcgsInvUi"
|
||||
RequestedThemeVariant="Dark">
|
||||
RequestedThemeVariant="Light">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.DataTemplates>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using PcgsInvUi.Services;
|
||||
using PcgsInvUi.ViewModels;
|
||||
using PcgsInvUi.Views;
|
||||
|
||||
|
||||
+52
-13
@@ -5,12 +5,12 @@ namespace PcgsInvUi.Models;
|
||||
|
||||
public class Coin : ReactiveObject
|
||||
{
|
||||
public int PcgsNumber
|
||||
public string PCGSNo
|
||||
{
|
||||
get => _pcgsNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref _pcgsNumber, value);
|
||||
get => _pcgsNo;
|
||||
set => this.RaiseAndSetIfChanged(ref _pcgsNo, value);
|
||||
}
|
||||
private int _pcgsNumber;
|
||||
private string _pcgsNo;
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -50,8 +50,13 @@ public class Coin : ReactiveObject
|
||||
public double PriceGuideValue
|
||||
{
|
||||
get => _priceGuideValue;
|
||||
set => this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
||||
set
|
||||
{
|
||||
TotalPrice = value * Quantity;
|
||||
this.RaiseAndSetIfChanged(ref _priceGuideValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _priceGuideValue;
|
||||
|
||||
public string CoinFactsLink
|
||||
@@ -82,12 +87,12 @@ public class Coin : ReactiveObject
|
||||
}
|
||||
private string _dieVariety;
|
||||
|
||||
public string Series
|
||||
public string SeriesName
|
||||
{
|
||||
get => _series;
|
||||
set => this.RaiseAndSetIfChanged(ref _series, value);
|
||||
get => _seriesName;
|
||||
set => this.RaiseAndSetIfChanged(ref _seriesName, value);
|
||||
}
|
||||
private string _series;
|
||||
private string _seriesName;
|
||||
|
||||
public string Category
|
||||
{
|
||||
@@ -113,11 +118,21 @@ public class Coin : ReactiveObject
|
||||
public int Quantity
|
||||
{
|
||||
get => _quantity;
|
||||
set => this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||
set
|
||||
{
|
||||
TotalPrice = value * PriceGuideValue;
|
||||
this.RaiseAndSetIfChanged(ref _quantity, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int _quantity;
|
||||
|
||||
public double TotalPrice => Quantity * PriceGuideValue;
|
||||
|
||||
public double TotalPrice
|
||||
{
|
||||
get => _totalPrice;
|
||||
set => this.RaiseAndSetIfChanged(ref _totalPrice, value);
|
||||
}
|
||||
private double _totalPrice;
|
||||
|
||||
public double PaidFor
|
||||
{
|
||||
@@ -126,10 +141,34 @@ public class Coin : ReactiveObject
|
||||
}
|
||||
private double _paidFor;
|
||||
|
||||
public String Notes
|
||||
public string Notes
|
||||
{
|
||||
get => _notes;
|
||||
set => this.RaiseAndSetIfChanged(ref _notes, value);
|
||||
}
|
||||
private string _notes;
|
||||
|
||||
public Coin()
|
||||
{
|
||||
PCGSNo = "";
|
||||
Name = "";
|
||||
Year = 0;
|
||||
Denomination = "";
|
||||
MintMark = "";
|
||||
Grade = "";
|
||||
PriceGuideValue = 0;
|
||||
CoinFactsLink = "";
|
||||
MajorVariety = "";
|
||||
MinorVariety = "";
|
||||
DieVariety = "";
|
||||
SeriesName = "";
|
||||
Category = "";
|
||||
Designation = "";
|
||||
CertificateNumber = 0;
|
||||
Quantity = 0;
|
||||
PaidFor = 0;
|
||||
Notes = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,12 @@
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
// using Newtonsoft.Json;
|
||||
using PcgsInvUi.Models;
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PcgsInvUi.Services;
|
||||
|
||||
public class PcgsClient
|
||||
@@ -14,23 +17,30 @@ public class PcgsClient
|
||||
|
||||
public PcgsClient(string apiKey)
|
||||
{
|
||||
_apiKey = apiKey;
|
||||
// _apiKey = apiKey;
|
||||
_apiKey =
|
||||
"E8xivTVN_k4Q8ubk8Xv_uU11U91WX0wDht4S4m4BAf2HPmKnGrZ0J2f9nccM7Ns1VkGoT1SXYR74I7aNaMKqXlJGEy3oobseKV0nGiqu1IKvFkOTVjhV37SWUVExSDFMC6FLzs7xJQIHwkcxr5JFOQNmc4ZytEh_-hmCN3NL-z0fEk98tzBmPJ_F7bq_xNru86QMD2A9yalu_dWe-lCysfyE2bCA2EDqwvWenRYf-0XnNtp6qlxxCMlCd-TDqqRKLC3qefCwpXSemwBiNSP5gbC9pwcKrZugkruuJ0nyxxThZymm";
|
||||
}
|
||||
|
||||
public async Task<Coin> GetCoinFactsByGrade(int pcgsNumber, int grade, bool plusGrade)
|
||||
public async Task<Coin> GetCoinFactsByGrade(int pcgsNumber, string grade, bool plusGrade = false)
|
||||
{
|
||||
Coin newCoin = null;
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
var gradeParam = GetGradeFromString(grade);
|
||||
|
||||
string requestUri =
|
||||
$"{_apiUri}/coindetail/GetCoinFactsByGrade/?PCGSNo={pcgsNumber}&GradeNo={grade}&PlusGrade={plusGrade}";
|
||||
$"{_apiUri}/coindetail/GetCoinFactsByGrade/?PCGSNo={pcgsNumber}&GradeNo={gradeParam}&PlusGrade={plusGrade}";
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", _apiKey);
|
||||
Console.WriteLine($"Sending request to {requestUri}");
|
||||
HttpResponseMessage response = await client.GetAsync(requestUri);
|
||||
Console.WriteLine("Got response.");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
newCoin = ParseJsonResponse(jsonResponse);
|
||||
Console.WriteLine("Coin created.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -40,12 +50,25 @@ public class PcgsClient
|
||||
|
||||
return newCoin;
|
||||
}
|
||||
|
||||
// TODO Will eventually create the other methods that are included in the Public API.
|
||||
|
||||
private int GetGradeFromString(string grade)
|
||||
{
|
||||
var actualGrade = int.Parse(grade.Substring(grade.Length - 2));
|
||||
Console.WriteLine($"Grade is {actualGrade}");
|
||||
return actualGrade;
|
||||
}
|
||||
|
||||
// TODO Will eventually create the other methods that are included in the Public API.
|
||||
|
||||
private Coin ParseJsonResponse(string json)
|
||||
{
|
||||
Coin newCoin = JsonConvert.DeserializeObject<Coin>(json);
|
||||
Console.WriteLine(json);
|
||||
Coin newCoin = JsonSerializer.Deserialize<Coin>(json);
|
||||
Console.WriteLine($"New Coin has pcgs number {newCoin.PCGSNo}");
|
||||
|
||||
string test = JsonSerializer.Serialize(newCoin);
|
||||
Console.WriteLine(test);
|
||||
|
||||
return newCoin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Windows.Input;
|
||||
using System.Xml;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class DeleteWindowViewModel : ViewModelBase
|
||||
{
|
||||
public ReactiveCommand<Unit, object> OkCommand { get; } = ReactiveCommand.Create(() => (object)true);
|
||||
public ReactiveCommand<Unit, object> CancelCommand { get; } = ReactiveCommand.Create(() => (object)false);
|
||||
}
|
||||
@@ -16,10 +16,10 @@ public class EditViewModel : ViewModelBase
|
||||
CurrentCoin = coin;
|
||||
|
||||
var okEnabled = this.WhenAnyValue(
|
||||
x => x.CurrentCoin.PcgsNumber,
|
||||
x => x.CurrentCoin.PCGSNo,
|
||||
x => x.CurrentCoin.Grade,
|
||||
x => x.CurrentCoin.Quantity,
|
||||
(id, grade, quantity) => (id != 0) &&
|
||||
(id, grade, quantity) => !string.IsNullOrWhiteSpace(id) &&
|
||||
!string.IsNullOrWhiteSpace(grade) &&
|
||||
(quantity != 0)
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using PcgsInvUi.Models;
|
||||
using PcgsInvUi.Services;
|
||||
using ReactiveUI;
|
||||
@@ -10,11 +10,6 @@ namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public bool PaneOpen
|
||||
{
|
||||
get => _paneOpen;
|
||||
set => this.RaiseAndSetIfChanged(ref _paneOpen, value);
|
||||
}
|
||||
public ViewModelBase SidebarContent
|
||||
{
|
||||
get => _sideContent;
|
||||
@@ -31,54 +26,39 @@ public class MainWindowViewModel : ViewModelBase
|
||||
get => _totalValue;
|
||||
set => this.RaiseAndSetIfChanged(ref _totalValue, value);
|
||||
}
|
||||
public ICommand DeleteCommand { get; }
|
||||
public Interaction<DeleteWindowViewModel, Boolean> ShowDeleteWindow { get; }
|
||||
|
||||
private ViewModelBase? _sideContent;
|
||||
private Coin? _selectedCoin;
|
||||
private bool _paneOpen;
|
||||
private double _totalValue;
|
||||
private PcgsClient _pcgsClient;
|
||||
|
||||
public MainWindowViewModel(CoinCollection coins)
|
||||
{
|
||||
CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
||||
}
|
||||
|
||||
public void AddItem()
|
||||
{
|
||||
var newViewModel = new NewViewModel();
|
||||
|
||||
Observable.Merge(
|
||||
newViewModel.OkCommand,
|
||||
newViewModel.CancelCommand.Select(_ => (Coin?)null))
|
||||
.Take(1)
|
||||
.Subscribe(newCoin =>
|
||||
{
|
||||
if (newCoin != null)
|
||||
{
|
||||
// This raises a CollectionChanged event, which *should* update the UI, but doesn't.
|
||||
CoinCollection.Add(newCoin);
|
||||
// Update view
|
||||
TotalValue += newCoin.TotalPrice;
|
||||
|
||||
// Setting main content to null and then back to the main view model works just fine.
|
||||
// TotalValue updates just fine.
|
||||
}
|
||||
|
||||
SidebarContent = null;
|
||||
PaneOpen = false;
|
||||
});
|
||||
|
||||
SidebarContent = newViewModel;
|
||||
PaneOpen = true;
|
||||
}
|
||||
|
||||
public void EditItem()
|
||||
{
|
||||
var editViewModel = new EditViewModel(SelectedCoin);
|
||||
}
|
||||
|
||||
public void DeleteItem()
|
||||
{
|
||||
CoinCollection = new ObservableCollection<Coin>(coins.GetItems());
|
||||
_pcgsClient = new PcgsClient("eAb8gS0I2XAvT_5gJeiGJaglMia1Tk-oB4kJUK6kuafyrny_S61vIJY-Ikl4nCQM67wrdxzUqLVWTV2kBSxD3d5XNBHxHnYBhcSS6dOPug0hZaF3qAv56df3gYSzOGh9Tif5y0eP3Iw0LrqKDr1Hj-dk6SV6GKog2IIqCPQhhHH8FMTWBTYO-_O8cx7qLdM5GM8KlTsic6g3VRUhM8EA_4OO04dCfmNLGhqINRl3jGZ0Q4ziI8fng2bVWsIyteqiPzUn10rIQ3-OPpqVZG_DxeOmOejj4GzbUNyqUOajy-nr5rYY");
|
||||
|
||||
ShowDeleteWindow = new Interaction<DeleteWindowViewModel, bool>();
|
||||
DeleteCommand = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
var deleteViewModel = new DeleteWindowViewModel();
|
||||
var result = await ShowDeleteWindow.Handle(deleteViewModel);
|
||||
if (result) CoinCollection.Remove(SelectedCoin);
|
||||
});
|
||||
|
||||
// Subscribe to SidebarContent.OkCommand, which is an IObservable<(int, string, int)>
|
||||
// This is the same as the above, but with a different syntax.
|
||||
newViewModel.OkCommand
|
||||
.Subscribe(async requestStructure =>
|
||||
{
|
||||
var newCoin = await _pcgsClient.GetCoinFactsByGrade(requestStructure.Item1, requestStructure.Item2);
|
||||
newCoin.Quantity = requestStructure.Item3;
|
||||
CoinCollection.Add(newCoin);
|
||||
TotalValue += newCoin.Quantity * newCoin.PriceGuideValue;
|
||||
});
|
||||
}
|
||||
|
||||
public void FindItem()
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive;
|
||||
using System.Collections.Generic;
|
||||
using PcgsInvUi.Models;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.ViewModels;
|
||||
|
||||
public class NewViewModel : ViewModelBase
|
||||
{
|
||||
private string _pcgsNumber;
|
||||
private string _grade;
|
||||
private string _quantity;
|
||||
private string _pcgsNumber = "";
|
||||
private string _grade = "";
|
||||
private string _quantity = "";
|
||||
|
||||
public string PcgsNumber
|
||||
{
|
||||
@@ -40,15 +38,23 @@ public class NewViewModel : ViewModelBase
|
||||
!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),
|
||||
// Grade = Grade,
|
||||
// Quantity = Int32.Parse(Quantity)
|
||||
// },
|
||||
// okEnabled);
|
||||
|
||||
OkCommand = ReactiveCommand.Create(
|
||||
() => new Coin { PcgsNumber = Int32.Parse(PcgsNumber),
|
||||
Grade = Grade,
|
||||
Quantity = Int32.Parse(Quantity),
|
||||
PriceGuideValue = 100.0
|
||||
},
|
||||
() => (int.Parse(PcgsNumber), Grade, int.Parse(Quantity)),
|
||||
okEnabled);
|
||||
|
||||
CancelCommand = ReactiveCommand.Create(() => { });
|
||||
ClearCommand = ReactiveCommand.Create(() =>
|
||||
{
|
||||
PcgsNumber = "";
|
||||
Grade = "";
|
||||
Quantity = "";
|
||||
});
|
||||
|
||||
// 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.
|
||||
@@ -86,8 +92,8 @@ public class NewViewModel : ViewModelBase
|
||||
"MS-70"
|
||||
};
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Coin> OkCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
|
||||
|
||||
public ReactiveCommand<Unit, (int, string, int)> OkCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:PcgsInvUi.ViewModels"
|
||||
d:DesignWidth="325" d:DesignHeight="100"
|
||||
x:Class="PcgsInvUi.Views.DeleteWindow"
|
||||
x:Class="PcgsInvUi.Views.DeleteWindow" x:DataType="viewModels:DeleteWindowViewModel"
|
||||
Width="325" Height="100" WindowStartupLocation="CenterOwner"
|
||||
Title="DeleteWindow">
|
||||
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *">
|
||||
@@ -14,11 +14,11 @@
|
||||
Width="100"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="Yes" Click="AcceptClicked"/>
|
||||
Content="Yes" Command="{Binding OkCommand}"/>
|
||||
<Button Grid.Row="1" Grid.Column="1" Margin="5"
|
||||
Width="100"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="No" Click="CancelClicked"/>
|
||||
Content="No" Command="{Binding CancelCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,27 +1,16 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using PcgsInvUi.ViewModels;
|
||||
using Avalonia.ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
|
||||
|
||||
namespace PcgsInvUi.Views;
|
||||
|
||||
public partial class DeleteWindow : Window
|
||||
public partial class DeleteWindow : ReactiveWindow<DeleteWindowViewModel>
|
||||
{
|
||||
public bool Accepted { get; set; }
|
||||
|
||||
public DeleteWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Accepted = false;
|
||||
}
|
||||
|
||||
public void AcceptClicked(object source, RoutedEventArgs args)
|
||||
{
|
||||
// TODO Delete the SelectedCoin?
|
||||
Accepted = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
public void CancelClicked(object source, RoutedEventArgs args)
|
||||
{
|
||||
Close();
|
||||
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,16 @@
|
||||
xmlns:viewModels="clr-namespace:PcgsInvUi.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="PcgsInvUi.Views.MainWindow" x:DataType="viewModels:MainWindowViewModel"
|
||||
Title="MainWindow">
|
||||
<SplitView IsPaneOpen="{Binding PaneOpen}"
|
||||
DisplayMode="Overlay"
|
||||
PanePlacement="Right">
|
||||
Title="MainWindow"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<SplitView IsPaneOpen="True"
|
||||
DisplayMode="Inline"
|
||||
PanePlacement="Right" >
|
||||
<SplitView.Pane>
|
||||
<UserControl VerticalAlignment="Center" Content="{Binding SidebarContent}"/>
|
||||
<Grid RowDefinitions="Auto, *">
|
||||
<UserControl Grid.Row="0" Margin="10, 20, 10, 10" VerticalAlignment="Center" Content="{Binding SidebarContent}"/>
|
||||
<TextBox Grid.Row="1" Margin="5" Watermark="Notes..."/>
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
<Grid RowDefinitions="*, Auto" ShowGridLines="True">
|
||||
<DataGrid Grid.Row="0" HorizontalAlignment="Stretch"
|
||||
@@ -21,7 +25,7 @@
|
||||
CanUserResizeColumns="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Series" Width="*"
|
||||
Binding="{Binding Series}"
|
||||
Binding="{Binding SeriesName}"
|
||||
IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Year"
|
||||
Binding="{Binding Year}"
|
||||
@@ -45,25 +49,21 @@
|
||||
Binding="{Binding PriceGuideValue}"
|
||||
IsReadOnly="False"/>
|
||||
<DataGridTextColumn Header="PCGS #" Width="*"
|
||||
Binding="{Binding PcgsNumber}"
|
||||
Binding="{Binding PCGSNo}"
|
||||
IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Quantity" Width="*"
|
||||
Binding="{Binding Quantity}"
|
||||
IsReadOnly="False"/>
|
||||
<DataGridTextColumn Header="Total Price" Width="*"
|
||||
Binding="{Binding TotalPrice}"
|
||||
Binding="{Binding TotalPrice, StringFormat='${0:0.00}'}"
|
||||
IsReadOnly="True" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<DockPanel Grid.Row="1">
|
||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto, Auto, Auto" DockPanel.Dock="Left">
|
||||
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="New..."
|
||||
Command="{Binding AddItem}"/>
|
||||
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Edit..."
|
||||
Command="{Binding EditItem}"/>
|
||||
<Button Grid.Column="2" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
||||
Command="{Binding DeleteItem}"/>
|
||||
<Button Grid.Column="3" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Find..."
|
||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto" DockPanel.Dock="Left">
|
||||
<Button Grid.Column="0" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Delete"
|
||||
Command="{Binding DeleteCommand}"/>
|
||||
<Button Grid.Column="1" Margin="5" Width="100" HorizontalContentAlignment="Center" Content="Find..."
|
||||
Command="{Binding FindItem}"/>
|
||||
</Grid>
|
||||
<Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" ColumnDefinitions="Auto, Auto" DockPanel.Dock="Right">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.ReactiveUI;
|
||||
using PcgsInvUi.ViewModels;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace PcgsInvUi.Views;
|
||||
|
||||
@@ -10,7 +10,6 @@ public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
||||
{
|
||||
// TODO New window.
|
||||
// TODO Edit window.
|
||||
// TODO Delete window.
|
||||
// TODO Find window.
|
||||
// TODO Export window.
|
||||
// TODO Error handling.
|
||||
@@ -22,9 +21,18 @@ public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
||||
// 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)
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(d => d(ViewModel!.ShowDeleteWindow.RegisterHandler(ShowDeleteWindowAsync)));
|
||||
}
|
||||
|
||||
public async Task ShowDeleteWindowAsync(InteractionContext<DeleteWindowViewModel, Boolean> interaction)
|
||||
{
|
||||
var window = new DeleteWindow();
|
||||
window.DataContext = interaction.Input;
|
||||
|
||||
var result = await window.ShowDialog<bool>(this);
|
||||
interaction.SetOutput(result);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
<Button Grid.Column="0" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Width="90" HorizontalContentAlignment="Center" Content="OK" Command="{Binding OkCommand}"/>
|
||||
<Button Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Width="90" HorizontalContentAlignment="Center" Content="Cancel" Command="{Binding CancelCommand}" />
|
||||
Width="90" HorizontalContentAlignment="Center" Content="Clear" Command="{Binding ClearCommand}" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
Reference in new issue
Block a user