diff --git a/CHANGELIST.md b/CHANGELIST.md
index d19984ae..1bb0b323 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -40,6 +40,7 @@
- Move decoupled view models
- Fix log output
- Start migrating MainViewModel
+- Perform most of MainViewModel changes
### 2.6.6 (2023-10-04)
diff --git a/MPF.UI.Core/ViewModels/MainViewModel.cs b/MPF.UI.Core/ViewModels/MainViewModel.cs
index 7b7379a5..f06eed0a 100644
--- a/MPF.UI.Core/ViewModels/MainViewModel.cs
+++ b/MPF.UI.Core/ViewModels/MainViewModel.cs
@@ -68,6 +68,20 @@ namespace MPF.UI.Core.ViewModels
#region Properties
+ ///
+ /// Indicates the status of the options menu item
+ ///
+ public bool OptionsMenuItemEnabled
+ {
+ get => _optionsMenuItemEnabled;
+ set
+ {
+ _optionsMenuItemEnabled = value;
+ TriggerPropertyChanged("OptionsMenuItemEnabled");
+ }
+ }
+ private bool _optionsMenuItemEnabled;
+
///
/// Currently selected system value
///
@@ -82,6 +96,20 @@ namespace MPF.UI.Core.ViewModels
}
private RedumpSystem? _currentSystem;
+ ///
+ /// Indicates the status of the system type combo box
+ ///
+ public bool SystemTypeComboBoxEnabled
+ {
+ get => _systemTypeComboBoxEnabled;
+ set
+ {
+ _systemTypeComboBoxEnabled = value;
+ TriggerPropertyChanged("SystemTypeComboBoxEnabled");
+ }
+ }
+ private bool _systemTypeComboBoxEnabled;
+
///
/// Currently selected media type value
///
@@ -96,6 +124,20 @@ namespace MPF.UI.Core.ViewModels
}
private MediaType? _currentMediaType;
+ ///
+ /// Indicates the status of the media type combo box
+ ///
+ public bool MediaTypeComboBoxEnabled
+ {
+ get => _mediaTypeComboBoxEnabled;
+ set
+ {
+ _mediaTypeComboBoxEnabled = value;
+ TriggerPropertyChanged("MediaTypeComboBoxEnabled");
+ }
+ }
+ private bool _mediaTypeComboBoxEnabled;
+
///
/// Currently provided output path
///
@@ -110,6 +152,34 @@ namespace MPF.UI.Core.ViewModels
}
private string _outputPath;
+ ///
+ /// Indicates the status of the output path text box
+ ///
+ public bool OutputPathTextBoxEnabled
+ {
+ get => _outputPathTextBoxEnabled;
+ set
+ {
+ _outputPathTextBoxEnabled = value;
+ TriggerPropertyChanged("OutputPathTextBoxEnabled");
+ }
+ }
+ private bool _outputPathTextBoxEnabled;
+
+ ///
+ /// Indicates the status of the output path browse button
+ ///
+ public bool OutputPathBrowseButtonEnabled
+ {
+ get => _outputPathBrowseButtonEnabled;
+ set
+ {
+ _outputPathBrowseButtonEnabled = value;
+ TriggerPropertyChanged("OutputPathBrowseButtonEnabled");
+ }
+ }
+ private bool _outputPathBrowseButtonEnabled;
+
///
/// Currently selected drive value
///
@@ -124,6 +194,20 @@ namespace MPF.UI.Core.ViewModels
}
private Drive _currentDrive;
+ ///
+ /// Indicates the status of the drive combo box
+ ///
+ public bool DriveLetterComboBoxEnabled
+ {
+ get => _driveLetterComboBoxEnabled;
+ set
+ {
+ _driveLetterComboBoxEnabled = value;
+ TriggerPropertyChanged("DriveLetterComboBoxEnabled");
+ }
+ }
+ private bool _driveLetterComboBoxEnabled;
+
///
/// Currently selected drive speed value
///
@@ -138,6 +222,20 @@ namespace MPF.UI.Core.ViewModels
}
private int _driveSpeed;
+ ///
+ /// Indicates the status of the drive speed combo box
+ ///
+ public bool DriveSpeedComboBoxEnabled
+ {
+ get => _driveSpeedComboBoxEnabled;
+ set
+ {
+ _driveSpeedComboBoxEnabled = value;
+ TriggerPropertyChanged("DriveSpeedComboBoxEnabled");
+ }
+ }
+ private bool _driveSpeedComboBoxEnabled;
+
///
/// Currently selected dumping program
///
@@ -152,6 +250,20 @@ namespace MPF.UI.Core.ViewModels
}
private InternalProgram _currentProgram;
+ ///
+ /// Indicates the status of the dumping program combo box
+ ///
+ public bool DumpingProgramComboBoxEnabled
+ {
+ get => _dumpingProgramComboBoxEnabled;
+ set
+ {
+ _dumpingProgramComboBoxEnabled = value;
+ TriggerPropertyChanged("DumpingProgramComboBoxEnabled");
+ }
+ }
+ private bool _dumpingProgramComboBoxEnabled;
+
///
/// Currently provided parameters
///
@@ -166,6 +278,104 @@ namespace MPF.UI.Core.ViewModels
}
private string _parameters;
+ ///
+ /// Indicates the status of the parameters text box
+ ///
+ public bool ParametersCheckBoxEnabled
+ {
+ get => _parametersCheckBoxEnabled;
+ set
+ {
+ _parametersCheckBoxEnabled = value;
+ TriggerPropertyChanged("ParametersCheckBoxEnabled");
+ }
+ }
+ private bool _parametersCheckBoxEnabled;
+
+ ///
+ /// Indicates the status of the parameters check box
+ ///
+ public bool EnableParametersCheckBoxEnabled
+ {
+ get => _enableParametersCheckBoxEnabled;
+ set
+ {
+ _enableParametersCheckBoxEnabled = value;
+ TriggerPropertyChanged("EnableParametersCheckBoxEnabled");
+ }
+ }
+ private bool _enableParametersCheckBoxEnabled;
+
+ ///
+ /// Indicates the status of the start/stop button
+ ///
+ public bool StartStopButtonEnabled
+ {
+ get => _startStopButtonEnabled;
+ set
+ {
+ _startStopButtonEnabled = value;
+ TriggerPropertyChanged("StartStopButtonEnabled");
+ }
+ }
+ private bool _startStopButtonEnabled;
+
+ ///
+ /// Current value for the start/stop dumping button
+ ///
+ public object StartStopButtonText
+ {
+ get => _startStopButtonText;
+ set
+ {
+ _startStopButtonText = value as string;
+ TriggerPropertyChanged("StartStopButtonText");
+ }
+ }
+ private string _startStopButtonText;
+
+ ///
+ /// Indicates the status of the media scan button
+ ///
+ public bool MediaScanButtonEnabled
+ {
+ get => _mediaScanButtonEnabled;
+ set
+ {
+ _mediaScanButtonEnabled = value;
+ TriggerPropertyChanged("MediaScanButtonEnabled");
+ }
+ }
+ private bool _mediaScanButtonEnabled;
+
+ ///
+ /// Indicates the status of the update volume label button
+ ///
+ public bool UpdateVolumeLabelEnabled
+ {
+ get => _updateVolumeLabelEnabled;
+ set
+ {
+ _updateVolumeLabelEnabled = value;
+ TriggerPropertyChanged("UpdateVolumeLabelEnabled");
+ }
+ }
+ private bool _updateVolumeLabelEnabled;
+
+ ///
+ /// Indicates the status of the copy protect scan button
+ ///
+ public bool CopyProtectScanButtonEnabled
+ {
+ get => _copyProtectScanButtonEnabled;
+ set
+ {
+ _copyProtectScanButtonEnabled = value;
+ TriggerPropertyChanged("CopyProtectScanButtonEnabled");
+ }
+ }
+ private bool _copyProtectScanButtonEnabled;
+
///
/// Currently displayed status
///
@@ -180,6 +390,20 @@ namespace MPF.UI.Core.ViewModels
}
private string _status;
+ ///
+ /// Indicates the status of the log panel
+ ///
+ public bool LogPanelExpanded
+ {
+ get => _logPanelExpanded;
+ set
+ {
+ _logPanelExpanded = value;
+ TriggerPropertyChanged("LogPanelExpanded");
+ }
+ }
+ private bool _logPanelExpanded;
+
#endregion
#region List Properties
@@ -198,6 +422,20 @@ namespace MPF.UI.Core.ViewModels
}
private List _drives;
+ ///
+ /// Current list of drive speeds
+ ///
+ public List DriveSpeeds
+ {
+ get => _driveSpeeds;
+ set
+ {
+ _driveSpeeds = value;
+ TriggerPropertyChanged("DriveSpeeds");
+ }
+ }
+ private List _driveSpeeds;
+
///
/// Current list of supported media types
///
@@ -248,6 +486,17 @@ namespace MPF.UI.Core.ViewModels
public MainViewModel()
{
_options = OptionsLoader.LoadFromConfig();
+
+ OptionsMenuItemEnabled = true;
+ SystemTypeComboBoxEnabled = true;
+ MediaTypeComboBoxEnabled = true;
+ DriveLetterComboBoxEnabled = true;
+ DumpingProgramComboBoxEnabled = true;
+ StartStopButtonEnabled = true;
+ StartStopButtonText = Interface.StartDumping;
+ MediaScanButtonEnabled = true;
+ LogPanelExpanded = _options.OpenLogWindowAtStartup;
+
MediaTypes = new List>();
Systems = RedumpSystemComboBoxItem.GenerateElements().ToList();
InternalPrograms = new List>();
@@ -305,8 +554,8 @@ namespace MPF.UI.Core.ViewModels
this.Logger.VerboseLogLn("Scanning for drives..");
// Always enable the media scan
- this.Parent.MediaScanButton.IsEnabled = true;
- this.Parent.UpdateVolumeLabel.IsEnabled = true;
+ this.MediaScanButtonEnabled = true;
+ this.UpdateVolumeLabelEnabled = true;
// If we have a selected drive, keep track of it
char? lastSelectedDrive = this.CurrentDrive?.Letter;
@@ -339,14 +588,14 @@ namespace MPF.UI.Core.ViewModels
// Set the selected index
CurrentDrive = (index != -1 ? Drives[index] : Drives[0]);
this.Status = "Valid drive found! Choose your Media Type";
- this.Parent.CopyProtectScanButton.IsEnabled = true;
+ this.CopyProtectScanButtonEnabled = true;
// Get the current system type
if (index != -1)
DetermineSystemType();
// Only enable the start/stop if we don't have the default selected
- this.Parent.StartStopButton.IsEnabled = ShouldEnableDumpingButton();
+ this.StartStopButtonEnabled = ShouldEnableDumpingButton();
}
else
{
@@ -354,15 +603,12 @@ namespace MPF.UI.Core.ViewModels
this.Logger.VerboseLogLn("Found no drives");
this.CurrentDrive = null;
this.Status = "No valid drive found!";
- this.Parent.StartStopButton.IsEnabled = false;
- this.Parent.CopyProtectScanButton.IsEnabled = false;
+ this.StartStopButtonEnabled = false;
+ this.CopyProtectScanButtonEnabled = false;
}
// Reenable UI updates
CanExecuteSelectionChanged = true;
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -381,26 +627,21 @@ namespace MPF.UI.Core.ViewModels
this.Logger.VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
MediaTypes = Element.GenerateElements().Where(m => mediaTypeValues.Contains(m.Value)).ToList();
-
- //this.Parent.MediaTypeComboBox.IsEnabled = MediaTypes.Count > 1;
- this.Parent.MediaTypeComboBox.IsEnabled = true;
-
+ this.MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
this.CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
- this.Parent.MediaTypeComboBox.SelectedIndex = (index > -1 ? index : 0);
}
else
{
- this.Parent.MediaTypeComboBox.IsEnabled = false;
- this.Parent.MediaTypeComboBox.ItemsSource = null;
- this.Parent.MediaTypeComboBox.SelectedIndex = -1;
+ this.MediaTypeComboBoxEnabled = false;
+ this.MediaTypes = null;
+ this.CurrentMediaType = null;
}
// Reenable UI updates
CanExecuteSelectionChanged = true;
- // Ensure the UI gets updated
+ // Force an update of the media type
this.ChangeMediaType(null);
- this.Parent.UpdateLayout();
}
///
@@ -424,9 +665,6 @@ namespace MPF.UI.Core.ViewModels
// Reenable UI updates
CanExecuteSelectionChanged = true;
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
#endregion
@@ -675,39 +913,22 @@ namespace MPF.UI.Core.ViewModels
InfoTool.ProcessSpecialFields(result.Item2);
}
- ///
- /// Show the Options window
- ///
- public void ShowOptionsWindow()
- {
- var optionsWindow = new OptionsWindow(this.Options)
- {
- Focusable = true,
- Owner = this.Parent,
- ShowActivated = true,
- ShowInTaskbar = true,
- WindowStartupLocation = WindowStartupLocation.CenterOwner,
- };
- optionsWindow.Closed += OnOptionsUpdated;
- optionsWindow.Show();
- }
-
///
/// Toggle the Start/Stop button
///
public async void ToggleStartStop()
{
// Dump or stop the dump
- if ((string)this.Parent.StartStopButton.Content == Interface.StartDumping)
+ if (this.StartStopButtonText as string == Interface.StartDumping)
{
StartDumping();
}
- else if ((string)this.Parent.StartStopButton.Content == Interface.StopDumping)
+ else if (this.StartStopButtonText as string == Interface.StopDumping)
{
if (this.Options.VerboseLogging)
this.Logger.VerboseLogLn("Canceling dumping process...");
Env.CancelDumping();
- this.Parent.CopyProtectScanButton.IsEnabled = true;
+ this.CopyProtectScanButtonEnabled = true;
if (Env.Options.EjectAfterDump == true)
{
@@ -753,15 +974,14 @@ namespace MPF.UI.Core.ViewModels
public async void InitializeUIValues(bool removeEventHandlers, bool rescanDrives)
{
// Disable the dumping button
- this.Parent.StartStopButton.IsEnabled = false;
+ this.StartStopButtonEnabled = false;
// Safely uncheck the parameters box, just in case
- if (this.Parent.EnableParametersCheckBox.IsChecked == true)
+ if (this.ParametersCheckBoxEnabled == true)
{
- this.Parent.EnableParametersCheckBox.Checked -= Parent.EnableParametersCheckBoxClick;
- this.Parent.EnableParametersCheckBox.IsChecked = false;
- this.Parent.ParametersTextBox.IsEnabled = false;
- this.Parent.EnableParametersCheckBox.Checked += Parent.EnableParametersCheckBoxClick;
+ this.CanExecuteSelectionChanged = false;
+ this.ParametersCheckBoxEnabled = false;
+ this.CanExecuteSelectionChanged = true;
}
// Set the UI color scheme according to the options
@@ -770,9 +990,6 @@ namespace MPF.UI.Core.ViewModels
else
EnableLightMode();
- // Force the UI to reload after applying the theme
- this.Parent.UpdateLayout();
-
// Remove event handlers to ensure ordering
if (removeEventHandlers)
DisableEventHandlers();
@@ -781,20 +998,20 @@ namespace MPF.UI.Core.ViewModels
if (rescanDrives)
{
this.Status = "Creating drive list, please wait!";
- await this.Parent.Dispatcher.InvokeAsync(() => PopulateDrives());
+ PopulateDrives();
}
else
{
- await this.Parent.Dispatcher.InvokeAsync(() => DetermineSystemType());
+ DetermineSystemType();
}
// Determine current media type, if possible
- await this.Parent.Dispatcher.InvokeAsync(() => PopulateMediaType());
+ PopulateMediaType();
CacheCurrentDiscType();
SetCurrentDiscType();
// Set the dumping program
- await this.Parent.Dispatcher.InvokeAsync(() => PopulateInternalPrograms());
+ PopulateInternalPrograms();
// Set the initial environment and UI values
SetSupportedDriveSpeed();
@@ -806,7 +1023,7 @@ namespace MPF.UI.Core.ViewModels
EnableEventHandlers();
// Enable the dumping button, if necessary
- this.Parent.StartStopButton.IsEnabled = ShouldEnableDumpingButton();
+ this.StartStopButtonEnabled = ShouldEnableDumpingButton();
}
///
@@ -816,15 +1033,14 @@ namespace MPF.UI.Core.ViewModels
public void FastUpdateLabel(bool removeEventHandlers)
{
// Disable the dumping button
- this.Parent.StartStopButton.IsEnabled = false;
+ this.StartStopButtonEnabled = false;
// Safely uncheck the parameters box, just in case
- if (this.Parent.EnableParametersCheckBox.IsChecked == true)
+ if (this.ParametersCheckBoxEnabled == true)
{
- this.Parent.EnableParametersCheckBox.Checked -= Parent.EnableParametersCheckBoxClick;
- this.Parent.EnableParametersCheckBox.IsChecked = false;
- this.Parent.ParametersTextBox.IsEnabled = false;
- this.Parent.EnableParametersCheckBox.Checked += Parent.EnableParametersCheckBoxClick;
+ this.CanExecuteSelectionChanged = false;
+ this.ParametersCheckBoxEnabled = false;
+ this.CanExecuteSelectionChanged = true;
}
// Remove event handlers to ensure ordering
@@ -843,7 +1059,7 @@ namespace MPF.UI.Core.ViewModels
EnableEventHandlers();
// Enable the dumping button, if necessary
- this.Parent.StartStopButton.IsEnabled = ShouldEnableDumpingButton();
+ this.StartStopButtonEnabled = ShouldEnableDumpingButton();
}
///
@@ -972,9 +1188,6 @@ namespace MPF.UI.Core.ViewModels
this.Logger.VerboseLogLn($"Drive marked as empty, defaulting to {defaultMediaType.LongName()}.");
CurrentMediaType = defaultMediaType;
}
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -1019,7 +1232,7 @@ namespace MPF.UI.Core.ViewModels
if (currentSystem != null)
{
int sysIndex = Systems.FindIndex(s => s == currentSystem);
- this.Parent.SystemTypeComboBox.SelectedIndex = sysIndex;
+ this.CurrentSystem = Systems[sysIndex];
}
}
else if (this.Options.SkipSystemDetection && this.Options.DefaultSystem != null)
@@ -1028,11 +1241,48 @@ namespace MPF.UI.Core.ViewModels
if (this.Options.VerboseLogging)
this.Logger.VerboseLogLn($"System detection disabled, setting to default of {currentSystem.LongName()}.");
int sysIndex = Systems.FindIndex(s => s == currentSystem);
- this.Parent.SystemTypeComboBox.SelectedIndex = sysIndex;
+ this.CurrentSystem = Systems[sysIndex];
}
+ }
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
+ ///
+ /// Disable all UI elements during dumping
+ ///
+ public void DisableAllUIElements()
+ {
+ OptionsMenuItemEnabled = false;
+ SystemTypeComboBoxEnabled = false;
+ MediaTypeComboBoxEnabled = false;
+ OutputPathTextBoxEnabled = false;
+ OutputPathBrowseButtonEnabled = false;
+ DriveLetterComboBoxEnabled = false;
+ DriveSpeedComboBoxEnabled = false;
+ DumpingProgramComboBoxEnabled = false;
+ EnableParametersCheckBoxEnabled = false;
+ StartStopButtonText = Interface.StopDumping;
+ MediaScanButtonEnabled = false;
+ UpdateVolumeLabelEnabled = false;
+ CopyProtectScanButtonEnabled = false;
+ }
+
+ ///
+ /// Enable all UI elements after dumping
+ ///
+ public void EnableAllUIElements()
+ {
+ OptionsMenuItemEnabled = true;
+ SystemTypeComboBoxEnabled = true;
+ MediaTypeComboBoxEnabled = true;
+ OutputPathTextBoxEnabled = true;
+ OutputPathBrowseButtonEnabled = true;
+ DriveLetterComboBoxEnabled = true;
+ DriveSpeedComboBoxEnabled = true;
+ DumpingProgramComboBoxEnabled = true;
+ EnableParametersCheckBoxEnabled = true;
+ StartStopButtonText = Interface.StartDumping;
+ MediaScanButtonEnabled = true;
+ UpdateVolumeLabelEnabled = true;
+ CopyProtectScanButtonEnabled = true;
}
///
@@ -1051,21 +1301,18 @@ namespace MPF.UI.Core.ViewModels
SetCurrentDiscType();
// Enable or disable the button
- this.Parent.StartStopButton.IsEnabled = result && ShouldEnableDumpingButton();
+ this.StartStopButtonEnabled = result && ShouldEnableDumpingButton();
// If we're in a type that doesn't support drive speeds
- this.Parent.DriveSpeedComboBox.IsEnabled = Env.Type.DoesSupportDriveSpeed();
+ this.DriveSpeedComboBoxEnabled = Env.Type.DoesSupportDriveSpeed();
// If input params are not enabled, generate the full parameters from the environment
- if (!this.Parent.ParametersTextBox.IsEnabled)
+ if (!this.ParametersCheckBoxEnabled)
{
- string generated = Env.GetFullParameters((int?)this.Parent.DriveSpeedComboBox.SelectedItem);
+ string generated = Env.GetFullParameters(this.DriveSpeed);
if (generated != null)
this.Parameters = generated;
}
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -1128,9 +1375,6 @@ namespace MPF.UI.Core.ViewModels
this.OutputPath = Path.Combine(directory, filename);
}
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -1186,10 +1430,10 @@ namespace MPF.UI.Core.ViewModels
var tempContent = this.Status;
this.Status = "Scanning for copy protection... this might take a while!";
- this.Parent.StartStopButton.IsEnabled = false;
- this.Parent.MediaScanButton.IsEnabled = false;
- this.Parent.UpdateVolumeLabel.IsEnabled = false;
- this.Parent.CopyProtectScanButton.IsEnabled = false;
+ this.StartStopButtonEnabled = false;
+ this.MediaScanButtonEnabled = false;
+ this.UpdateVolumeLabelEnabled = false;
+ this.CopyProtectScanButtonEnabled = false;
var progress = new Progress();
progress.ProgressChanged += ProgressUpdated;
@@ -1204,7 +1448,7 @@ namespace MPF.UI.Core.ViewModels
// this.Logger.VerboseLogLn($"SmartE detected, removing {Modules.DiscImageCreator.FlagStrings.ScanFileProtect} from parameters");
//}
- if (!this.Parent.LogPanel.IsExpanded)
+ if (!this.LogPanelExpanded)
{
if (string.IsNullOrEmpty(error))
CustomMessageBox.Show(output, "Detected Protection(s)", MessageBoxButton.OK, MessageBoxImage.Information);
@@ -1218,10 +1462,10 @@ namespace MPF.UI.Core.ViewModels
this.Logger.ErrorLogLn($"Path could not be scanned! Exception information:\r\n\r\n{error}");
this.Status = tempContent;
- this.Parent.StartStopButton.IsEnabled = ShouldEnableDumpingButton();
- this.Parent.MediaScanButton.IsEnabled = true;
- this.Parent.UpdateVolumeLabel.IsEnabled = true;
- this.Parent.CopyProtectScanButton.IsEnabled = true;
+ this.StartStopButtonEnabled = ShouldEnableDumpingButton();
+ this.MediaScanButtonEnabled = true;
+ this.UpdateVolumeLabelEnabled = true;
+ this.CopyProtectScanButtonEnabled = true;
}
}
@@ -1240,9 +1484,6 @@ namespace MPF.UI.Core.ViewModels
this.Logger.VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
this.CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -1251,10 +1492,9 @@ namespace MPF.UI.Core.ViewModels
public void SetSupportedDriveSpeed()
{
// Set the drive speed list that's appropriate
- var values = Interface.GetSpeedsForMediaType(CurrentMediaType);
- this.Parent.DriveSpeedComboBox.ItemsSource = values;
+ this.DriveSpeeds = (List)Interface.GetSpeedsForMediaType(CurrentMediaType);
if (this.Options.VerboseLogging)
- this.Logger.VerboseLogLn($"Supported media speeds: {string.Join(", ", values)}");
+ this.Logger.VerboseLogLn($"Supported media speeds: {string.Join(", ", this.DriveSpeeds)}");
// Set the selected speed
int speed;
@@ -1283,9 +1523,6 @@ namespace MPF.UI.Core.ViewModels
if (this.Options.VerboseLogging)
this.Logger.VerboseLogLn($"Setting drive speed to: {speed}");
this.DriveSpeed = speed;
-
- // Ensure the UI gets updated
- this.Parent.UpdateLayout();
}
///
@@ -1338,13 +1575,12 @@ namespace MPF.UI.Core.ViewModels
Env.Drive.RefreshDrive();
// If still in custom parameter mode, check that users meant to continue or not
- if (this.Parent.EnableParametersCheckBox.IsChecked == true)
+ if (this.ParametersCheckBoxEnabled == true)
{
MessageBoxResult result = CustomMessageBox.Show("It looks like you have custom parameters that have not been saved. Would you like to apply those changes before starting to dump?", "Custom Changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
- this.Parent.EnableParametersCheckBox.IsChecked = false;
- this.Parent.ParametersTextBox.IsEnabled = false;
+ this.ParametersCheckBoxEnabled = false;
ProcessCustomParameters();
}
else if (result == MessageBoxResult.Cancel)
@@ -1364,7 +1600,7 @@ namespace MPF.UI.Core.ViewModels
return;
// Disable all UI elements apart from dumping button
- this.Parent.DisableAllUIElements();
+ DisableAllUIElements();
// Refresh the drive, if it wasn't null
Env.Drive?.RefreshDrive();
@@ -1395,7 +1631,7 @@ namespace MPF.UI.Core.ViewModels
this.Status = "Execution complete!";
// Reset all UI elements
- this.Parent.EnableAllUIElements();
+ EnableAllUIElements();
return;
}
@@ -1418,7 +1654,40 @@ namespace MPF.UI.Core.ViewModels
finally
{
// Reset all UI elements
- this.Parent.EnableAllUIElements();
+ EnableAllUIElements();
+ }
+ }
+
+ ///
+ /// Toggle the parameters input box
+ ///
+ public void ToggleParameters()
+ {
+ if (ParametersCheckBoxEnabled == true)
+ {
+ SystemTypeComboBoxEnabled = false;
+ MediaTypeComboBoxEnabled = false;
+
+ OutputPathTextBoxEnabled = false;
+ OutputPathBrowseButtonEnabled = false;
+
+ MediaScanButtonEnabled = false;
+ UpdateVolumeLabelEnabled = false;
+ CopyProtectScanButtonEnabled = false;
+ }
+ else
+ {
+ ProcessCustomParameters();
+
+ SystemTypeComboBoxEnabled = true;
+ MediaTypeComboBoxEnabled = true;
+
+ OutputPathTextBoxEnabled = true;
+ OutputPathBrowseButtonEnabled = true;
+
+ MediaScanButtonEnabled = true;
+ UpdateVolumeLabelEnabled = true;
+ CopyProtectScanButtonEnabled = true;
}
}
@@ -1492,7 +1761,7 @@ namespace MPF.UI.Core.ViewModels
///
/// Handler for OptionsWindow OnUpdated event
///
- private void OnOptionsUpdated(object sender, EventArgs e) =>
+ public void OnOptionsUpdated(object sender, EventArgs e) =>
UpdateOptions(sender as OptionsWindow);
#region Progress Reporting
diff --git a/MPF.UI.Core/Windows/MainWindow.xaml b/MPF.UI.Core/Windows/MainWindow.xaml
index 7378b830..9eb2caa0 100644
--- a/MPF.UI.Core/Windows/MainWindow.xaml
+++ b/MPF.UI.Core/Windows/MainWindow.xaml
@@ -55,7 +55,8 @@
+ Template="{DynamicResource CustomMenuItemTemplate}"
+ IsEnabled="{Binding OptionsMenuItemEnabled}"/>
+ IsEnabled="{Binding SystemTypeComboBoxEnabled}" Style="{DynamicResource CustomComboBoxStyle}">