working prototype
This commit is contained in:
parent
e6e356a9da
commit
62595f612e
4 changed files with 72 additions and 32 deletions
|
@ -71,30 +71,7 @@ public class Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetChecksum()
|
|
||||||
{
|
|
||||||
string filePath = this.GamePath;
|
|
||||||
|
|
||||||
BackgroundWorker md5Worker = new BackgroundWorker();
|
|
||||||
BackgroundWorker sha1Worker = new BackgroundWorker();
|
|
||||||
|
|
||||||
md5Worker.DoWork += (s, e) =>
|
|
||||||
{
|
|
||||||
string md5 = Checksum.GetMD5Hash(filePath);
|
|
||||||
Console.WriteLine("MD5: " + md5);
|
|
||||||
};
|
|
||||||
|
|
||||||
sha1Worker.DoWork += (s, e) =>
|
|
||||||
{
|
|
||||||
string sha1 = Checksum.GetSHA1Hash(filePath);
|
|
||||||
Console.WriteLine("SHA1: " + sha1);
|
|
||||||
};
|
|
||||||
|
|
||||||
md5Worker.RunWorkerAsync();
|
|
||||||
sha1Worker.RunWorkerAsync();
|
|
||||||
|
|
||||||
Console.WriteLine("Hashing started...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ParseFormattedFilename(string filename)
|
private string ParseFormattedFilename(string filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,9 +5,24 @@
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="PS2_Manager.EditGame">
|
x:Class="PS2_Manager.EditGame">
|
||||||
|
|
||||||
|
<Grid RowDefinitions="*, 40">
|
||||||
|
<ScrollViewer Grid.Row="0">
|
||||||
<StackPanel Orientation="Vertical" Margin="10">
|
<StackPanel Orientation="Vertical" Margin="10">
|
||||||
<TextBlock Text="Display Name:" HorizontalAlignment="Center" Padding="0,10"/>
|
<TextBlock Text="Display Name:" HorizontalAlignment="Center" Padding="0,10"/>
|
||||||
<TextBox Name="DisplayNameBox" TextChanged="DisplayNameBox_OnTextChanged"/>
|
<TextBox Name="DisplayNameBox" TextChanged="DisplayNameBox_OnTextChanged"/>
|
||||||
<Button Click="Button_OnClick"></Button>
|
<Separator/>
|
||||||
|
<Button Content="Calculate Checksums" Click="ChecksumButtonOnClick" HorizontalAlignment="Stretch"></Button>
|
||||||
|
<Border Background="#35313d" CornerRadius="5" Padding="10" Margin="0,5" IsVisible="False" Name="ChecksumArea">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock FontSize="10" Name="MD5TextBlock"/>
|
||||||
|
<TextBlock FontSize="10" Name="SHATextBlock"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
<Grid Grid.Row="1" ColumnDefinitions="*,*">
|
||||||
|
<Button Content="Undo" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
<Button Content="Save" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Threading;
|
||||||
using PS2_Manager.Core;
|
using PS2_Manager.Core;
|
||||||
|
|
||||||
namespace PS2_Manager;
|
namespace PS2_Manager;
|
||||||
|
@ -10,10 +12,29 @@ namespace PS2_Manager;
|
||||||
public partial class EditGame : UserControl
|
public partial class EditGame : UserControl
|
||||||
{
|
{
|
||||||
public Game game { get; set; }
|
public Game game { get; set; }
|
||||||
|
public UpdateVar<string> MD5Hash { get; set; } = new UpdateVar<string>();
|
||||||
|
public UpdateVar<string> SHA1Hash { get; set; } = new UpdateVar<string>();
|
||||||
public EditGame(Game _game)
|
public EditGame(Game _game)
|
||||||
{
|
{
|
||||||
this.game = _game;
|
this.game = _game;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DisplayNameBox.Text = this.game.Name;
|
||||||
|
MD5Hash.ValueChanged += () =>
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("MD5Hash.ValueChanged");
|
||||||
|
MD5TextBlock.Text = "MD5: " + MD5Hash.Value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
SHA1Hash.ValueChanged += () =>
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("SHA1Hash.ValueChanged");
|
||||||
|
SHATextBlock.Text = "SHA1: " + SHA1Hash.Value;
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayNameBox_OnTextChanged(object? sender, TextChangedEventArgs e)
|
private void DisplayNameBox_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
|
@ -22,8 +43,35 @@ public partial class EditGame : UserControl
|
||||||
MainWindow.RefreshGamesListTrigger.Invoke(null, EventArgs.Empty);
|
MainWindow.RefreshGamesListTrigger.Invoke(null, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_OnClick(object? sender, RoutedEventArgs e)
|
private void ChecksumButtonOnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.game.GetChecksum();
|
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();
|
||||||
|
sha1Worker.RunWorkerAsync();
|
||||||
|
|
||||||
|
Console.WriteLine("Hashing started...");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -77,7 +77,7 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Column="2" RowDefinitions="20, *" IsVisible="False" Name="GameShowcaseGrid">
|
<Grid Grid.Column="2" RowDefinitions="20, *" IsVisible="False" Name="GameShowcaseGrid">
|
||||||
<Border Grid.Row="1" Background="#35313d" CornerRadius="10" Name="InfoWindow">
|
<Border Grid.Row="1" Background="#35313d" CornerRadius="10" Name="InfoWindow" >
|
||||||
|
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Add table
Reference in a new issue