diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs
index 945dfc05..2a3ff922 100644
--- a/DICUI.Library/Utilities/DumpEnvironment.cs
+++ b/DICUI.Library/Utilities/DumpEnvironment.cs
@@ -157,33 +157,13 @@ namespace DICUI.Utilities
if (!File.Exists(DICPath))
return false;
- // Use the drive speed command as a quick test
- Process childProcess;
- string output = await Task.Run(() =>
+ Parameters parameters = new Parameters(string.Empty)
{
- childProcess = new Process()
- {
- StartInfo = new ProcessStartInfo()
- {
- FileName = DICPath,
- Arguments = DICCommandStrings.DriveSpeed + " " + Drive.Letter,
- CreateNoWindow = true,
- UseShellExecute = false,
- RedirectStandardInput = true,
- RedirectStandardOutput = true,
- },
- };
- childProcess.Start();
- childProcess.WaitForExit(1000);
+ Command = DICCommand.DriveSpeed,
+ DriveLetter = Drive.Letter.ToString(),
+ };
- // Just in case, we want to push a button 5 times to clear any errors
- for (int i = 0; i < 5; i++)
- childProcess.StandardInput.WriteLine("Y");
-
- string stdout = childProcess.StandardOutput.ReadToEnd();
- childProcess.Dispose();
- return stdout;
- });
+ string output = await ExecuteDiscImageCreatorWithParameters(parameters);
// If we get the firmware message
if (output.Contains("[ERROR] This drive isn't latest firmware. Please update."))
@@ -208,30 +188,13 @@ namespace DICUI.Utilities
if (Drive.InternalDriveType != InternalDriveType.Optical)
return;
- Process childProcess;
- await Task.Run(() =>
+ Parameters parameters = new Parameters(string.Empty)
{
- childProcess = new Process()
- {
- StartInfo = new ProcessStartInfo()
- {
- FileName = DICPath,
- Arguments = DICCommandStrings.Eject + " " + Drive.Letter,
- CreateNoWindow = true,
- UseShellExecute = false,
- RedirectStandardInput = true,
- RedirectStandardOutput = true,
- },
- };
- childProcess.Start();
- childProcess.WaitForExit(1000);
+ Command = DICCommand.Eject,
+ DriveLetter = Drive.Letter.ToString(),
+ };
- // Just in case, we want to push a button 5 times to clear any errors
- for (int i = 0; i < 5; i++)
- childProcess.StandardInput.WriteLine("Y");
-
- childProcess.Dispose();
- });
+ await ExecuteDiscImageCreatorWithParameters(parameters);
}
///
@@ -389,6 +352,31 @@ namespace DICUI.Utilities
return null;
}
+ ///
+ /// Reset the current drive using DIC
+ ///
+ public async void ResetDrive()
+ {
+ // Validate that the required program exists
+ if (!File.Exists(DICPath))
+ return;
+
+ // Precautionary check for dumping, just in case
+ CancelDumping();
+
+ // Validate we're not trying to reset a non-optical
+ if (Drive.InternalDriveType != InternalDriveType.Optical)
+ return;
+
+ Parameters parameters = new Parameters(string.Empty)
+ {
+ Command = DICCommand.Reset,
+ DriveLetter = Drive.Letter.ToString(),
+ };
+
+ await ExecuteDiscImageCreatorWithParameters(parameters);
+ }
+
///
/// Execute a complete dump workflow
///
@@ -422,7 +410,7 @@ namespace DICUI.Utilities
/// Verify that the current environment has a complete dump and create submission info is possible
///
/// Result instance with the outcome
- public Result VerifyAndSaveDumpOutput(IProgress progress, bool? ejectDisc = null, Func ShowUserPrompt = null)
+ public Result VerifyAndSaveDumpOutput(IProgress progress, bool? ejectDisc = null, bool resetDrive = false, Func ShowUserPrompt = null)
{
progress.Report(Result.Success("Gathering submission information... please wait!"));
@@ -440,6 +428,12 @@ namespace DICUI.Utilities
EjectDisc();
}
+ if (resetDrive)
+ {
+ progress.Report(Result.Success($"Resetting drive {Drive.Letter}"));
+ ResetDrive();
+ }
+
if (PromptForDiscInformation && ShowUserPrompt != null)
{
progress?.Report(Result.Success("Waiting for additional disc information..."));
@@ -522,6 +516,43 @@ namespace DICUI.Utilities
dicProcess.WaitForExit();
}
+ ///
+ /// Run DIC async with an input set of parameters
+ ///
+ ///
+ /// Standard output from commandline window
+ private async Task ExecuteDiscImageCreatorWithParameters(Parameters parameters)
+ {
+ Process childProcess;
+ string output = await Task.Run(() =>
+ {
+ childProcess = new Process()
+ {
+ StartInfo = new ProcessStartInfo()
+ {
+ FileName = DICPath,
+ Arguments = parameters.GenerateParameters(),
+ CreateNoWindow = true,
+ UseShellExecute = false,
+ RedirectStandardInput = true,
+ RedirectStandardOutput = true,
+ },
+ };
+ childProcess.Start();
+ childProcess.WaitForExit(1000);
+
+ // Just in case, we want to push a button 5 times to clear any errors
+ for (int i = 0; i < 5; i++)
+ childProcess.StandardInput.WriteLine("Y");
+
+ string stdout = childProcess.StandardOutput.ReadToEnd();
+ childProcess.Dispose();
+ return stdout;
+ });
+
+ return output;
+ }
+
///
/// Execute subdump for a (potential) Sega Saturn dump
///
diff --git a/DICUI/App.config b/DICUI/App.config
index 0e5d553e..3bf5566e 100644
--- a/DICUI/App.config
+++ b/DICUI/App.config
@@ -20,6 +20,7 @@
+
diff --git a/DICUI/Options.cs b/DICUI/Options.cs
index 3893708f..a2fa239c 100644
--- a/DICUI/Options.cs
+++ b/DICUI/Options.cs
@@ -23,6 +23,7 @@ namespace DICUI
public bool AddPlaceholders { get; set; }
public bool PromptForDiscInformation { get; set; }
public bool IgnoreFixedDrives { get; set; }
+ public bool ResetDriveAfterDump { get; set; }
public bool SkipMediaTypeDetection { get; set; }
public bool SkipSystemDetection { get; set; }
@@ -74,6 +75,7 @@ namespace DICUI
this.AddPlaceholders = GetBooleanSetting(configFile, "AddPlaceholders", true);
this.PromptForDiscInformation = GetBooleanSetting(configFile, "PromptForDiscInformation", true);
this.IgnoreFixedDrives = GetBooleanSetting(configFile, "IgnoreFixedDrives", false);
+ this.ResetDriveAfterDump = GetBooleanSetting(configFile, "ResetDriveAfterDump", false);
this.Username = GetStringSetting(configFile, "Username", "");
this.Password = GetStringSetting(configFile, "Password", "");
diff --git a/DICUI/ViewModels.cs b/DICUI/ViewModels.cs
index d7225b25..f96186c5 100644
--- a/DICUI/ViewModels.cs
+++ b/DICUI/ViewModels.cs
@@ -59,6 +59,12 @@ namespace DICUI
set { _options.IgnoreFixedDrives = value; }
}
+ public bool ResetDriveAfterDump
+ {
+ get { return _options.ResetDriveAfterDump; }
+ set { _options.ResetDriveAfterDump = value; }
+ }
+
public bool SkipMediaTypeDetection
{
get { return _options.SkipMediaTypeDetection; }
diff --git a/DICUI/Windows/MainWindow.xaml.cs b/DICUI/Windows/MainWindow.xaml.cs
index ba5e76f4..06823ed2 100644
--- a/DICUI/Windows/MainWindow.xaml.cs
+++ b/DICUI/Windows/MainWindow.xaml.cs
@@ -105,6 +105,12 @@ namespace DICUI.Windows
ViewModels.LoggerViewModel.VerboseLogLn($"Ejecting disc in drive {_env.Drive.Letter}");
_env.EjectDisc();
}
+
+ if (_options.ResetDriveAfterDump)
+ {
+ ViewModels.LoggerViewModel.VerboseLogLn($"Resetting drive {_env.Drive.Letter}");
+ _env.ResetDrive();
+ }
}
}
@@ -510,7 +516,9 @@ namespace DICUI.Windows
if (result)
{
// Verify dump output and save it
- result = _env.VerifyAndSaveDumpOutput(progress, EjectWhenDoneCheckBox.IsChecked,
+ result = _env.VerifyAndSaveDumpOutput(progress,
+ EjectWhenDoneCheckBox.IsChecked,
+ _options.ResetDriveAfterDump,
(si) =>
{
// lazy initialization
diff --git a/DICUI/Windows/OptionsWindow.xaml b/DICUI/Windows/OptionsWindow.xaml
index c0d32119..13a17cf2 100644
--- a/DICUI/Windows/OptionsWindow.xaml
+++ b/DICUI/Windows/OptionsWindow.xaml
@@ -137,6 +137,12 @@
IsChecked="{Binding Path=IgnoreFixedDrives}"
ToolTip="Ignore hard drives and other fixed drives" Margin="0,4"
/>
+
+