OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
index 50a4c8e..bfa4054 100644 (file)
@@ -1605,6 +1605,19 @@ namespace Handbrake
             }\r
         }\r
 \r
+        private void btn_export_Click(object sender, EventArgs e)\r
+        {\r
+            SaveFileDialog saveFileDialog = new SaveFileDialog();\r
+            saveFileDialog.Filter = "Csv File|*.csv";\r
+            saveFileDialog.DefaultExt = "csv";\r
+            if (saveFileDialog.ShowDialog() == DialogResult.OK)\r
+            {\r
+                string filename = saveFileDialog.FileName;\r
+\r
+                Main.SaveChapterMarkersToCsv(this, filename);\r
+            }\r
+        }\r
+\r
         private void mnu_resetChapters_Click(object sender, EventArgs e)\r
         {\r
             data_chpt.Rows.Clear();\r
@@ -1783,23 +1796,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 +1990,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 +2012,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
@@ -2072,6 +2088,7 @@ namespace Handbrake
 \r
         #endregion\r
 \r
+\r
         // This is the END of the road ****************************************\r
     }\r
 }
\ No newline at end of file