Setup Improved

This commit is contained in:
WeeXnes 2025-05-03 16:32:22 +02:00
parent 951f93b1b3
commit d32c17dc1c
2 changed files with 27 additions and 36 deletions

View file

@ -5,29 +5,19 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PS2_Manager.Setup" x:Class="PS2_Manager.Setup"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
SystemDecorations="None" Title="Setup PS2 Manager"
Title="Setup"
Height="349" Height="349"
Width="598" Width="598"
CanResize="False"
Background="#201c29" Background="#201c29"
Closing="Window_OnClosing"> Closing="Window_OnClosing">
<Grid RowDefinitions="20, *"> <Grid Margin="20">
<Grid Grid.Row="0"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Background="#35313d" <TextBlock Name="InfoText1" Text="Welcome to PS2 Manager" HorizontalAlignment="Center"/>
PointerPressed="WindowDrag"> <Separator/>
<Grid ColumnDefinitions="*, 20"> <TextBlock Name="InfoText2" Text="First of all please select the path to your PS2 Game Library" HorizontalAlignment="Center"/>
<TextBlock Name="WindowTitle" FontSize="12" Text="Setup PS2 Manager" Padding="8,0,0,0" VerticalAlignment="Center"/> <Button Name="OpenLibraryButton" Content="Select Folder" HorizontalAlignment="Center" Margin="0,10"
</Grid> Click="OpenLibraryButton_OnClick"/>
</Border> </StackPanel>
</Grid>
<Grid Grid.Row="1" Margin="20">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Name="InfoText1" Text="Welcome to PS2 Manager" HorizontalAlignment="Center"/>
<Separator/>
<TextBlock Name="InfoText2" Text="First of all please select the path to your PS2 Game Library" HorizontalAlignment="Center"/>
<Button Name="OpenLibraryButton" Content="Select Folder" HorizontalAlignment="Center" Margin="0,10"
Click="OpenLibraryButton_OnClick"/>
</StackPanel>
</Grid>
</Grid> </Grid>
</Window> </Window>

View file

@ -43,29 +43,30 @@ public partial class Setup : Window
{ {
Console.Info("Open Library Button Clicked"); Console.Info("Open Library Button Clicked");
settings.library_path.SetValue(""); settings.library_path.SetValue("");
while (String.IsNullOrEmpty(settings.library_path.GetValue<string>())) var topLevel = TopLevel.GetTopLevel(this);
var path = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{ {
var topLevel = TopLevel.GetTopLevel(this); Title = "Open Game Library",
var path = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions AllowMultiple = false
});
try
{
if (!String.IsNullOrEmpty(path[0].Path.LocalPath))
{ {
Title = "Open Game Library", settings.library_path.SetValue(path[0].Path.LocalPath);
AllowMultiple = false FinishSetup();
});
try
{
if (!String.IsNullOrEmpty(path[0].Path.LocalPath))
settings.library_path.SetValue(path[0].Path.LocalPath);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
} }
} }
FinishSetup(); catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
} }
private void Window_OnClosing(object? sender, WindowClosingEventArgs e) private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
{ {
if(!this.SetupFinished) e.Cancel = true; if(!this.SetupFinished) Environment.Exit(0);
} }
} }