Added Renaming

This commit is contained in:
WeeXnes 2025-04-22 02:08:08 +02:00
parent 62595f612e
commit eb4e4201c7
4 changed files with 27 additions and 4 deletions

View file

@ -44,6 +44,15 @@ public class Game
} }
} }
public void ChangeName(string newName)
{
this.Name = newName;
string targetDirectory = settings.library_path.GetValue<string>();
string newFileName = $"{this.GameID}.{this.Name}.iso";
string destPath = Path.Combine(Path.Combine(targetDirectory, "DVD"), newFileName);
File.Move(this.GamePath, destPath);
}
public string GetGameTitle() public string GetGameTitle()
{ {
string url = $"http://localhost:3000/search/{this.GameID}"; string url = $"http://localhost:3000/search/{this.GameID}";

View file

@ -21,8 +21,10 @@
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
<Grid Grid.Row="1" ColumnDefinitions="*,*"> <Grid Grid.Row="1" ColumnDefinitions="*,*">
<Button Content="Undo" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"/> <Button Content="Undo" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"
<Button Content="Save" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/> Click="Edit_OnClick"/>
<Button Content="Save" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"
Click="Save_OnClick"/>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -39,8 +39,7 @@ public partial class EditGame : UserControl
private void DisplayNameBox_OnTextChanged(object? sender, TextChangedEventArgs e) private void DisplayNameBox_OnTextChanged(object? sender, TextChangedEventArgs e)
{ {
this.game.Name = DisplayNameBox.Text;
MainWindow.RefreshGamesListTrigger.Invoke(null, EventArgs.Empty);
} }
private void ChecksumButtonOnClick(object? sender, RoutedEventArgs e) private void ChecksumButtonOnClick(object? sender, RoutedEventArgs e)
@ -74,4 +73,15 @@ public partial class EditGame : UserControl
Console.WriteLine("Hashing started..."); Console.WriteLine("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;
}
} }

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
@ -81,6 +82,7 @@ public partial class MainWindow : Window
new Game(file, true); new Game(file, true);
Games.Add(newGame); Games.Add(newGame);
} }
Games = Games.OrderBy(game => game.Name).ToList();
GamesList.ItemsSource = Games; GamesList.ItemsSource = Games;
} }