From bfb67ec0c96fc1d9785f528753ef20a707443c00 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 12 Mar 2021 15:29:26 -0800 Subject: [PATCH] Make UI more consistent for dump button --- MPF/Windows/MainWindow.xaml.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/MPF/Windows/MainWindow.xaml.cs b/MPF/Windows/MainWindow.xaml.cs index 06c6d818..b773179a 100644 --- a/MPF/Windows/MainWindow.xaml.cs +++ b/MPF/Windows/MainWindow.xaml.cs @@ -115,7 +115,7 @@ namespace MPF.Windows DetermineSystemType(); // Only enable the start/stop if we don't have the default selected - StartStopButton.IsEnabled = (SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem) != KnownSystem.NONE; + StartStopButton.IsEnabled = ShouldEnableDumpingButton(); } else { @@ -195,8 +195,8 @@ namespace MPF.Windows // Add event handlers AddEventHandlers(); - // Enable the dumping button - StartStopButton.IsEnabled = true; + // Enable the dumping button, if necessary + StartStopButton.IsEnabled = ShouldEnableDumpingButton(); } /// @@ -396,7 +396,8 @@ namespace MPF.Windows // Set the index for the current disc type SetCurrentDiscType(); - StartStopButton.IsEnabled = result && (Drives != null && Drives.Count > 0 ? true : false); + // Enable or disable the button + StartStopButton.IsEnabled = result && ShouldEnableDumpingButton(); // If we're in a type that doesn't support drive speeds DriveSpeedComboBox.IsEnabled = Env.Type.DoesSupportDriveSpeed(); @@ -512,7 +513,7 @@ namespace MPF.Windows LogOutput.LogLn($"Detected the following protections in {drive.Letter}:\r\n\r\n{protections}"); StatusLabel.Content = tempContent; - StartStopButton.IsEnabled = true; + StartStopButton.IsEnabled = ShouldEnableDumpingButton(); MediaScanButton.IsEnabled = true; CopyProtectScanButton.IsEnabled = true; } @@ -564,6 +565,17 @@ namespace MPF.Windows return discInformationWindow.ShowDialog(); } + /// + /// Determine if the dumping button should be enabled + /// + private bool ShouldEnableDumpingButton() + { + return SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem != KnownSystem.NONE + && Drives != null + && Drives.Count > 0 + && !string.IsNullOrEmpty(ParametersTextBox.Text); + } + /// /// Begin the dumping process using the given inputs ///