OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 30 Apr 2010 19:57:05 +0000 (19:57 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 30 Apr 2010 19:57:05 +0000 (19:57 +0000)
- Kill the CLI on GUI close for Scanning and fixed for encoding.
- Fixed Autoname bug where it would strip all slashes out the path

git-svn-id: svn://localhost/HandBrake/trunk@3279 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Functions/Main.cs
win/C#/Services/Scan.cs
win/C#/Settings.StyleCop
win/C#/frmMain.cs
win/C#/frmOptions.cs

index cb82a4b..80d806b 100644 (file)
@@ -153,6 +153,15 @@ namespace Handbrake.Functions
                 // Get the Source Name \r
                 string sourceName = mainWindow.SourceName;\r
 \r
+                // Remove any illeagal characters from the source name\r
+                foreach (char character in Path.GetInvalidFileNameChars())\r
+                {\r
+                    if (autoNamePath != null)\r
+                    {\r
+                        sourceName = sourceName.Replace(character.ToString(), string.Empty);\r
+                    }\r
+                }\r
+\r
                 if (Properties.Settings.Default.AutoNameRemoveUnderscore)\r
                     sourceName = sourceName.Replace("_", " ");\r
 \r
@@ -208,18 +217,12 @@ namespace Handbrake.Functions
                 else // Otherwise, use the path that is already there.\r
                 {\r
                     // Use the path and change the file extension to match the previous destination\r
-                    autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);\r
+                    autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text),\r
+                                                destinationFilename);\r
 \r
                     if (Path.HasExtension(mainWindow.text_destination.Text))\r
-                        autoNamePath = Path.ChangeExtension(autoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
-                }\r
-            }\r
-\r
-            foreach (char character in Path.GetInvalidFileNameChars())\r
-            {\r
-                if (autoNamePath != null)\r
-                {\r
-                    autoNamePath = autoNamePath.Replace(character.ToString(), string.Empty);\r
+                        autoNamePath = Path.ChangeExtension(autoNamePath,\r
+                                                            Path.GetExtension(mainWindow.text_destination.Text));\r
                 }\r
             }\r
 \r
index abecfec..6fd00a3 100644 (file)
@@ -128,6 +128,24 @@ namespace Handbrake.Services
         }\r
 \r
         /// <summary>\r
+        /// Kill the scan\r
+        /// </summary>\r
+        public void KillScan()\r
+        {\r
+            try\r
+            {\r
+                if (hbProc != null)\r
+                    hbProc.Kill();\r
+            }\r
+            catch (Exception ex)\r
+            {\r
+                MessageBox.Show(\r
+                    "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" +\r
+                    ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
         /// Start a scan for a given source path and title\r
         /// </summary>\r
         /// <param name="sourcePath">Path to the source file</param>\r
@@ -193,7 +211,7 @@ namespace Handbrake.Services
             {\r
                 Console.WriteLine("frmMain.cs - scanProcess() " + exc);\r
             }\r
-        }\r
+        }     \r
 \r
         /// <summary>\r
         /// Read the log file\r
index 90f8bc0..8d62325 100644 (file)
             <BooleanProperty Name="Enabled">False</BooleanProperty>\r
           </RuleSettings>\r
         </Rule>\r
+        <Rule Name="PrefixLocalCallsWithThis">\r
+          <RuleSettings>\r
+            <BooleanProperty Name="Enabled">False</BooleanProperty>\r
+          </RuleSettings>\r
+        </Rule>\r
       </Rules>\r
       <AnalyzerSettings />\r
     </Analyzer>\r
index 50a4c8e..0b89a57 100644 (file)
@@ -1783,23 +1783,13 @@ namespace Handbrake
 \r
         private void KillScan()\r
         {\r
-            try\r
-            {\r
-                SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
-                EnableGUI();\r
-                ResetGUI();\r
+            SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
+            EnableGUI();\r
+            ResetGUI();\r
 \r
-                if (SourceScan.ScanProcess() != null)\r
-                    SourceScan.ScanProcess().Kill();\r
+            SourceScan.KillScan();\r
 \r
-                lbl_encode.Text = "Scan Cancelled!";\r
-            }\r
-            catch (Exception ex)\r
-            {\r
-                MessageBox.Show(\r
-                    "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" +\r
-                    ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-            }\r
+            lbl_encode.Text = "Scan Cancelled!";\r
         }\r
 \r
         private void ResetGUI()\r
@@ -1987,9 +1977,9 @@ namespace Handbrake
         /// <summary>\r
         /// Handle GUI shortcuts\r
         /// </summary>\r
-        /// <param name="msg"></param>\r
-        /// <param name="keyData"></param>\r
-        /// <returns></returns>\r
+        /// <param name="msg">Message</param>\r
+        /// <param name="keyData">Keys</param>\r
+        /// <returns>Bool</returns>\r
         protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\r
         {\r
             if (keyData == (Keys.Control | Keys.S))\r
@@ -2009,18 +1999,31 @@ namespace Handbrake
         /// <summary>\r
         /// If the queue is being processed, prompt the user to confirm application close.\r
         /// </summary>\r
-        /// <param name="e"></param>\r
+        /// <param name="e">FormClosingEventArgs</param>\r
         protected override void OnFormClosing(FormClosingEventArgs e)\r
         {\r
             // If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
-            if ((encodeQueue.IsEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))\r
+            if (encodeQueue.IsEncoding)\r
             {\r
                 DialogResult result =\r
                     MessageBox.Show(\r
-                        "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?",\r
+                        "HandBrake has queue items to process. Closing HandBrake will stop the current encoding.\n\nDo you want to close HandBrake?",\r
                         "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+\r
                 if (result == DialogResult.No)\r
                     e.Cancel = true;\r
+\r
+                // Try to safely close out if we can, or kill the cli if using in-gui status\r
+                if (Settings.Default.enocdeStatusInGui)\r
+                    encodeQueue.Stop();\r
+                else\r
+                    encodeQueue.SafelyClose();\r
+            }\r
+\r
+            if (SourceScan.IsScanning)\r
+            {\r
+                SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
+                SourceScan.KillScan();\r
             }\r
             base.OnFormClosing(e);\r
         }\r
index 1a25c9f..26bb264 100644 (file)
@@ -104,7 +104,6 @@ namespace Handbrake
             else\r
                 radio_foreignAndSubs.Checked = true;\r
 \r
-\r
             // #############################\r
             // CLI\r
             // #############################\r