diff --git a/.gitignore b/.gitignore
index 548f21c..0a199e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,12 @@
/PcgsInvUi/[Oo]bj/
[Oo]bj/
[Bb]in/
+ALL_BUILD.vcxproj
+ALL_BUILD.vcxproj.filters
+ZERO_CHECK.vcxproj
+ZERO_CHECK.vcxproj.filters
+CMakeCache.txt
+CMakeFiles/
+.idea/
+cmake_install.cmake
+coin_collection
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..74dab4e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.25)
+
+project("PcgsInvUi" CSharp)
+
+add_subdirectory(PcgsInvUi)
diff --git a/PcgsInvUi.csproj b/PcgsInvUi.csproj
new file mode 100644
index 0000000..26caed2
--- /dev/null
+++ b/PcgsInvUi.csproj
@@ -0,0 +1,224 @@
+
+
+
+ x64
+
+
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}
+ Win32Proj
+ 10.0.22621.0
+ x64
+ PcgsInvUi
+ v4.7.2
+ NoUpgrade
+ true
+ Exe
+ Properties
+
+
+
+ true
+ true
+ C:\Users\lvas4\RiderProjects\pcgs-inv\Debug\
+ v143
+ PcgsInvUi
+ Program
+ C:\Users\lvas4\RiderProjects\pcgs-inv\Debug\PcgsInvUi.exe
+ full
+ DEBUG
+ prompt
+ latest
+ false
+ 3
+
+
+ C:\Users\lvas4\RiderProjects\pcgs-inv\Release\
+ v143
+ PcgsInvUi
+ Program
+ C:\Users\lvas4\RiderProjects\pcgs-inv\Release\PcgsInvUi.exe
+ none
+
+ queue
+ latest
+ true
+ 1
+
+
+ C:\Users\lvas4\RiderProjects\pcgs-inv\MinSizeRel\
+ v143
+ PcgsInvUi
+ Program
+ C:\Users\lvas4\RiderProjects\pcgs-inv\MinSizeRel\PcgsInvUi.exe
+ none
+
+ latest
+ true
+
+
+ true
+ true
+ C:\Users\lvas4\RiderProjects\pcgs-inv\RelWithDebInfo\
+ v143
+ PcgsInvUi
+ Program
+ C:\Users\lvas4\RiderProjects\pcgs-inv\RelWithDebInfo\PcgsInvUi.exe
+ full
+
+ latest
+ false
+
+
+
+
+
+
+
+
+
+ CMakeLists.txt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ App.axaml.cs
+
+
+ Program.cs
+
+
+ ViewLocator.cs
+
+
+ App.axaml
+
+
+ Models\Coin.cs
+
+
+ Services\CoinCollection.cs
+
+
+ Services\CoinDatabase.cs
+
+
+ Services\PcgsClient.cs
+
+
+ ViewModels\CoinListViewModel.cs
+
+
+ ViewModels\DeleteWindowViewModel.cs
+
+
+ ViewModels\EditViewModel.cs
+
+
+ ViewModels\ErrorWindowViewModel.cs
+
+
+ ViewModels\FindWindowViewModel.cs
+
+
+ ViewModels\MainWindowViewModel.cs
+
+
+ ViewModels\NewViewModel.cs
+
+
+ ViewModels\ViewModelBase.cs
+
+
+ Views\DeleteWindow.axaml
+
+
+ Views\DeleteWindow.axaml.cs
+
+
+ Views\ErrorWindow.axaml
+
+
+ Views\ErrorWindow.axaml.cs
+
+
+ Views\FindWindow.axaml
+
+
+ Views\FindWindow.axaml.cs
+
+
+ Views\MainWindow.axaml
+
+
+ Views\MainWindow.axaml.cs
+
+
+ Views\NewView.axaml
+
+
+ Views\NewView.axaml.cs
+
+
+
+
+ true
+ true
+
+
+
+
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}
+ ZERO_CHECK
+ false
+ Never
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CustomCommand_Debug_2b1af5d328edb17d91180d581ead755d;
+ CustomCommand_MinSizeRel_2b1af5d328edb17d91180d581ead755d;
+ CustomCommand_RelWithDebInfo_2b1af5d328edb17d91180d581ead755d;
+ CustomCommand_Release_2b1af5d328edb17d91180d581ead755d;
+ $(BuildDependsOn)
+
+
+
\ No newline at end of file
diff --git a/PcgsInvUi.sln b/PcgsInvUi.sln
new file mode 100644
index 0000000..1428c41
--- /dev/null
+++ b/PcgsInvUi.sln
@@ -0,0 +1,53 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{1318C6B3-3038-3793-8B5B-FFAF1B645D42}"
+ ProjectSection(ProjectDependencies) = postProject
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E} = {54609B1E-BC06-306E-9607-8EAEF1F4571E}
+ {3FD6A666-E15C-386C-9AAE-B352CA747977} = {3FD6A666-E15C-386C-9AAE-B352CA747977}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PcgsInvUi", "PcgsInvUi.csproj", "{54609B1E-BC06-306E-9607-8EAEF1F4571E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {3FD6A666-E15C-386C-9AAE-B352CA747977} = {3FD6A666-E15C-386C-9AAE-B352CA747977}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{3FD6A666-E15C-386C-9AAE-B352CA747977}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ MinSizeRel|x64 = MinSizeRel|x64
+ RelWithDebInfo|x64 = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1318C6B3-3038-3793-8B5B-FFAF1B645D42}.Debug|x64.ActiveCfg = Debug|x64
+ {1318C6B3-3038-3793-8B5B-FFAF1B645D42}.Release|x64.ActiveCfg = Release|x64
+ {1318C6B3-3038-3793-8B5B-FFAF1B645D42}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1318C6B3-3038-3793-8B5B-FFAF1B645D42}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.Debug|x64.ActiveCfg = Debug|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.Debug|x64.Build.0 = Debug|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.Release|x64.ActiveCfg = Release|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.Release|x64.Build.0 = Release|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {54609B1E-BC06-306E-9607-8EAEF1F4571E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.Debug|x64.ActiveCfg = Debug|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.Debug|x64.Build.0 = Debug|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.Release|x64.ActiveCfg = Release|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.Release|x64.Build.0 = Release|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {3FD6A666-E15C-386C-9AAE-B352CA747977}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {59E64599-55C1-370C-BB8B-8DCA690BC7F5}
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/PcgsInvUi/CMakeLists.txt b/PcgsInvUi/CMakeLists.txt
new file mode 100644
index 0000000..7c894f7
--- /dev/null
+++ b/PcgsInvUi/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 3.25)
+
+project(PcgsInvUi LANGUAGES CSharp)
+
+include(CSharpUtilities)
+
+add_executable(PcgsInvUi
+ App.axaml.cs
+ Program.cs
+ ViewLocator.cs
+ App.axaml
+ app.manifest
+ Models/Coin.cs
+ Services/CoinCollection.cs
+ Services/CoinDatabase.cs
+ Services/PcgsClient.cs
+ ViewModels/CoinListViewModel.cs
+ ViewModels/DeleteWindowViewModel.cs
+ ViewModels/EditViewModel.cs
+ ViewModels/ErrorWindowViewModel.cs
+ ViewModels/FindWindowViewModel.cs
+ ViewModels/MainWindowViewModel.cs
+ ViewModels/NewViewModel.cs
+ ViewModels/ViewModelBase.cs
+ Views/DeleteWindow.axaml
+ Views/DeleteWindow.axaml.cs
+ Views/ErrorWindow.axaml
+ Views/ErrorWindow.axaml.cs
+ Views/FindWindow.axaml
+ Views/FindWindow.axaml.cs
+ Views/MainWindow.axaml
+ Views/MainWindow.axaml.cs
+ Views/NewView.axaml
+ Views/NewView.axaml.cs
+)
+
+# Set the .NET Framework version for the executable.
+set_property(TARGET PcgsInvUi PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2")
+# Set the executable to be 64-bit.
+set_property(TARGET PcgsInvUi PROPERTY WIN64_EXECUTABLE TRUE)
+# Set the C# language version (defaults to 3.0)
+set(CMAKE_CSharp_FLAGS "/langversion:latest")
+
+# Add the .NET reference libraries as dependencies.
+set_property(TARGET PcgsInvUi PROPERTY VS_DOTNET_REFERENCES
+ "Microsoft.CSharp"
+)
diff --git a/PcgsInvUi/Services/CoinDatabase.cs b/PcgsInvUi/Services/CoinDatabase.cs
index b954ef3..221d845 100644
--- a/PcgsInvUi/Services/CoinDatabase.cs
+++ b/PcgsInvUi/Services/CoinDatabase.cs
@@ -37,14 +37,16 @@ public class CoinDatabase {
private SQLiteConnection CreateConnection() {
// Check if database exists.
- if (!System.IO.File.Exists("%USERPROFILE%\\coin_collection")) {
+ if (!System.IO.File.Exists("coin_collection")) {
// Create the database.
- SQLiteConnection.CreateFile("%USERPROFILE%\\coin_collection");
+ Console.Write("Creating database... ");
+ SQLiteConnection.CreateFile("coin_collection");
+ Console.WriteLine("Done.");
}
// Create a connection to the database.
SQLiteConnection connection =
- new SQLiteConnection("DataSource=%USERPROFILE%\\coin_collection");
+ new SQLiteConnection("DataSource=coin_collection");
// Open the connection.
try {
diff --git a/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs b/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
index 54623cf..db4b132 100644
--- a/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
+++ b/PcgsInvUi/ViewModels/DeleteWindowViewModel.cs
@@ -1,15 +1,14 @@
using System.Reactive;
-using PcgsInvUi.Views;
using ReactiveUI;
namespace PcgsInvUi.ViewModels;
public class DeleteWindowViewModel : ViewModelBase {
public ReactiveCommand OkCommand { get; }
- public ReactiveCommand CancelCommand { get; }
+ public ReactiveCommand CancelCommand { get; }
public DeleteWindowViewModel() {
OkCommand = ReactiveCommand.Create(() => (object)true);
- CancelCommand = ReactiveCommand.Create(window => window.Close());
+ CancelCommand = ReactiveCommand.Create(() => (object)false);
}
-}
\ No newline at end of file
+}
diff --git a/PcgsInvUi/ViewModels/EditViewModel.cs b/PcgsInvUi/ViewModels/EditViewModel.cs
index 3572169..cf64977 100644
--- a/PcgsInvUi/ViewModels/EditViewModel.cs
+++ b/PcgsInvUi/ViewModels/EditViewModel.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Reactive;
+using System.Reactive;
using PcgsInvUi.Models;
using ReactiveUI;
@@ -25,4 +24,4 @@ public class EditViewModel : ViewModelBase {
// Setup OkCommand - all Coin-related properties must be non-whitespace.
OkCommand = ReactiveCommand.Create(() => { });
}
-}
\ No newline at end of file
+}
diff --git a/PcgsInvUi/ViewModels/ErrorWindowViewModel.cs b/PcgsInvUi/ViewModels/ErrorWindowViewModel.cs
index 6d93ac2..ab7d0d8 100644
--- a/PcgsInvUi/ViewModels/ErrorWindowViewModel.cs
+++ b/PcgsInvUi/ViewModels/ErrorWindowViewModel.cs
@@ -18,9 +18,9 @@ public class ErrorWindowViewModel : ViewModelBase {
public ErrorWindowViewModel(string message)
{
- DisplayedMessage = message;
+ _message = message;
CloseCommand = ReactiveCommand.Create(window => window.Close());
}
-}
\ No newline at end of file
+}
diff --git a/PcgsInvUi/ViewModels/MainWindowViewModel.cs b/PcgsInvUi/ViewModels/MainWindowViewModel.cs
index 05d3433..b6f70f4 100644
--- a/PcgsInvUi/ViewModels/MainWindowViewModel.cs
+++ b/PcgsInvUi/ViewModels/MainWindowViewModel.cs
@@ -10,6 +10,7 @@ using ReactiveUI;
namespace PcgsInvUi.ViewModels;
+// TODO Create proper sums for total value.
// TODO Error handling for API calls.
// TODO Manual handling of API key.
// TODO Use CoinFacts link.
@@ -67,7 +68,7 @@ public class MainWindowViewModel : ViewModelBase {
var result = await ShowDeleteWindow.Handle(deleteViewModel);
if (result && SelectedCoin is not null) {
ConnectedCoinDatabase.DeleteCoin(SelectedCoin);
- ConnectedCoinDatabase.Collection.Remove(SelectedCoin); // possible null deref - ignored due to button being disabled.
+ ConnectedCoinDatabase.Collection.Remove(SelectedCoin);
}
}, deleteEnabled);
@@ -83,10 +84,10 @@ public class MainWindowViewModel : ViewModelBase {
catch (IOException e) {
// Something is wrong with the file after it's been created.
Console.WriteLine(e.Message);
- ShowErrorWindow.Handle(new ErrorWindowViewModel(e.Message));
+ await ShowErrorWindow.Handle(new ErrorWindowViewModel(e.Message));
} catch (Exception e) {
Console.WriteLine(e.Message);
- ShowErrorWindow.Handle(new ErrorWindowViewModel(e.Message));
+ await ShowErrorWindow.Handle(new ErrorWindowViewModel(e.Message));
}
});
@@ -120,4 +121,4 @@ public class MainWindowViewModel : ViewModelBase {
this.WhenAnyValue(x => x.SelectedCoin.TotalPrice)
.Subscribe(_ => TotalValue = ConnectedCoinDatabase.Collection.Sum(x => x.TotalPrice));
}
-}
\ No newline at end of file
+}
diff --git a/PcgsInvUi/Views/DeleteWindow.axaml b/PcgsInvUi/Views/DeleteWindow.axaml
index a967024..b9dabdf 100644
--- a/PcgsInvUi/Views/DeleteWindow.axaml
+++ b/PcgsInvUi/Views/DeleteWindow.axaml
@@ -18,7 +18,7 @@
+ HorizontalContentAlignment="Center" IsEnabled="True"
+ Content="No" Command="{Binding CancelCommand}" />
-
\ No newline at end of file
+
diff --git a/PcgsInvUi/Views/DeleteWindow.axaml.cs b/PcgsInvUi/Views/DeleteWindow.axaml.cs
index 5b5d4db..000f574 100644
--- a/PcgsInvUi/Views/DeleteWindow.axaml.cs
+++ b/PcgsInvUi/Views/DeleteWindow.axaml.cs
@@ -9,5 +9,6 @@ public partial class DeleteWindow : ReactiveWindow {
public DeleteWindow() {
InitializeComponent();
this.WhenActivated(d => d(ViewModel!.OkCommand.Subscribe(Close)));
+ this.WhenActivated(d => d(ViewModel!.CancelCommand.Subscribe(Close)));
}
-}
\ No newline at end of file
+}
diff --git a/PcgsInvUi/Views/MainWindow.axaml b/PcgsInvUi/Views/MainWindow.axaml
index 837c944..d01a9ab 100644
--- a/PcgsInvUi/Views/MainWindow.axaml
+++ b/PcgsInvUi/Views/MainWindow.axaml
@@ -5,8 +5,7 @@
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="Main Window"
- WindowStartupLocation="CenterOwner">
+ Title="Main Window" WindowStartupLocation="CenterScreen" WindowState="Maximized" >