diff --git a/PS2_Manager/EditGame.axaml b/PS2_Manager/EditGame.axaml
deleted file mode 100644
index eeb49b7..0000000
--- a/PS2_Manager/EditGame.axaml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PS2_Manager/EditGame.axaml.cs b/PS2_Manager/EditGame.axaml.cs
deleted file mode 100644
index edd6bed..0000000
--- a/PS2_Manager/EditGame.axaml.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.ComponentModel;
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Markup.Xaml;
-using Avalonia.Threading;
-using PS2_Manager.Core;
-
-namespace PS2_Manager;
-
-public partial class EditGame : UserControl
-{
- public Game game { get; set; }
- public UpdateVar MD5Hash { get; set; } = new UpdateVar();
- public UpdateVar SHA1Hash { get; set; } = new UpdateVar();
- public EditGame(Game _game)
- {
- this.game = _game;
- InitializeComponent();
- DisplayNameBox.Text = this.game.Name;
- MD5Hash.ValueChanged += () =>
- {
- Dispatcher.UIThread.Invoke(() =>
- {
- Console.Info("MD5 Hash calculated");
- MD5TextBlock.Text = "MD5: " + MD5Hash.Value;
- });
- };
- SHA1Hash.ValueChanged += () =>
- {
- Dispatcher.UIThread.Invoke(() =>
- {
- Console.Info("SHA1 Hash calculated");
- SHATextBlock.Text = "SHA1: " + SHA1Hash.Value;
- });
- };
- }
-
- private void ChecksumButtonOnClick(object? sender, RoutedEventArgs e)
- {
- this.GetChecksum();
- }
-
- public void GetChecksum()
- {
- string filePath = this.game.GamePath;
-
- MD5TextBlock.Text = "MD5: Loading...";
- SHATextBlock.Text = "SHA1: Loading...";
- ChecksumArea.IsVisible = true;
-
- BackgroundWorker md5Worker = new BackgroundWorker();
- BackgroundWorker sha1Worker = new BackgroundWorker();
-
- md5Worker.DoWork += (s, e) =>
- {
- this.MD5Hash.Value = Checksum.GetMD5Hash(filePath);
- };
-
- sha1Worker.DoWork += (s, e) =>
- {
- this.SHA1Hash.Value = Checksum.GetSHA1Hash(filePath);
- };
-
- md5Worker.RunWorkerAsync();
- Console.Info("MD5 Hashing started...");
- sha1Worker.RunWorkerAsync();
- Console.Info("SHA1 Hashing started...");
- }
-
- private void Save_OnClick(object? sender, RoutedEventArgs e)
- {
- this.game.ChangeName(DisplayNameBox.Text);
- MainWindow.RefreshGamesListTrigger?.Invoke(null, EventArgs.Empty);
- }
-
- private void Edit_OnClick(object? sender, RoutedEventArgs e)
- {
- DisplayNameBox.Text = game.Name;
- }
-}
\ No newline at end of file
diff --git a/PS2_Manager/GameInfo.axaml b/PS2_Manager/GameInfo.axaml
index 3134e06..1509e6a 100644
--- a/PS2_Manager/GameInfo.axaml
+++ b/PS2_Manager/GameInfo.axaml
@@ -4,27 +4,5 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="PS2_Manager.GameInfo">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/PS2_Manager/GameInfo.axaml.cs b/PS2_Manager/GameInfo.axaml.cs
index 011c605..018fc21 100644
--- a/PS2_Manager/GameInfo.axaml.cs
+++ b/PS2_Manager/GameInfo.axaml.cs
@@ -14,112 +14,16 @@ namespace PS2_Manager;
public partial class GameInfo : UserControl
{
- public UpdateVar ArtworkType { get; set; } = new UpdateVar();
public Game game { get; set; }
public GameInfo(Game _game)
{
InitializeComponent();
this.game = _game;
- ArtworkType.ValueChanged += UpdateArtworks;
- ArtworkType.Value = Artwork.Type.Front;
-
- GameNameTextBlock.Text = game.Name;
- GameIdTextBlock.Text = game.GameID;
-
- FileInfo fileInfo = new FileInfo(game.GamePath);
- IsoSizeTextBlock.Text = Util.FormatFileSize(fileInfo.Length);
- DateTime lastModified = fileInfo.LastWriteTime;
- string formattedDate = lastModified.ToString("dd.MM.yyyy HH:mm");
- GameDateTextBlock.Text = formattedDate;
+
}
- private void UpdateArtworks()
- {
-
- Console.Info("Showing: " + ArtworkType.Value.ToString());
- Bitmap? tempBitmap = null;
- switch (ArtworkType.Value)
- {
- case Artwork.Type.Front:
- CoverContainer.Height = 292;
- tempBitmap = game.ArtworkFront;
- break;
- case Artwork.Type.Back:
- CoverContainer.Height = 292;
- tempBitmap = game.ArtworkBack;
- break;
- case Artwork.Type.Disc:
- CoverContainer.Height = CoverContainer.Width;
- tempBitmap = game.ArtworkDVD;
- break;
- }
- if (Util.IsBitmapEmpty(tempBitmap))
- {
- CoverContainer.Background = new SolidColorBrush(Color.Parse("#201c29"));
- CoverTextHint.IsVisible = true;
- }
- else
- {
- CoverContainer.Background = Brushes.Transparent;
- CoverTextHint.IsVisible = false;
- }
-
-
-
- CoverTextHint.Text = ArtworkType.Value.ToString();
-
- CoverImage.Source = tempBitmap;
- }
- private async void CoverImage_OnPointerPressed(object? sender, PointerPressedEventArgs e)
- {
- var topLevel = TopLevel.GetTopLevel(this);
-
- var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
- {
- Title = "Select a Cover for the PS2 Game",
- AllowMultiple = false,
- FileTypeFilter = new []
- {
- Globals.FileDialogTypes.PS2Cover
- }
- });
-
- if (files.Count >= 1)
- {
- switch (ArtworkType.Value)
- {
- case Artwork.Type.Front:
- this.game.ArtworkFront = new Bitmap(files[0].Path.LocalPath);
- break;
- case Artwork.Type.Back:
- this.game.ArtworkBack = new Bitmap(files[0].Path.LocalPath);
- break;
- case Artwork.Type.Disc:
- this.game.ArtworkDVD = new Bitmap(files[0].Path.LocalPath);
- break;
- }
- Console.Info("Updating " + ArtworkType.Value + " Artwork for " + this.game.GameID);
- this.game.SaveCover(ArtworkType.Value);
- UpdateArtworks();
- MainWindow.RefreshGamesListTrigger?.Invoke(null, EventArgs.Empty);
- }
- else
- {
- Console.Error("OpenFilePicker was called but Canceled or no Files selected");
- }
- }
-
- private void NextButton(object? sender, RoutedEventArgs e)
- {
- this.ArtworkType.Value = Artwork.NextType(this.ArtworkType.Value);
- }
-
- private void PrevButton(object? sender, RoutedEventArgs e)
- {
- this.ArtworkType.Value = Artwork.PrevType(this.ArtworkType.Value);
- }
}
\ No newline at end of file
diff --git a/PS2_Manager/MainWindow.axaml b/PS2_Manager/MainWindow.axaml
index 3c5a040..aaa446f 100644
--- a/PS2_Manager/MainWindow.axaml
+++ b/PS2_Manager/MainWindow.axaml
@@ -5,81 +5,143 @@
xmlns:local="clr-namespace:PS2_Manager.Core"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PS2_Manager.MainWindow"
- Title="PS2_Manager"
- Background="Transparent"
- SystemDecorations="None"
+ Title="PS2 Games Manager"
+ Background="#201c29"
Width="990"
Height="520"
+ MinHeight="490"
+ MinWidth="600"
WindowStartupLocation="CenterScreen"
- Loaded="Control_OnLoaded">
-
-
-
-
-
-
-
-
-
-
+ Loaded="Control_OnLoaded"
+ Foreground="White">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PS2_Manager/MainWindow.axaml.cs b/PS2_Manager/MainWindow.axaml.cs
index 9cbc835..a230a98 100644
--- a/PS2_Manager/MainWindow.axaml.cs
+++ b/PS2_Manager/MainWindow.axaml.cs
@@ -1,11 +1,16 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
using Avalonia.Platform.Storage;
+using Avalonia.Threading;
using PS2_Manager.Core;
namespace PS2_Manager;
@@ -13,22 +18,78 @@ namespace PS2_Manager;
public partial class MainWindow : Window
{
public static EventHandler? RefreshGamesListTrigger { get; set; }
+
+ public UpdateVar ArtworkType { get; set; } = new UpdateVar();
+ public UpdateVar MD5Hash { get; set; } = new UpdateVar();
+ public UpdateVar SHA1Hash { get; set; } = new UpdateVar();
public MainWindow()
{
InitializeComponent();
RefreshGamesListTrigger += FetchGamesFromLibrary;
+ ArtworkType.ValueChanged += UpdateArtworks;
+ MD5Hash.ValueChanged += () =>
+ {
+ Dispatcher.UIThread.Invoke(() =>
+ {
+ Console.Info("MD5 Hash calculated");
+ MD5TextBlock.Text = "MD5: " + MD5Hash.Value;
+ });
+ };
+ SHA1Hash.ValueChanged += () =>
+ {
+ Dispatcher.UIThread.Invoke(() =>
+ {
+ Console.Info("SHA1 Hash calculated");
+ SHATextBlock.Text = "SHA1: " + SHA1Hash.Value;
+ });
+ };
}
-
- private void ShowcaseGame(Game game)
+ private void GamesList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
- GameShowcaseGrid.IsVisible = true;
- InfoWindow.Child = new GameInfo(game);
- GameEdit.Child = new EditGame(game);
- Console.Info(game + " set as Showcase");
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ Console.Info("Selected " + selectedGame + " from ListView");
+ SetEditArea();
+ SetShowcaseArea();
+ SwitchView(false);
+ }
+ }
+
+ private void SwitchView(bool placeholder)
+ {
+ GameEdit.IsVisible = !placeholder;
+ WelcomePanel.IsVisible = placeholder;
+
+ GameInfo.IsVisible = !placeholder;
+ GameInfoPlaceholder.IsVisible = placeholder;
+ }
+
+ private void SetShowcaseArea()
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ ArtworkType.Value = Artwork.Type.Front;
+
+ GameNameTextBlock.Text = selectedGame.Name;
+ GameIdTextBlock.Text = selectedGame.GameID;
+ FileInfo fileInfo = new FileInfo(selectedGame.GamePath);
+ IsoSizeTextBlock.Text = Util.FormatFileSize(fileInfo.Length);
+ DateTime lastModified = fileInfo.LastWriteTime;
+ string formattedDate = lastModified.ToString("dd.MM.yyyy HH:mm");
+ GameDateTextBlock.Text = formattedDate;
+ }
+ }
+
+ private void SetEditArea()
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ ChecksumArea.IsVisible = false;
+ NameTextBox_Edit.Text = selectedGame.Name;
+ }
}
-
private void WindowDrag(object? sender, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
@@ -70,13 +131,12 @@ public partial class MainWindow : Window
private async void Control_OnLoaded(object? sender, RoutedEventArgs e)
{
- WindowTitle.Text = "PS2 Games Manager";
- GameEdit.Child = new Welcome();
FetchGamesFromLibrary();
}
public void FetchGamesFromLibrary(object? sender = null, EventArgs? e = null)
{
+ SwitchView(true);
Console.Info("Fetching games from library...");
List Games = new List();
Util.CheckDir(Path.Combine(settings.library_path.GetValue(), "DVD"));
@@ -92,14 +152,7 @@ public partial class MainWindow : Window
GamesList.ItemsSource = Games;
}
- private void GamesList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
- {
- if (GamesList.SelectedItem is Game selectedGame)
- {
- Console.Info("Selected " + selectedGame + " from ListView");
- this.ShowcaseGame(selectedGame);
- }
- }
+
private void DeleteButton(object? sender, RoutedEventArgs e)
{
if (GamesList.SelectedItem is Game selectedGame)
@@ -114,5 +167,177 @@ public partial class MainWindow : Window
{
FetchGamesFromLibrary();
}
+
+
+
+
+
+
+
+ //Game Edit Area/////////////////////////////////////////////////////////////
+
+ private void OnRepositoryLinkClicked(object sender, RoutedEventArgs e)
+ {
+ Console.Info("Repository Link Clicked");
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "https://git.weexnes.dev/WeeXnes/ps2_manager",
+ UseShellExecute = true
+ });
+ }
+
+ private void Save_OnClick(object? sender, RoutedEventArgs e)
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ selectedGame.ChangeName(NameTextBox_Edit.Text ?? "Error");
+ MainWindow.RefreshGamesListTrigger?.Invoke(null, EventArgs.Empty);
+ }
+ }
+
+ private void Undo_OnClick(object? sender, RoutedEventArgs e)
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ NameTextBox_Edit.Text = selectedGame.Name;
+ }
+ }
+
+
+ private void ChecksumButtonOnClick(object? sender, RoutedEventArgs e)
+ {
+ this.GetChecksum();
+ }
+
+ public void GetChecksum()
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ string filePath = selectedGame.GamePath;
+
+ this.MD5Hash.Value = "Loading...";
+ this.SHA1Hash.Value = "Loading...";
+ ChecksumArea.IsVisible = true;
+
+ BackgroundWorker md5Worker = new BackgroundWorker();
+ BackgroundWorker sha1Worker = new BackgroundWorker();
+
+ md5Worker.DoWork += (s, e) =>
+ {
+ this.MD5Hash.Value = Checksum.GetMD5Hash(filePath);
+ };
+
+ sha1Worker.DoWork += (s, e) =>
+ {
+ this.SHA1Hash.Value = Checksum.GetSHA1Hash(filePath);
+ };
+
+ md5Worker.RunWorkerAsync();
+ Console.Info("MD5 Hashing started...");
+ sha1Worker.RunWorkerAsync();
+ Console.Info("SHA1 Hashing started...");
+ }
+
+ }
+
+ //Game Showcase Area/////////////////////////////////////////////////////////////
+
+
+
+
+ private void UpdateArtworks()
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ Console.Info("Showing: " + ArtworkType.Value.ToString());
+ Bitmap? tempBitmap = null;
+ switch (ArtworkType.Value)
+ {
+ case Artwork.Type.Front:
+ CoverContainer.Height = 292;
+ tempBitmap = selectedGame.ArtworkFront;
+ break;
+ case Artwork.Type.Back:
+ CoverContainer.Height = 292;
+ tempBitmap = selectedGame.ArtworkBack;
+ break;
+ case Artwork.Type.Disc:
+ CoverContainer.Height = CoverContainer.Width;
+ tempBitmap = selectedGame.ArtworkDVD;
+ break;
+ }
+
+ if (Util.IsBitmapEmpty(tempBitmap))
+ {
+ CoverContainer.Background = new SolidColorBrush(Color.Parse("#201c29"));
+ CoverTextHint.IsVisible = true;
+ }
+ else
+ {
+ CoverContainer.Background = Brushes.Transparent;
+ CoverTextHint.IsVisible = false;
+ }
+
+
+
+ CoverTextHint.Text = ArtworkType.Value.ToString();
+
+ CoverImage.Source = tempBitmap;
+ }
+ }
+
+
+
+ private async void CoverImage_OnPointerPressed(object? sender, PointerPressedEventArgs e)
+ {
+ if (GamesList.SelectedItem is Game selectedGame)
+ {
+ var topLevel = TopLevel.GetTopLevel(this);
+
+ var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
+ {
+ Title = "Select a Cover for the PS2 Game",
+ AllowMultiple = false,
+ FileTypeFilter = new []
+ {
+ Globals.FileDialogTypes.PS2Cover
+ }
+ });
+
+ if (files.Count >= 1)
+ {
+ switch (ArtworkType.Value)
+ {
+ case Artwork.Type.Front:
+ selectedGame.ArtworkFront = new Bitmap(files[0].Path.LocalPath);
+ break;
+ case Artwork.Type.Back:
+ selectedGame.ArtworkBack = new Bitmap(files[0].Path.LocalPath);
+ break;
+ case Artwork.Type.Disc:
+ selectedGame.ArtworkDVD = new Bitmap(files[0].Path.LocalPath);
+ break;
+ }
+ Console.Info("Updating " + ArtworkType.Value + " Artwork for " + selectedGame.GameID);
+ selectedGame.SaveCover(ArtworkType.Value);
+ UpdateArtworks();
+ MainWindow.RefreshGamesListTrigger?.Invoke(null, EventArgs.Empty);
+ }
+ else
+ {
+ Console.Error("OpenFilePicker was called but Canceled or no Files selected");
+ }
+ }
+ }
+
+ private void NextButton(object? sender, RoutedEventArgs e)
+ {
+ this.ArtworkType.Value = Artwork.NextType(this.ArtworkType.Value);
+ }
+
+ private void PrevButton(object? sender, RoutedEventArgs e)
+ {
+ this.ArtworkType.Value = Artwork.PrevType(this.ArtworkType.Value);
+ }
}
\ No newline at end of file
diff --git a/PS2_Manager/MessageBox.axaml b/PS2_Manager/MessageBox.axaml
deleted file mode 100644
index cdb1879..0000000
--- a/PS2_Manager/MessageBox.axaml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PS2_Manager/MessageBox.axaml.cs b/PS2_Manager/MessageBox.axaml.cs
deleted file mode 100644
index 87c9677..0000000
--- a/PS2_Manager/MessageBox.axaml.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Input;
-using Avalonia.Markup.Xaml;
-
-namespace PS2_Manager;
-
-public partial class MessageBox : Window
-{
- public MessageBox(string messageContent)
- {
- InitializeComponent();
- ErrorDump.Content = "Exception: " + messageContent;
- }
- private void WindowDrag(object? sender, PointerPressedEventArgs e)
- {
- if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
- {
- BeginMoveDrag(e);
- }
- }
-}
\ No newline at end of file
diff --git a/PS2_Manager/Welcome.axaml b/PS2_Manager/Welcome.axaml
index 413b318..e1671f0 100644
--- a/PS2_Manager/Welcome.axaml
+++ b/PS2_Manager/Welcome.axaml
@@ -4,12 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="PS2_Manager.Welcome">
-
-
-
-
-
-
-
+
+
diff --git a/PS2_Manager/Welcome.axaml.cs b/PS2_Manager/Welcome.axaml.cs
index 9fd5cf1..12867c4 100644
--- a/PS2_Manager/Welcome.axaml.cs
+++ b/PS2_Manager/Welcome.axaml.cs
@@ -12,13 +12,5 @@ public partial class Welcome : UserControl
{
InitializeComponent();
}
- private void OnRepositoryLinkClicked(object sender, RoutedEventArgs e)
- {
- Console.Info("Repository Link Clicked");
- Process.Start(new ProcessStartInfo
- {
- FileName = "https://git.weexnes.dev/WeeXnes/ps2_manager",
- UseShellExecute = true
- });
- }
+
}
\ No newline at end of file