mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Add folder picker button
This commit is contained in:
@@ -7,8 +7,11 @@
|
|||||||
xmlns:zmhs="clr-namespace:ZuneModdingHelper.Services"
|
xmlns:zmhs="clr-namespace:ZuneModdingHelper.Services"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
Unloaded="SettingsPage_Unloaded"
|
Unloaded="SettingsPage_Unloaded">
|
||||||
DataContext="{x:Static zmhs:Settings.Default}">
|
<d:UserControl.DataContext>
|
||||||
|
<local:SettingsViewModel/>
|
||||||
|
</d:UserControl.DataContext>
|
||||||
|
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
||||||
@@ -16,8 +19,10 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Text="Choose the directory where the Zune software is installed." Margin="0,8"
|
<TextBlock Text="Choose the directory where the Zune software is installed." Margin="0,8"
|
||||||
Style="{StaticResource ZuneBodyTextBlockStyle}" />
|
Style="{StaticResource ZuneBodyTextBlockStyle}" />
|
||||||
<TextBox VerticalAlignment="Top"
|
<TextBox Text="{Binding Settings.ZuneInstallDir}"/>
|
||||||
Text="{Binding ZuneInstallDir}"/>
|
<Button Content="LOCATE" HorizontalAlignment="Left" Margin="0,8,0,0"
|
||||||
|
Visibility="{Binding FolderPickerVisibility, Mode=OneTime}"
|
||||||
|
Click="LocateZuneButton_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Windows;
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using ZuneModdingHelper.Services;
|
using ZuneModdingHelper.Services;
|
||||||
|
|
||||||
@@ -9,15 +10,45 @@ namespace ZuneModdingHelper.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SettingsPage : UserControl
|
public partial class SettingsPage : UserControl
|
||||||
{
|
{
|
||||||
public SettingsPage()
|
public SettingsPage(Settings settings)
|
||||||
{
|
{
|
||||||
|
ViewModel = new()
|
||||||
|
{
|
||||||
|
Settings = settings,
|
||||||
|
FolderPickerVisibility = CommonFileDialog.IsPlatformSupported
|
||||||
|
? Visibility.Visible : Visibility.Collapsed,
|
||||||
|
};
|
||||||
|
DataContext = ViewModel;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = Settings.Default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SettingsViewModel ViewModel { get; }
|
||||||
|
|
||||||
private async void SettingsPage_Unloaded(object sender, RoutedEventArgs e)
|
private async void SettingsPage_Unloaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await Settings.Default.SaveAsync();
|
await ViewModel.Settings.SaveAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LocateZuneButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
CommonOpenFileDialog dialog = new()
|
||||||
|
{
|
||||||
|
IsFolderPicker = true,
|
||||||
|
DefaultDirectory = ViewModel.Settings.ZuneInstallDir
|
||||||
|
};
|
||||||
|
CommonFileDialogResult result = dialog.ShowDialog();
|
||||||
|
if (result == CommonFileDialogResult.Ok)
|
||||||
|
{
|
||||||
|
ViewModel.Settings.ZuneInstallDir = dialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SettingsViewModel
|
||||||
|
{
|
||||||
|
public Settings Settings { get; init; }
|
||||||
|
|
||||||
|
public Visibility FolderPickerVisibility { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user