OSDN Git Service

Win Gui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 14 Jul 2007 15:57:19 +0000 (15:57 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 14 Jul 2007 15:57:19 +0000 (15:57 +0000)
- Fixed bug with chapter drop downs throwing errors when they shouldn't.
- Chapter down down menus are now populated on title selection. (Audio and Subtitles still need to be done)
- Process priority option now works. All encodes both single and queue will use the defined priority.
- A few other small things.

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

win/C#/frmMain.cs
win/C#/frmQueue.Designer.cs
win/C#/frmQueue.cs

index 80900e5..556d8c6 100644 (file)
@@ -8,6 +8,7 @@ using System.Windows.Forms;
 using System.Net;\r
 using System.IO;\r
 using System.Diagnostics;\r
+using System.Threading;\r
 \r
 namespace Handbrake\r
 {\r
@@ -316,7 +317,7 @@ namespace Handbrake
         // TOOLS MENU --------------------------------------------------------------\r
         private void mnu_encode_Click(object sender, EventArgs e)\r
         {\r
-            //Queue.ShowDialog();\r
+            showQueue();\r
         }\r
 \r
         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
@@ -549,9 +550,6 @@ namespace Handbrake
             QueryEditorText.Text = "";\r
         }\r
 \r
-\r
-        \r
-     \r
         private frmQueue queueWindow = (frmQueue)new frmQueue();\r
         private void btn_queue_Click(object sender, EventArgs e)\r
         {\r
@@ -560,6 +558,11 @@ namespace Handbrake
             queueWindow.Show();\r
         }\r
 \r
+        private void showQueue()\r
+        {\r
+            queueWindow.Show();\r
+        }\r
+\r
         private void btn_encode_Click(object sender, EventArgs e)\r
         {\r
             String query = "";\r
@@ -578,14 +581,50 @@ namespace Handbrake
             hbProc.StartInfo.Arguments = query;\r
             hbProc.StartInfo.UseShellExecute = false;\r
             hbProc.Start();\r
+\r
+            // Set the process Priority\r
+            string priority = Properties.Settings.Default.processPriority;\r
+            switch (priority)\r
+            {\r
+                case "Realtime":\r
+                    hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+                    break;\r
+                case "High":\r
+                    hbProc.PriorityClass = ProcessPriorityClass.High;\r
+                    break;\r
+                case "Above Normal":\r
+                    hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+                    break;\r
+                case "Normal":\r
+                    hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+                    break;\r
+                case "Low":\r
+                    hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+                    break;\r
+                default:\r
+                    hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+                    break;\r
+            }\r
             \r
+            //hbProc.WaitForExit;\r
+            //hbProc.Close;\r
+            ThreadPool.QueueUserWorkItem(procMonitor);\r
+           \r
 \r
-            MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+            \r
        \r
             // TODO: Need to write a bit of code here to do process monitoring.\r
             // Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.\r
         }\r
 \r
+        private void procMonitor(object state)\r
+        {\r
+           MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+        }\r
+\r
+\r
+\r
+\r
         // -------------------------------------------------------------- \r
         // Items that require actions on frmMain\r
         // --------------------------------------------------------------\r
@@ -625,7 +664,7 @@ namespace Handbrake
                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
 \r
-                    if (chapterFinish > chapterStart)\r
+                    if (chapterFinish < chapterStart)\r
                     {\r
                         MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
                     }\r
@@ -679,15 +718,17 @@ namespace Handbrake
                     }\r
                 }\r
 \r
+                // There is a bug here *******************************************************************\r
                 if (!lbl_Aspect.Text.Equals("Select a Title")){\r
                     int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);\r
+                    MessageBox.Show("test");\r
                     int mod16 = height % 16;\r
                     height = height - mod16;\r
                     text_height.Text = height.ToString();\r
                 }\r
                \r
             } catch(Exception){\r
-                \r
+                // No need to alert the user if there is a problem here.\r
             }\r
         }\r
 \r
@@ -917,6 +958,8 @@ namespace Handbrake
             // Reset some values on the form\r
             lbl_Aspect.Text = "Select a Title";\r
             lbl_RecomendedCrop.Text = "Select a Title";\r
+            drop_chapterStart.Items.Clear();\r
+            drop_chapterFinish.Items.Clear();\r
             QueryEditorText.Text = "";\r
 \r
             // If the dropdown is set to automatic nothing else needs to be done.\r
@@ -938,10 +981,28 @@ namespace Handbrake
                     {\r
                         lbl_Aspect.Text = thisDVD.Titles[counter].AspectRatio.ToString();\r
                         lbl_RecomendedCrop.Text = thisDVD.Titles[counter].AutoCropDimensions[0] + "/" + thisDVD.Titles[counter].AutoCropDimensions[1] + "/" + thisDVD.Titles[counter].AutoCropDimensions[2] + "/" + thisDVD.Titles[counter].AutoCropDimensions[3];\r
+\r
+                        // Chapter Dropdown Menus\r
+                        int chapterCount = thisDVD.Titles[counter].Chapters.Count;\r
+                        int loopCouter = 1;\r
+                        while (loopCouter <= chapterCount) \r
+                        {\r
+                            drop_chapterStart.Items.Add(loopCouter);\r
+                            drop_chapterFinish.Items.Add(loopCouter);\r
+\r
+                            drop_chapterStart.Text = "1";\r
+                            drop_chapterFinish.Text = loopCouter.ToString();\r
+                            loopCouter++;\r
+                        }\r
+\r
+                        // Audio Drop down Menu.\r
+                        //thisDVD.Titles[counter].AudioTracks[0].ToString()\r
+\r
+                        // Subtitle Dropdown Menu.\r
+\r
                         // Still need to set these up.\r
-                        MessageBox.Show(thisDVD.Titles[counter].AudioTracks[0].ToString());\r
-                        MessageBox.Show(thisDVD.Titles[counter].Chapters.ToString());\r
-                        MessageBox.Show(thisDVD.Titles[counter].Subtitles.ToString());\r
+                        //thisDVD.Titles[counter].Subtitles.ToString()\r
+     \r
                     }\r
                     counter++;\r
                 }\r
index ccef85c..3e170d9 100644 (file)
@@ -149,7 +149,7 @@ namespace Handbrake
             // label2\r
             // \r
             this.label2.AutoSize = true;\r
-            this.label2.Location = new System.Drawing.Point(12, 336);\r
+            this.label2.Location = new System.Drawing.Point(7, 337);\r
             this.label2.Name = "label2";\r
             this.label2.Size = new System.Drawing.Size(51, 13);\r
             this.label2.TabIndex = 35;\r
@@ -158,7 +158,7 @@ namespace Handbrake
             // lbl_progressValue\r
             // \r
             this.lbl_progressValue.AutoSize = true;\r
-            this.lbl_progressValue.Location = new System.Drawing.Point(593, 337);\r
+            this.lbl_progressValue.Location = new System.Drawing.Point(605, 337);\r
             this.lbl_progressValue.Name = "lbl_progressValue";\r
             this.lbl_progressValue.Size = new System.Drawing.Size(24, 13);\r
             this.lbl_progressValue.TabIndex = 36;\r
index 1435331..f555ffe 100644 (file)
@@ -86,6 +86,30 @@ namespace Handbrake
                 hbProc.StartInfo.Arguments = query;\r
                 hbProc.StartInfo.UseShellExecute = false;\r
                 hbProc.Start();\r
+                // Set the process Priority\r
+                string priority = Properties.Settings.Default.processPriority;\r
+                switch (priority)\r
+                {\r
+                    case "Realtime":\r
+                        hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+                        break;\r
+                    case "High":\r
+                        hbProc.PriorityClass = ProcessPriorityClass.High;\r
+                        break;\r
+                    case "Above Normal":\r
+                        hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+                        break;\r
+                    case "Normal":\r
+                        hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+                        break;\r
+                    case "Low":\r
+                        hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+                        break;\r
+                    default:\r
+                        hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+                        break;\r
+                }\r
+\r
                 hbProc.WaitForExit();\r
                 hbProc.Close();\r
                 counter++;\r
@@ -95,7 +119,7 @@ namespace Handbrake
 \r
         private void updateUIElements(int progressSplit)\r
         {\r
-            // This needs to be written so there is no cross-thread problems\r
+            // This needs to be written so there is no cross-thread problems ********************\r
             thisWindow.list_queue.Items.Remove(0);\r
             progressBar.Value = progressBar.Value + progressSplit;\r
             progressBar.Update();\r