mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Make outputting to separate window a setting
This commit is contained in:
@@ -171,32 +171,39 @@ namespace MPF.Data
|
||||
/// <summary>
|
||||
/// Run internal program
|
||||
/// </summary>
|
||||
public void ExecuteInternalProgram()
|
||||
/// <param name="separateWindow">True to show in separate window, false otherwise</param>
|
||||
public void ExecuteInternalProgram(bool separateWindow)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
process = new Process()
|
||||
// Create the start info
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = ExecutablePath,
|
||||
Arguments = GenerateParameters() ?? "",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
},
|
||||
FileName = ExecutablePath,
|
||||
Arguments = GenerateParameters() ?? "",
|
||||
CreateNoWindow = !separateWindow,
|
||||
UseShellExecute = separateWindow,
|
||||
RedirectStandardOutput = !separateWindow,
|
||||
RedirectStandardError = !separateWindow,
|
||||
};
|
||||
|
||||
// Create the new process
|
||||
process = new Process() { StartInfo = startInfo };
|
||||
|
||||
// Add event handlers
|
||||
process.OutputDataReceived += OutputToLog;
|
||||
process.ErrorDataReceived += OutputToLog;
|
||||
// Add event handlers, if necessary
|
||||
if (!separateWindow)
|
||||
{
|
||||
process.OutputDataReceived += OutputToLog;
|
||||
process.ErrorDataReceived += OutputToLog;
|
||||
}
|
||||
|
||||
// Start the process
|
||||
process.Start();
|
||||
|
||||
// Begin reading the outputs
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
// Begin reading the outputs, if necessary
|
||||
if (!separateWindow)
|
||||
{
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
}
|
||||
|
||||
process.WaitForExit();
|
||||
process.Close();
|
||||
|
||||
@@ -268,6 +268,15 @@ namespace MPF.Data
|
||||
set { _settings["IgnoreFixedDrives"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show dumping tools in their own window instead of in the log
|
||||
/// </summary>
|
||||
public bool ToolsInSeparateWindow
|
||||
{
|
||||
get { return GetBooleanSetting(_settings, "ToolsInSeparateWindow", false); }
|
||||
set { _settings["ToolsInSeparateWindow"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skip Options
|
||||
|
||||
@@ -386,10 +386,10 @@ namespace MPF.Utilities
|
||||
return result;
|
||||
|
||||
// Execute internal tool
|
||||
progress?.Report(Result.Success($"Executing {Options.InternalProgram}... see log for output!"));
|
||||
progress?.Report(Result.Success($"Executing {Options.InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}"));
|
||||
Directory.CreateDirectory(OutputDirectory);
|
||||
Parameters.ReportStatus += OutputToLog;
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram());
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow));
|
||||
progress?.Report(Result.Success($"{Options.InternalProgram} has finished!"));
|
||||
|
||||
// Execute additional tools
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -124,6 +123,18 @@ namespace MPF.UserControls
|
||||
ProgressLabel.Text = string.Format("Scanning sectors for protection... ({0:##.##}%)", percentProgress);
|
||||
}
|
||||
}));
|
||||
|
||||
_matchers.Add(new Matcher(
|
||||
"Checking SubQ ctl (Track)",
|
||||
@"\s*(\d+)\/\s*(\d+)$",
|
||||
match => {
|
||||
if (UInt32.TryParse(match.Groups[1].Value, out uint current) && UInt32.TryParse(match.Groups[2].Value, out uint total))
|
||||
{
|
||||
float percentProgress = (current / (float)total) * 100;
|
||||
ProgressBar.Value = percentProgress;
|
||||
ProgressLabel.Text = string.Format("Checking subchannels... ({0:##.##}%)", percentProgress);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -80,6 +80,11 @@
|
||||
ToolTip="Ignore hard drives and other fixed drives" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Show Separate Window"
|
||||
IsChecked="{Binding Path=UIOptions.Options.ToolsInSeparateWindow}"
|
||||
ToolTip="Show program output in separate command window instead of in the log" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Protection Scan"
|
||||
IsChecked="{Binding Path=UIOptions.Options.ScanForProtection}"
|
||||
ToolTip="Enable automatic checking for copy protection on dumped media" Margin="0,4,0,0"
|
||||
|
||||
Reference in New Issue
Block a user