Added folder picker to locate Zune software

This commit is contained in:
Yoshi Askharoun
2021-08-04 20:35:45 -05:00
parent 8985e9d141
commit 953fd5dfeb
3 changed files with 46 additions and 25 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ namespace ZuneModCore
new MbidLocatorMod(), new MbidLocatorMod(),
}.AsReadOnly(); }.AsReadOnly();
public static string ZuneInstallDir { get; set; } = @"C:\Program Files\Zune\"; public static string ZuneInstallDir { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Zune");
public abstract string Id { get; } public abstract string Id { get; }
+22 -2
View File
@@ -3,6 +3,7 @@ using Flurl.Http;
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs; using MahApps.Metro.Controls.Dialogs;
using Microsoft.AppCenter.Analytics; using Microsoft.AppCenter.Analytics;
using Microsoft.WindowsAPICodePack.Dialogs;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OwlCore.AbstractUI.ViewModels; using OwlCore.AbstractUI.ViewModels;
using System; using System;
@@ -27,7 +28,7 @@ namespace ZuneModdingHelper
ColorScheme = MetroDialogColorScheme.Accented, ColorScheme = MetroDialogColorScheme.Accented,
AnimateShow = true, AnimateShow = true,
AnimateHide = true, AnimateHide = true,
AffirmativeButtonText = "Close" AffirmativeButtonText = "OK"
}; };
public MainWindow() public MainWindow()
@@ -245,7 +246,26 @@ namespace ZuneModdingHelper
private void LocateZuneButton_Click(object sender, RoutedEventArgs e) private void LocateZuneButton_Click(object sender, RoutedEventArgs e)
{ {
if (CommonFileDialog.IsPlatformSupported)
{
CommonOpenFileDialog dialog = new()
{
IsFolderPicker = true,
DefaultFileName = Mod.ZuneInstallDir
};
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
ZuneInstallDirBox.Text = dialog.FileName;
}
}
else
{
// TODO: Fallback to pre-Vista dialog
this.ShowMessageAsync("Error",
"Please use File Explorer to locate an copy the path.",
settings: defaultMetroDialogSettings);
}
} }
} }
} }
@@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" /> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="OwlCore" Version="0.0.6" /> <PackageReference Include="OwlCore" Version="0.0.6" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>