From d70d8f5b6eb0ef944ec67187fc2ca185e866e3c4 Mon Sep 17 00:00:00 2001 From: Wilson Date: Wed, 2 Mar 2022 00:43:05 -0500 Subject: [PATCH] Added a button to quickly update the volume label and dump path. (#369) * Added a button to quickly update the volume label and dump path. Behaves identically to switching the selected drive combo box. (Calls the InitializeUIValues method with rescanDrives set to false.) * Typo fixed the odd w. --- MPF/ViewModels/MainViewModel.cs | 18 +++++++++++++++++- MPF/Windows/MainWindow.xaml | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MPF/ViewModels/MainViewModel.cs b/MPF/ViewModels/MainViewModel.cs index 531f73c3..8014d17f 100644 --- a/MPF/ViewModels/MainViewModel.cs +++ b/MPF/ViewModels/MainViewModel.cs @@ -76,6 +76,7 @@ namespace MPF.GUI.ViewModels // Disable buttons until we load fully App.Instance.StartStopButton.IsEnabled = false; App.Instance.MediaScanButton.IsEnabled = false; + App.Instance.UpdateVolumeLabel.IsEnabled = false; App.Instance.CopyProtectScanButton.IsEnabled = false; // Add the click handlers to the UI @@ -105,6 +106,7 @@ namespace MPF.GUI.ViewModels // Always enable the media scan App.Instance.MediaScanButton.IsEnabled = true; + App.Instance.UpdateVolumeLabel.IsEnabled = true; // Populate the list of drives and add it to the combo box Drives = Drive.CreateListOfDrives(App.Options.IgnoreFixedDrives); @@ -548,6 +550,7 @@ namespace MPF.GUI.ViewModels App.Instance.CopyProtectScanButton.Click += CopyProtectScanButtonClick; App.Instance.EnableParametersCheckBox.Click += EnableParametersCheckBoxClick; App.Instance.MediaScanButton.Click += MediaScanButtonClick; + App.Instance.UpdateVolumeLabel.Click += UpdateVolumeLabelClick; App.Instance.OutputDirectoryBrowseButton.Click += OutputDirectoryBrowseButtonClick; App.Instance.StartStopButton.Click += StartStopButtonClick; @@ -612,6 +615,7 @@ namespace MPF.GUI.ViewModels App.Instance.EnableParametersCheckBox.IsEnabled = false; App.Instance.StartStopButton.Content = Interface.StopDumping; App.Instance.MediaScanButton.IsEnabled = false; + App.Instance.UpdateVolumeLabel.IsEnabled = false; App.Instance.CopyProtectScanButton.IsEnabled = false; } @@ -631,6 +635,7 @@ namespace MPF.GUI.ViewModels App.Instance.EnableParametersCheckBox.IsEnabled = true; App.Instance.StartStopButton.Content = Interface.StartDumping; App.Instance.MediaScanButton.IsEnabled = true; + App.Instance.UpdateVolumeLabel.IsEnabled = true; App.Instance.CopyProtectScanButton.IsEnabled = true; } @@ -1006,7 +1011,7 @@ namespace MPF.GUI.ViewModels App.Instance.DriveLetterComboBox.SelectedIndex = driveIndex; } catch { } - + int driveSpeed = Env.Parameters.Speed ?? -1; if (driveSpeed > 0) App.Instance.DriveSpeedComboBox.SelectedValue = driveSpeed; @@ -1067,6 +1072,7 @@ namespace MPF.GUI.ViewModels App.Instance.StatusLabel.Content = "Scanning for copy protection... this might take a while!"; App.Instance.StartStopButton.IsEnabled = false; App.Instance.MediaScanButton.IsEnabled = false; + App.Instance.UpdateVolumeLabel.IsEnabled = false; App.Instance.CopyProtectScanButton.IsEnabled = false; var progress = new Progress(); @@ -1096,6 +1102,7 @@ namespace MPF.GUI.ViewModels App.Instance.StatusLabel.Content = tempContent; App.Instance.StartStopButton.IsEnabled = ShouldEnableDumpingButton(); App.Instance.MediaScanButton.IsEnabled = true; + App.Instance.UpdateVolumeLabel.IsEnabled = true; App.Instance.CopyProtectScanButton.IsEnabled = true; } } @@ -1451,6 +1458,15 @@ namespace MPF.GUI.ViewModels private void MediaScanButtonClick(object sender, RoutedEventArgs e) => InitializeUIValues(removeEventHandlers: true, rescanDrives: true); + /// + /// Handler for UpdateVolumeLabel Click event + /// + private void UpdateVolumeLabelClick(object sender, RoutedEventArgs e) + { + if (_canExecuteSelectionChanged) + InitializeUIValues(removeEventHandlers: true, rescanDrives: false); + } + /// /// Handler for MediaTypeComboBox SelectionChanged event /// diff --git a/MPF/Windows/MainWindow.xaml b/MPF/Windows/MainWindow.xaml index 6200e945..36e13dde 100644 --- a/MPF/Windows/MainWindow.xaml +++ b/MPF/Windows/MainWindow.xaml @@ -163,11 +163,13 @@ - +