OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 3 Jan 2009 22:46:52 +0000 (22:46 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 3 Jan 2009 22:46:52 +0000 (22:46 +0000)
- Fixes some bugs/issues with the Queue Windows / Main Window Queue/Encoding tie-in

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

win/C#/Functions/QueryParser.cs
win/C#/Queue/QueueHandler.cs
win/C#/frmMain.cs
win/C#/frmQueue.cs

index 32179d8..759a58d 100644 (file)
@@ -9,11 +9,13 @@ using System.Collections.Generic;
 using System.Text;\r
 using System.Text.RegularExpressions;\r
 using System.Windows.Forms;\r
+using System.Globalization;\r
 \r
 namespace Handbrake.Functions\r
 {\r
     class QueryParser\r
     {\r
+        static readonly private CultureInfo Culture = new CultureInfo("en-US", false);\r
 \r
         // All the Main Window GUI options\r
         #region Varibles\r
@@ -1022,7 +1024,7 @@ namespace Handbrake.Functions
                 double qConvert = 0;\r
                 if (videoQuality.Success != false)\r
                 {\r
-                    qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;\r
+                    qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture) * 100;\r
                     qConvert = System.Math.Ceiling(qConvert);\r
                     thisQuery.q_videoQuality = int.Parse(qConvert.ToString());\r
                 }\r
index 6810dec..9568014 100644 (file)
@@ -5,10 +5,12 @@ using System.Collections;
 using System.IO;\r
 using System.Windows.Forms;\r
 using System.Xml.Serialization;\r
+using System.Threading;\r
+using System.Diagnostics;\r
 \r
 namespace Handbrake.Queue\r
 {\r
-    public class Queue\r
+    public class QueueHandler\r
     {\r
         private static XmlSerializer ser = new XmlSerializer(typeof(List<QueueItem>));\r
         List<QueueItem> queue = new List<QueueItem>();\r
@@ -37,7 +39,7 @@ namespace Handbrake.Queue
         /// Get the last query that was returned by getNextItemForEncoding()\r
         /// </summary>\r
         /// <returns></returns>\r
-        public QueueItem getLastQuery()\r
+        public QueueItem getLastQueryItem()\r
         {\r
             return lastItem;\r
         }\r
@@ -201,5 +203,5 @@ namespace Handbrake.Queue
                 }\r
             }\r
         }\r
-    }\r
+   }\r
 }\r
index 5110b0b..418a15f 100644 (file)
@@ -25,7 +25,7 @@ namespace Handbrake
         private delegate void UpdateWindowHandler();\r
         Functions.Main hb_common_func = new Functions.Main();\r
         Functions.Encode encodeHandler = new Functions.Encode();\r
-        Queue.Queue encodeQueue = new Queue.Queue();\r
+        Queue.QueueHandler encodeQueue = new Queue.QueueHandler();\r
         Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();\r
         Parsing.Title selectedTitle;\r
         Parsing.DVD thisDVD;\r
@@ -503,7 +503,13 @@ namespace Handbrake
 \r
                 if (result == DialogResult.Yes)\r
                 {\r
-                    queueWindow.frmMain_cancelEncode();\r
+                    Process[] aProc = Process.GetProcessesByName("HandBrakeCLI");\r
+                    Process HandBrakeCLI;\r
+                    if (aProc.Length > 0)\r
+                    {\r
+                        HandBrakeCLI = aProc[0];\r
+                        HandBrakeCLI.Kill();\r
+                    }\r
                     if (!queueWindow.isEncoding())\r
                         setEncodeFinished();\r
                 }\r
index afa9f46..43f198a 100644 (file)
@@ -26,7 +26,7 @@ namespace Handbrake
         Functions.Encode cliObj = new Functions.Encode();\r
         Boolean paused = false;\r
         Process hbProc = null;\r
-        Queue.Queue queue;\r
+        Queue.QueueHandler queue;\r
         frmMain mainWindow = null;\r
         Thread theQ;\r
 \r
@@ -40,7 +40,7 @@ namespace Handbrake
         /// Initializes the Queue list with the Arraylist from the Queue class\r
         /// </summary>\r
         /// <param name="qw"></param>\r
-        public void setQueue(Queue.Queue qw)\r
+        public void setQueue(Queue.QueueHandler qw)\r
         {\r
             queue = qw;\r
             redrawQueue();\r
@@ -60,83 +60,15 @@ namespace Handbrake
         }\r
 \r
         /// <summary>\r
-        /// This disables encoding from the queue when a single encode from the main window is running.\r
+        /// Allows frmMain to start an encode.\r
+        /// Should probably find a cleaner way of doing this.\r
         /// </summary>\r
         public void frmMain_encode()\r
         {\r
-            paused = false;\r
-            // Start the encode\r
-            try\r
-            {\r
-                if (queue.count() != 0)\r
-                {\r
-                    // Setup or reset some values\r
-                    btn_encode.Enabled = false;\r
-                    btn_stop.Visible = true;\r
-\r
-                    Thread theQ = new Thread(startProc);\r
-                    theQ.IsBackground = true;\r
-                    theQ.Start();\r
-                }\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show(exc.ToString());\r
-            }\r
+            btn_encode_Click(this, null);\r
         }\r
 \r
-        public void frmMain_cancelEncode()\r
-        {\r
-            Process[] aProc = Process.GetProcessesByName("HandBrakeCLI");\r
-            Process HandBrakeCLI;\r
-            if (aProc.Length > 0)\r
-            {\r
-                HandBrakeCLI = aProc[0];\r
-                HandBrakeCLI.Kill();\r
-            }\r
-        }\r
-\r
-        // Redraw's the queue with the latest data from the Queue class\r
-        private void redrawQueue()\r
-        {\r
-            list_queue.Items.Clear();\r
-            List<Queue.QueueItem> theQueue = queue.getQueue();\r
-            foreach (Queue.QueueItem queue_item in theQueue)\r
-            {\r
-                string q_item = queue_item.Query;\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
-\r
-                // Get the DVD Title\r
-                string title = "";\r
-                if (parsed.DVDTitle == 0)\r
-                    title = "Auto";\r
-                else\r
-                    title = parsed.DVDTitle.ToString();\r
-\r
-                // Get the DVD Chapters\r
-                string chapters = "";\r
-                if (parsed.DVDChapterStart == 0)\r
-                    chapters = "Auto";\r
-                else\r
-                {\r
-                    chapters = parsed.DVDChapterStart.ToString();\r
-                    if (parsed.DVDChapterFinish != 0)\r
-                        chapters = chapters + " - " + parsed.DVDChapterFinish;\r
-                }\r
-\r
-                ListViewItem item = new ListViewItem();\r
-                item.Text = title; // Title\r
-                item.SubItems.Add(chapters); // Chapters\r
-                item.SubItems.Add(queue_item.Source); // Source\r
-                item.SubItems.Add(queue_item.Destination); // Destination\r
-                item.SubItems.Add(parsed.VideoEncoder); // Video\r
-                item.SubItems.Add(parsed.AudioEncoder1); // Audio\r
-\r
-                list_queue.Items.Add(item);\r
-            }\r
-        }\r
-\r
-        // Initializes the encode process\r
+        // Start and Stop Controls\r
         private void btn_encode_Click(object sender, EventArgs e)\r
         {\r
             if (queue.count() != 0)\r
@@ -146,7 +78,6 @@ namespace Handbrake
                     paused = false;\r
                     btn_encode.Enabled = false;\r
                     btn_stop.Visible = true;\r
-                    MessageBox.Show("Encoding will now continue!","Info", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
                 }\r
                 else\r
                 {\r
@@ -173,6 +104,15 @@ namespace Handbrake
                 }\r
             }\r
         }\r
+        private void btn_stop_Click(object sender, EventArgs e)\r
+        {\r
+            paused = true;\r
+            btn_stop.Visible = false;\r
+            btn_encode.Enabled = true;\r
+            mainWindow.setEncodeFinished();\r
+            resetQueue();\r
+            MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+        }\r
 \r
         // Starts the encoding process\r
         private void startProc(object state)\r
@@ -185,7 +125,7 @@ namespace Handbrake
                     string query = queue.getNextItemForEncoding();\r
                     queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
 \r
-                    setEncValue();\r
+                    setCurrentEncodeInformation();\r
                     if (this.Created)\r
                         updateUIElements();\r
 \r
@@ -193,7 +133,7 @@ namespace Handbrake
 \r
                     hbProc.WaitForExit();\r
                     cliObj.addCLIQueryToLog(query);\r
-                    cliObj.copyLog(query, queue.getLastQuery().Destination);\r
+                    cliObj.copyLog(query, queue.getLastQueryItem().Destination);\r
 \r
                     hbProc.Close();\r
                     hbProc.Dispose();\r
@@ -217,8 +157,8 @@ namespace Handbrake
             }\r
         }\r
 \r
-        // Reset's the window to the default state.\r
-        private void resetQueue()\r
+        // Window Display Management\r
+        private void resetQueue() \r
         {\r
             try\r
             {\r
@@ -246,18 +186,45 @@ namespace Handbrake
                 MessageBox.Show(exc.ToString());\r
             }\r
         }\r
-\r
-        // Stop's the queue from continuing. \r
-        private void btn_stop_Click(object sender, EventArgs e)\r
+        private void redrawQueue()  \r
         {\r
-            paused = true;\r
-            btn_stop.Visible = false;\r
-            btn_encode.Enabled = true;\r
-            MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-        }\r
+            list_queue.Items.Clear();\r
+            List<Queue.QueueItem> theQueue = queue.getQueue();\r
+            foreach (Queue.QueueItem queue_item in theQueue)\r
+            {\r
+                string q_item = queue_item.Query;\r
+                Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
+\r
+                // Get the DVD Title\r
+                string title = "";\r
+                if (parsed.DVDTitle == 0)\r
+                    title = "Auto";\r
+                else\r
+                    title = parsed.DVDTitle.ToString();\r
+\r
+                // Get the DVD Chapters\r
+                string chapters = "";\r
+                if (parsed.DVDChapterStart == 0)\r
+                    chapters = "Auto";\r
+                else\r
+                {\r
+                    chapters = parsed.DVDChapterStart.ToString();\r
+                    if (parsed.DVDChapterFinish != 0)\r
+                        chapters = chapters + " - " + parsed.DVDChapterFinish;\r
+                }\r
 \r
-        // Updates the progress bar and progress label for a new status.\r
-        private void updateUIElements()\r
+                ListViewItem item = new ListViewItem();\r
+                item.Text = title; // Title\r
+                item.SubItems.Add(chapters); // Chapters\r
+                item.SubItems.Add(queue_item.Source); // Source\r
+                item.SubItems.Add(queue_item.Destination); // Destination\r
+                item.SubItems.Add(parsed.VideoEncoder); // Video\r
+                item.SubItems.Add(parsed.AudioEncoder1); // Audio\r
+\r
+                list_queue.Items.Add(item);\r
+            }\r
+        }\r
+        private void updateUIElements() \r
         {\r
             try\r
             {\r
@@ -275,21 +242,19 @@ namespace Handbrake
                 MessageBox.Show(exc.ToString());\r
             }\r
         }\r
-\r
-        // Set's the information lables about the current encode.\r
-        private void setEncValue()\r
+        private void setCurrentEncodeInformation() \r
         {\r
             try\r
             {\r
                 if (this.InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new setEncoding(setEncValue));\r
+                    this.BeginInvoke(new setEncoding(setCurrentEncodeInformation));\r
                 }\r
 \r
                 // found query is a global varible\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQuery().Query);\r
-                lbl_source.Text = queue.getLastQuery().Source;\r
-                lbl_dest.Text = queue.getLastQuery().Destination;\r
+                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQueryItem().Query);\r
+                lbl_source.Text = queue.getLastQueryItem().Source;\r
+                lbl_dest.Text = queue.getLastQueryItem().Destination;\r
 \r
 \r
                 if (parsed.DVDTitle == 0)\r