summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/C#/Functions/Main.cs23
-rw-r--r--win/C#/Services/Scan.cs20
-rw-r--r--win/C#/Settings.StyleCop5
-rw-r--r--win/C#/frmMain.cs45
-rw-r--r--win/C#/frmOptions.cs1
5 files changed, 61 insertions, 33 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index cb82a4bad..80d806b49 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -153,6 +153,15 @@ namespace Handbrake.Functions
// Get the Source Name
string sourceName = mainWindow.SourceName;
+ // Remove any illeagal characters from the source name
+ foreach (char character in Path.GetInvalidFileNameChars())
+ {
+ if (autoNamePath != null)
+ {
+ sourceName = sourceName.Replace(character.ToString(), string.Empty);
+ }
+ }
+
if (Properties.Settings.Default.AutoNameRemoveUnderscore)
sourceName = sourceName.Replace("_", " ");
@@ -208,18 +217,12 @@ namespace Handbrake.Functions
else // Otherwise, use the path that is already there.
{
// Use the path and change the file extension to match the previous destination
- autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);
+ autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text),
+ destinationFilename);
if (Path.HasExtension(mainWindow.text_destination.Text))
- autoNamePath = Path.ChangeExtension(autoNamePath, Path.GetExtension(mainWindow.text_destination.Text));
- }
- }
-
- foreach (char character in Path.GetInvalidFileNameChars())
- {
- if (autoNamePath != null)
- {
- autoNamePath = autoNamePath.Replace(character.ToString(), string.Empty);
+ autoNamePath = Path.ChangeExtension(autoNamePath,
+ Path.GetExtension(mainWindow.text_destination.Text));
}
}
diff --git a/win/C#/Services/Scan.cs b/win/C#/Services/Scan.cs
index abecfec2b..6fd00a34f 100644
--- a/win/C#/Services/Scan.cs
+++ b/win/C#/Services/Scan.cs
@@ -128,6 +128,24 @@ namespace Handbrake.Services
}
/// <summary>
+ /// Kill the scan
+ /// </summary>
+ public void KillScan()
+ {
+ try
+ {
+ if (hbProc != null)
+ hbProc.Kill();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(
+ "Unable to kill HandBrakeCLI.exe \nYou may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically within the next few minutes. \n\nError Information: \n" +
+ ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ /// <summary>
/// Start a scan for a given source path and title
/// </summary>
/// <param name="sourcePath">Path to the source file</param>
@@ -193,7 +211,7 @@ namespace Handbrake.Services
{
Console.WriteLine("frmMain.cs - scanProcess() " + exc);
}
- }
+ }
/// <summary>
/// Read the log file
diff --git a/win/C#/Settings.StyleCop b/win/C#/Settings.StyleCop
index 90f8bc063..8d623254e 100644
--- a/win/C#/Settings.StyleCop
+++ b/win/C#/Settings.StyleCop
@@ -150,6 +150,11 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
+ <Rule Name="PrefixLocalCallsWithThis">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 50a4c8ef6..0b89a573b 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -1783,23 +1783,13 @@ namespace Handbrake
private void KillScan()
{
- try
- {
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);
- EnableGUI();
- ResetGUI();
+ SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);
+ EnableGUI();
+ ResetGUI();
- if (SourceScan.ScanProcess() != null)
- SourceScan.ScanProcess().Kill();
+ SourceScan.KillScan();
- lbl_encode.Text = "Scan Cancelled!";
- }
- catch (Exception ex)
- {
- MessageBox.Show(
- "Unable to kill HandBrakeCLI.exe \nYou may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically within the next few minutes. \n\nError Information: \n" +
- ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
+ lbl_encode.Text = "Scan Cancelled!";
}
private void ResetGUI()
@@ -1987,9 +1977,9 @@ namespace Handbrake
/// <summary>
/// Handle GUI shortcuts
/// </summary>
- /// <param name="msg"></param>
- /// <param name="keyData"></param>
- /// <returns></returns>
+ /// <param name="msg">Message</param>
+ /// <param name="keyData">Keys</param>
+ /// <returns>Bool</returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
@@ -2009,18 +1999,31 @@ namespace Handbrake
/// <summary>
/// If the queue is being processed, prompt the user to confirm application close.
/// </summary>
- /// <param name="e"></param>
+ /// <param name="e">FormClosingEventArgs</param>
protected override void OnFormClosing(FormClosingEventArgs e)
{
// If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.
- if ((encodeQueue.IsEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))
+ if (encodeQueue.IsEncoding)
{
DialogResult result =
MessageBox.Show(
- "HandBrake has queue items to process. Closing HandBrake will not stop the current encoding, but will stop processing the queue.\n\nDo you want to close HandBrake?",
+ "HandBrake has queue items to process. Closing HandBrake will stop the current encoding.\n\nDo you want to close HandBrake?",
"Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+
if (result == DialogResult.No)
e.Cancel = true;
+
+ // Try to safely close out if we can, or kill the cli if using in-gui status
+ if (Settings.Default.enocdeStatusInGui)
+ encodeQueue.Stop();
+ else
+ encodeQueue.SafelyClose();
+ }
+
+ if (SourceScan.IsScanning)
+ {
+ SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);
+ SourceScan.KillScan();
}
base.OnFormClosing(e);
}
diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs
index 1a25c9f9d..26bb26464 100644
--- a/win/C#/frmOptions.cs
+++ b/win/C#/frmOptions.cs
@@ -104,7 +104,6 @@ namespace Handbrake
else
radio_foreignAndSubs.Checked = true;
-
// #############################
// CLI
// #############################