]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Sun, 14 Jun 2009 13:31:24 +0000 (13:31 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 14 Jun 2009 13:31:24 +0000 (13:31 +0000)
- Small tweaks to Encode.cs
- write2disk queue recovery feature is now completely handled in QueueHandler
- Auto naming is on by default.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2533 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/EncodeQueue/Encode.cs
win/C#/EncodeQueue/QueueHandler.cs
win/C#/Properties/Settings.Designer.cs
win/C#/Properties/Settings.settings
win/C#/app.config
win/C#/frmMain.cs
win/C#/frmQueue.cs

index c0e0b7c3e86f251678b9ae224d14004d6a0cea65..80125fc30a2c320050ceb772aaa94f256f4b2bfb 100644 (file)
@@ -33,7 +33,7 @@ namespace Handbrake.EncodeQueue
                 {\r
                     cliStart.RedirectStandardOutput = true;\r
                     cliStart.UseShellExecute = false;\r
-                    \r
+\r
                 }\r
                 if (Properties.Settings.Default.cli_minimized == "Checked")\r
                     cliStart.WindowStyle = ProcessWindowStyle.Minimized;\r
@@ -43,7 +43,8 @@ namespace Handbrake.EncodeQueue
                 currentEncode.processID = Main.getCliProcess(before);\r
                 currentEncode.isEncoding = true;\r
                 currentEncode.currentQuery = query;\r
-                currentEncode.processHandle = (int)currentEncode.hbProcProcess.MainWindowHandle; // Set the process Handle\r
+                if (currentEncode.hbProcProcess != null)\r
+                    currentEncode.processHandle = (int)currentEncode.hbProcProcess.MainWindowHandle; // Set the process Handle\r
 \r
                 // Set the process Priority\r
                 Process hbCliProcess = null;\r
@@ -75,7 +76,7 @@ namespace Handbrake.EncodeQueue
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc);\r
+                MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n   Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
 \r
             return currentEncode;\r
index d16f10ffb83a00441cc94aa691ddcbe087280349..68cfe306a298cc387fe217c34abe2801b3be65ec 100644 (file)
@@ -36,6 +36,9 @@ namespace Handbrake.EncodeQueue
             String query = job.Query;\r
             lastQueueItem = job;\r
             remove(0);    // Remove the item which we are about to pass out.\r
+\r
+            updateQueueRecoveryFile("hb_queue_recovery.xml");\r
+\r
             return query;\r
         }\r
 \r
@@ -57,6 +60,7 @@ namespace Handbrake.EncodeQueue
             id++;\r
 \r
             queue.Add(newJob);\r
+            updateQueueRecoveryFile("hb_queue_recovery.xml");\r
         }\r
 \r
         /// <summary>\r
@@ -82,6 +86,7 @@ namespace Handbrake.EncodeQueue
         public void remove(int index)\r
         {\r
             queue.RemoveAt(index);\r
+            updateQueueRecoveryFile("hb_queue_recovery.xml");\r
         }\r
 \r
         /// <summary>\r
@@ -106,6 +111,7 @@ namespace Handbrake.EncodeQueue
                 queue.RemoveAt(index);\r
                 queue.Insert((index - 1), item);\r
             }\r
+            updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
         }\r
 \r
         /// <summary>\r
@@ -121,13 +127,14 @@ namespace Handbrake.EncodeQueue
                 queue.RemoveAt(index);\r
                 queue.Insert((index + 1), item);\r
             }\r
+            updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
         }\r
 \r
         /// <summary>\r
         /// Writes the current queue to disk. hb_queue_recovery.xml\r
         /// This function is called after getNextItemForEncoding()\r
         /// </summary>\r
-        public void write2disk(string file)\r
+        public void updateQueueRecoveryFile(string file)\r
         {\r
             string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file;\r
 \r
@@ -191,11 +198,7 @@ namespace Handbrake.EncodeQueue
         /// </summary>\r
         public void recoverQueue(string file)\r
         {\r
-            string tempPath;\r
-            if (file == "hb_queue_recovery.xml")\r
-                tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
-            else\r
-                tempPath = file;\r
+            string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file;\r
 \r
             if (File.Exists(tempPath))\r
             {\r
@@ -210,7 +213,7 @@ namespace Handbrake.EncodeQueue
                                 queue.Add(item);\r
 \r
                         if (file != "hb_queue_recovery.xml")\r
-                            write2disk("hb_queue_recovery.xml");\r
+                            updateQueueRecoveryFile("hb_queue_recovery.xml");\r
                     }\r
                 }\r
             }\r
@@ -226,7 +229,6 @@ namespace Handbrake.EncodeQueue
 \r
         public void startEncode()\r
         { \r
-            Thread theQueue;\r
             if (this.count() != 0)\r
             {\r
                 if (isPaused)\r
@@ -236,7 +238,7 @@ namespace Handbrake.EncodeQueue
                     isPaused = false;\r
                     try\r
                     {\r
-                        theQueue = new Thread(startProc) { IsBackground = true };\r
+                        Thread theQueue = new Thread(startProcess) { IsBackground = true };\r
                         theQueue.Start();\r
                     }\r
                     catch (Exception exc)\r
@@ -256,7 +258,7 @@ namespace Handbrake.EncodeQueue
             encodeHandler.closeCLI(encodeProcess);\r
         }\r
 \r
-        private void startProc(object state)\r
+        private void startProcess(object state)\r
         {\r
             try\r
             {\r
@@ -264,7 +266,7 @@ namespace Handbrake.EncodeQueue
                 while (this.count() != 0)\r
                 {\r
                     string query = getNextItemForEncoding();\r
-                    write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
+                    updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
 \r
                     encodeProcess = encodeHandler.runCli(query);\r
                     EncodeStarted(null);\r
index f4cb2bd337b60a87bc719b765dccfb795c8c5d02..d03a34de724f3a989635c7a29bb49ac38cd6421d 100644 (file)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------\r
 // <auto-generated>\r
 //     This code was generated by a tool.\r
-//     Runtime Version:2.0.50727.3053\r
+//     Runtime Version:2.0.50727.3082\r
 //\r
 //     Changes to this file may cause incorrect behavior and will be lost if\r
 //     the code is regenerated.\r
@@ -145,7 +145,7 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("Checked")]\r
         public string autoNaming {\r
             get {\r
                 return ((string)(this["autoNaming"]));\r
@@ -229,7 +229,7 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}-{chapters}")]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}")]\r
         public string autoNameFormat {\r
             get {\r
                 return ((string)(this["autoNameFormat"]));\r
index 6a94bff039df22822840e8a5e5e78bf2e99b7416..d8d2a1c6fd101684c8b9f1be087f08d107adb90b 100644 (file)
@@ -33,7 +33,7 @@
       <Value Profile="(Default)">0</Value>\r
     </Setting>\r
     <Setting Name="autoNaming" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
+      <Value Profile="(Default)">Checked</Value>\r
     </Setting>\r
     <Setting Name="autoNamePath" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
@@ -54,7 +54,7 @@
       <Value Profile="(Default)" />\r
     </Setting>\r
     <Setting Name="autoNameFormat" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">{source}-{title}-{chapters}</Value>\r
+      <Value Profile="(Default)">{source}-{title}</Value>\r
     </Setting>\r
     <Setting Name="saveLogToSpecifiedPath" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
index d4c74e98ab6a2910c73ffa75e38e876e4387a812..344c8dd04ea278b997d626c1c889b2bec3fb8aa7 100644 (file)
@@ -38,7 +38,7 @@
                 <value>0</value>\r
             </setting>\r
             <setting name="autoNaming" serializeAs="String">\r
-                <value />\r
+                <value>Checked</value>\r
             </setting>\r
             <setting name="autoNamePath" serializeAs="String">\r
                 <value />\r
@@ -59,7 +59,7 @@
                 <value />\r
             </setting>\r
             <setting name="autoNameFormat" serializeAs="String">\r
-                <value>{source}-{title}-{chapters}</value>\r
+                <value>{source}-{title}</value>\r
             </setting>\r
             <setting name="saveLogToSpecifiedPath" serializeAs="String">\r
                 <value />\r
index b74499ef32190519fe900a9d69a4df333b152b1a..bad59d7b88d7646094b3ff2dbc3ba20f7588a033 100644 (file)
@@ -26,8 +26,8 @@ namespace Handbrake
         QueryGenerator queryGen = new QueryGenerator();\r
 \r
         // Globals: Mainly used for tracking. *********************************\r
-        Title selectedTitle;\r
-        DVD thisDVD;\r
+        private Title selectedTitle;\r
+        private DVD thisDVD;\r
         private frmQueue queueWindow;\r
         private frmPreview qtpreview;\r
         private Form splash;\r
@@ -215,9 +215,8 @@ namespace Handbrake
             // Experimental HBProc Process Monitoring.\r
             if (Properties.Settings.Default.enocdeStatusInGui == "Checked")\r
             {\r
-                HBProcess = encodeQueue.encodeProcess.hbProcProcess;\r
-                Thread EncodeMon = new Thread(encodeMonitorThread);\r
-                EncodeMon.Start();\r
+                Thread encodeMon = new Thread(encodeMonitorThread);\r
+                encodeMon.Start();\r
             }\r
         }\r
         private void encodeEnded(object sender, EventArgs e)\r
@@ -544,10 +543,8 @@ namespace Handbrake
                     String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.generateTheQuery(this);\r
 \r
                     if (encodeQueue.count() == 0)\r
-                    {\r
                         encodeQueue.add(query, text_source.Text, text_destination.Text);\r
-                        encodeQueue.write2disk("hb_queue_recovery.xml");\r
-                    }\r
+\r
                     queueWindow.setQueue();\r
                     if (encodeQueue.count() > 1)\r
                         queueWindow.Show(false);\r
@@ -582,7 +579,6 @@ namespace Handbrake
                 else\r
                     encodeQueue.add(query, text_source.Text, text_destination.Text);\r
 \r
-                encodeQueue.write2disk("hb_queue_recovery.xml"); // Writes the queue to the recovery file, just incase the GUI crashes.\r
                 queueWindow.Show();\r
             }\r
         }\r
@@ -1560,14 +1556,13 @@ namespace Handbrake
         #endregion\r
 \r
         #region In-GUI Encode Status (Experimental)\r
-        private Process HBProcess { get; set; }\r
-\r
+        \r
         private void encodeMonitorThread()\r
         {\r
             try\r
             {\r
-                Parser encode = new Parser(HBProcess.StandardOutput.BaseStream);\r
-                encode.OnEncodeProgress += encode_OnEncodeProgress;\r
+                Parser encode = new Parser(encodeQueue.encodeProcess.hbProcProcess.StandardOutput.BaseStream);\r
+                encode.OnEncodeProgress += encodeOnEncodeProgress;\r
                 while (!encode.EndOfStream)\r
                 {\r
                     encode.readEncodeStatus();\r
@@ -1578,12 +1573,11 @@ namespace Handbrake
                 MessageBox.Show(exc.ToString());\r
             }\r
         }\r
-\r
-        private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
+        private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
         {\r
             if (this.InvokeRequired)\r
             {\r
-                this.BeginInvoke(new EncodeProgressEventHandler(encode_OnEncodeProgress),\r
+                this.BeginInvoke(new EncodeProgressEventHandler(encodeOnEncodeProgress),\r
                     new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
                 return;\r
             }\r
index 88da988ba35ba06aeedc0a653d05fcbb5e5460a0..1672ae3f5eec9d374f7385a00e9607f68f348c60 100644 (file)
@@ -255,7 +255,6 @@ namespace Handbrake
                 foreach (int selectedIndex in selectedIndices)\r
                     queue.remove(selectedIndex);\r
 \r
-                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 updateUIElements();\r
 \r
                 // Select the item where the first deleted item was previously\r
@@ -310,7 +309,6 @@ namespace Handbrake
                 foreach (int selectedIndex in selectedIndices)\r
                     queue.moveUp(selectedIndex);\r
 \r
-                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 updateUIElements();\r
 \r
                 // Keep the selected item(s) selected, now moved up one index\r
@@ -339,7 +337,6 @@ namespace Handbrake
                 foreach (int selectedIndex in selectedIndices)\r
                     queue.moveDown(selectedIndex);\r
 \r
-                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 updateUIElements();\r
 \r
                 // Keep the selected item(s) selected, now moved down one index\r
@@ -366,7 +363,7 @@ namespace Handbrake
             SaveFile.Filter = "HandBrake Queue|*.queue";\r
             SaveFile.ShowDialog();\r
             if (SaveFile.FileName != String.Empty)\r
-                queue.write2disk(SaveFile.FileName);\r
+                queue.updateQueueRecoveryFile(SaveFile.FileName);\r
         }\r
         private void mnu_import_Click(object sender, EventArgs e)\r
         {\r
@@ -381,7 +378,6 @@ namespace Handbrake
             if (queue.lastQueueItem != null)\r
             {\r
                 queue.add(queue.lastQueueItem.Query, queue.lastQueueItem.Source, queue.lastQueueItem.Destination);\r
-                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 updateUIElements();\r
             }\r
         }\r