mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Fix path assignment from UI
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
- Replace Options with SegmentedOptions in most places
|
||||
- Fix ListConfig feature with new layout
|
||||
- Move InternalProgram up a level in options, fix XAML
|
||||
- Fix path assignment from UI
|
||||
|
||||
### 3.6.0 (2025-11-28)
|
||||
|
||||
|
||||
@@ -284,10 +284,10 @@ namespace MPF.Frontend
|
||||
// Set the proper parameters
|
||||
_executionContext = _internalProgram switch
|
||||
{
|
||||
InternalProgram.Aaru => new ExecutionContexts.Aaru.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.ConvertToOptions().Settings),
|
||||
InternalProgram.DiscImageCreator => new ExecutionContexts.DiscImageCreator.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.ConvertToOptions().Settings),
|
||||
// InternalProgram.Dreamdump => new ExecutionContexts.Dreamdump.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.ConvertToOptions().Settings),
|
||||
InternalProgram.Redumper => new ExecutionContexts.Redumper.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.ConvertToOptions().Settings),
|
||||
InternalProgram.Aaru => new ExecutionContexts.Aaru.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.Settings),
|
||||
InternalProgram.DiscImageCreator => new ExecutionContexts.DiscImageCreator.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.Settings),
|
||||
// InternalProgram.Dreamdump => new ExecutionContexts.Dreamdump.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.Settings),
|
||||
InternalProgram.Redumper => new ExecutionContexts.Redumper.ExecutionContext(_system, mediaType, _drive.Name, OutputPath, driveSpeed, _options.Settings),
|
||||
|
||||
// If no dumping program found, set to null
|
||||
InternalProgram.NONE => null,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using AaruConstants = MPF.ExecutionContexts.Aaru.SettingConstants;
|
||||
@@ -64,6 +65,19 @@ namespace MPF.Frontend
|
||||
|
||||
#endregion
|
||||
|
||||
#region Passthrough Properties
|
||||
|
||||
/// <summary>
|
||||
/// All settings in the form of a dictionary
|
||||
/// </summary>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
public Dictionary<string, string?> Settings
|
||||
{
|
||||
get { return ConvertToOptions().Settings; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -266,7 +280,7 @@ namespace MPF.Frontend
|
||||
/// Convert to an Options object
|
||||
/// </summary>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
public Options ConvertToOptions()
|
||||
private Options ConvertToOptions()
|
||||
{
|
||||
return new Options
|
||||
{
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <summary>
|
||||
/// Save the current set of options to the application configuration
|
||||
/// </summary>
|
||||
public static void SaveToConfig(Options options)
|
||||
public static void SaveToConfig(SegmentedOptions options)
|
||||
{
|
||||
// If no options path can be found
|
||||
if (string.IsNullOrEmpty(ConfigurationPath))
|
||||
@@ -261,7 +261,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <summary>
|
||||
/// Save the current set of options to the application configuration
|
||||
/// </summary>
|
||||
public static void SaveToConfig(SegmentedOptions options)
|
||||
public static void SaveToConfigNative(SegmentedOptions options)
|
||||
{
|
||||
// If no options path can be found
|
||||
if (string.IsNullOrEmpty(ConfigurationPath))
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace MPF.Frontend.ViewModels
|
||||
set
|
||||
{
|
||||
_options = value;
|
||||
OptionsLoader.SaveToConfig(_options.ConvertToOptions());
|
||||
OptionsLoader.SaveToConfig(_options);
|
||||
}
|
||||
}
|
||||
private SegmentedOptions _options;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using MPF.Frontend.ComboBoxItems;
|
||||
using LogCompression = MPF.Processors.LogCompression;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -64,10 +64,10 @@ namespace MPF.UI.Windows
|
||||
RedumpPasswordBox!.Password = options.Processing.Login.RedumpPassword;
|
||||
|
||||
// Add handlers
|
||||
AaruPathButton!.Click += BrowseForPathClick;
|
||||
DiscImageCreatorPathButton!.Click += BrowseForPathClick;
|
||||
RedumperPathButton!.Click += BrowseForPathClick;
|
||||
DefaultOutputPathButton!.Click += BrowseForPathClick;
|
||||
AaruPathButton!.Click += BrowseForAaruPathClick;
|
||||
DiscImageCreatorPathButton!.Click += BrowseForDiscImageCreatorPathClick;
|
||||
RedumperPathButton!.Click += BrowseForRedumperPathClick;
|
||||
DefaultOutputPathButton!.Click += BrowseForDefaultOutputPathClick;
|
||||
|
||||
AcceptButton!.Click += OnAcceptClick;
|
||||
CancelButton!.Click += OnCancelClick;
|
||||
@@ -91,11 +91,11 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Browse and set a path based on the invoking button
|
||||
/// </summary>
|
||||
private void BrowseForPath(Window parent, System.Windows.Controls.Button? button)
|
||||
private string? BrowseForPath(Window parent, System.Windows.Controls.Button? button)
|
||||
{
|
||||
// If the button is null, we can't do anything
|
||||
if (button is null)
|
||||
return;
|
||||
return null;
|
||||
|
||||
// Strips button prefix to obtain the setting name
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
@@ -118,38 +118,39 @@ namespace MPF.UI.Windows
|
||||
using (dialog)
|
||||
{
|
||||
DialogResult result = dialog.ShowDialog();
|
||||
if (result == System.Windows.Forms.DialogResult.OK)
|
||||
if (result != System.Windows.Forms.DialogResult.OK)
|
||||
return null;
|
||||
|
||||
string path = string.Empty;
|
||||
bool exists = false;
|
||||
|
||||
if (shouldBrowseForPath && dialog is FolderBrowserDialog folderBrowserDialog)
|
||||
{
|
||||
string path = string.Empty;
|
||||
bool exists = false;
|
||||
|
||||
if (shouldBrowseForPath && dialog is FolderBrowserDialog folderBrowserDialog)
|
||||
{
|
||||
path = folderBrowserDialog.SelectedPath;
|
||||
exists = Directory.Exists(path);
|
||||
}
|
||||
else if (dialog is OpenFileDialog openFileDialog)
|
||||
{
|
||||
path = openFileDialog.FileName;
|
||||
exists = File.Exists(path);
|
||||
}
|
||||
|
||||
if (exists)
|
||||
{
|
||||
OptionsViewModel.Options.ConvertToOptions()[pathSettingName] = path;
|
||||
var textBox = TextBoxForPathSetting(parent, pathSettingName);
|
||||
textBox?.Text = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show(
|
||||
"Specified path doesn't exist!",
|
||||
(string)System.Windows.Application.Current.FindResource("ErrorMessageString"),
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error
|
||||
);
|
||||
}
|
||||
path = folderBrowserDialog.SelectedPath;
|
||||
exists = Directory.Exists(path);
|
||||
}
|
||||
else if (dialog is OpenFileDialog openFileDialog)
|
||||
{
|
||||
path = openFileDialog.FileName;
|
||||
exists = File.Exists(path);
|
||||
}
|
||||
|
||||
if (exists)
|
||||
{
|
||||
var textBox = TextBoxForPathSetting(parent, pathSettingName);
|
||||
textBox?.Text = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show(
|
||||
"Specified path doesn't exist!",
|
||||
(string)System.Windows.Application.Current.FindResource("ErrorMessageString"),
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error
|
||||
);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,8 +206,42 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for generic Click event
|
||||
/// </summary>
|
||||
private void BrowseForPathClick(object sender, EventArgs e)
|
||||
=> BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
private void BrowseForAaruPathClick(object sender, EventArgs e)
|
||||
{
|
||||
string? result = BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
if (result is not null)
|
||||
OptionsViewModel.Options.Dumping.AaruPath = result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for generic Click event
|
||||
/// </summary>
|
||||
private void BrowseForDefaultOutputPathClick(object sender, EventArgs e)
|
||||
{
|
||||
string? result = BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
if (result is not null)
|
||||
OptionsViewModel.Options.Dumping.DefaultOutputPath = result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for generic Click event
|
||||
/// </summary>
|
||||
private void BrowseForDiscImageCreatorPathClick(object sender, EventArgs e)
|
||||
{
|
||||
string? result = BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
if (result is not null)
|
||||
OptionsViewModel.Options.Dumping.DiscImageCreatorPath = result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for generic Click event
|
||||
/// </summary>
|
||||
private void BrowseForRedumperPathClick(object sender, EventArgs e)
|
||||
{
|
||||
string? result = BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
if (result is not null)
|
||||
OptionsViewModel.Options.Dumping.RedumperPath = result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alert user of non-redump mode implications
|
||||
|
||||
Reference in New Issue
Block a user