From ca753b452627ea15703b3a0d1aa714c044affd89 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 6 May 2020 16:37:33 -0700 Subject: [PATCH] Some other abstractions --- DICUI/UIOptions.cs | 13 +++++++++++++ DICUI/Windows/MainWindow.xaml.cs | 16 ++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/DICUI/UIOptions.cs b/DICUI/UIOptions.cs index fc9352db..6f863ac5 100644 --- a/DICUI/UIOptions.cs +++ b/DICUI/UIOptions.cs @@ -6,8 +6,21 @@ namespace DICUI { public class UIOptions { + // TODO: Is there any way that this can be made private? public Options Options { get; set; } + #region Passthrough values + + // TODO: Can any of these be removed? + public string DefaultOutputPath => Options.DefaultOutputPath; + public bool IgnoreFixedDrives => Options.IgnoreFixedDrives; + public bool ResetDriveAfterDump => Options.ResetDriveAfterDump; + public bool SkipMediaTypeDetection => Options.SkipMediaTypeDetection; + public bool SkipSystemDetection => Options.SkipSystemDetection; + public bool OpenLogWindowAtStartup => Options.OpenLogWindowAtStartup; + + #endregion + /// /// Default constructor /// diff --git a/DICUI/Windows/MainWindow.xaml.cs b/DICUI/Windows/MainWindow.xaml.cs index ebc85f5e..6ff6c688 100644 --- a/DICUI/Windows/MainWindow.xaml.cs +++ b/DICUI/Windows/MainWindow.xaml.cs @@ -50,7 +50,7 @@ namespace DICUI.Windows DiskScanButton.IsEnabled = false; CopyProtectScanButton.IsEnabled = false; - if (_uiOptions.Options.OpenLogWindowAtStartup) + if (_uiOptions.OpenLogWindowAtStartup) { this.WindowStartupLocation = WindowStartupLocation.Manual; double combinedHeight = this.Height + _logWindow.Height + Constants.LogWindowMarginFromMainWindow; @@ -72,7 +72,7 @@ namespace DICUI.Windows _alreadyShown = true; - if (_uiOptions.Options.OpenLogWindowAtStartup) + if (_uiOptions.OpenLogWindowAtStartup) { //TODO: this should be bound directly to WindowVisible property in two way fashion // we need to study how to properly do it in XAML @@ -108,7 +108,7 @@ namespace DICUI.Windows _env.EjectDisc(); } - if (_uiOptions.Options.ResetDriveAfterDump) + if (_uiOptions.ResetDriveAfterDump) { ViewModels.LoggerViewModel.VerboseLogLn($"Resetting drive {_env.Drive.Letter}"); _env.ResetDrive(); @@ -368,7 +368,7 @@ namespace DICUI.Windows DiskScanButton.IsEnabled = true; // Populate the list of drives and add it to the combo box - _drives = Validators.CreateListOfDrives(_uiOptions.Options.IgnoreFixedDrives); + _drives = Validators.CreateListOfDrives(_uiOptions.IgnoreFixedDrives); DriveLetterComboBox.ItemsSource = _drives; if (DriveLetterComboBox.Items.Count > 0) @@ -390,7 +390,7 @@ namespace DICUI.Windows CopyProtectScanButton.IsEnabled = true; // Get the current media type - if (!_uiOptions.Options.SkipSystemDetection && index != -1) + if (!_uiOptions.SkipSystemDetection && index != -1) { ViewModels.LoggerViewModel.VerboseLog("Trying to detect system for drive {0}.. ", _drives[index].Letter); var currentSystem = Validators.GetKnownSystem(_drives[index]); @@ -543,7 +543,7 @@ namespace DICUI.Windows // Verify dump output and save it result = _env.VerifyAndSaveDumpOutput(progress, EjectWhenDoneCheckBox.IsChecked, - _uiOptions.Options.ResetDriveAfterDump, + _uiOptions.ResetDriveAfterDump, (si) => { // lazy initialization @@ -626,7 +626,7 @@ namespace DICUI.Windows // Set the output directory, if we changed drives or it's not already if (driveChanged || string.IsNullOrEmpty(OutputDirectoryTextBox.Text)) - OutputDirectoryTextBox.Text = Path.Combine(_uiOptions.Options.DefaultOutputPath, drive?.VolumeLabel ?? string.Empty); + OutputDirectoryTextBox.Text = Path.Combine(_uiOptions.DefaultOutputPath, drive?.VolumeLabel ?? string.Empty); // Get the extension for the file for the next two statements string extension = null; @@ -719,7 +719,7 @@ namespace DICUI.Windows return; // Get the current media type - if (!_uiOptions.Options.SkipMediaTypeDetection) + if (!_uiOptions.SkipMediaTypeDetection) { ViewModels.LoggerViewModel.VerboseLog("Trying to detect media type for drive {0}.. ", drive.Letter); _currentMediaType = Validators.GetMediaType(drive);