OSDN Git Service

WinGui: added initial CLI call managment class (work in progress)
authorbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 15 Jul 2007 21:05:49 +0000 (21:05 +0000)
committerbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 15 Jul 2007 21:05:49 +0000 (21:05 +0000)
updated frmQueue window to work properly with cross-thread calls and updating proper UI elements
updated ToString override in Parsing.Title to display leading zeros in duration

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

win/C#/CLI/Manager.cs [new file with mode: 0644]
win/C#/HandBrakeCS.csproj
win/C#/Parsing/Title.cs
win/C#/frmQueue.cs

diff --git a/win/C#/CLI/Manager.cs b/win/C#/CLI/Manager.cs
new file mode 100644 (file)
index 0000000..ac20609
--- /dev/null
@@ -0,0 +1,20 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Diagnostics;\r
+\r
+namespace Handbrake.CLI\r
+{\r
+    /// <summary>\r
+    /// still workin on this\r
+    /// </summary>\r
+    class Manager\r
+    {\r
+        private static Queue<Process> m_processQueue = new Queue<Process>();\r
+\r
+        public static void Enqueue(object s)\r
+        {\r
+            //TODO: create new Process object from passed \r
+        }\r
+    }\r
+}\r
index 6dc73b4..235cf27 100644 (file)
@@ -37,6 +37,7 @@
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="CLI\Manager.cs" />\r
     <Compile Include="frmAbout.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
index fab287b..d1ccd8a 100644 (file)
@@ -135,7 +135,7 @@ namespace Handbrake.Parsing
 \r
         public override string ToString()\r
         {\r
-            return string.Format("{0} ({1}:{2}:{3})", this.m_titleNumber, this.m_duration.Hours, \r
+            return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.m_titleNumber, this.m_duration.Hours, \r
                 this.m_duration.Minutes, this.m_duration.Seconds);\r
         }\r
 \r
index 8d91576..f9f59fe 100644 (file)
@@ -12,7 +12,7 @@ namespace Handbrake
 {\r
     public partial class frmQueue : Form\r
     {\r
-        private delegate void ProgressUpdateHandler(int progressSplit);\r
+        private delegate void ProgressUpdateHandler();\r
 \r
         public frmQueue()\r
         {\r
@@ -66,21 +66,16 @@ namespace Handbrake
         {\r
             progressBar.Value = 0;\r
             lbl_progressValue.Text = "0 %";\r
+            progressBar.Step = 100 / list_queue.Items.Count;\r
             progressBar.Update();\r
             ThreadPool.QueueUserWorkItem(startProc);\r
         }\r
 \r
         private void startProc(object state)\r
         {\r
-            int listSize = list_queue.Items.Count;\r
-            listSize--;\r
-            int counter = 0;\r
-            int progressSplit = listSize / 100;\r
-\r
-            while (counter <= listSize)\r
+            for (int i = 0; i < list_queue.Items.Count; i++)\r
             {\r
-                String query = list_queue.Items[0].ToString();\r
-\r
+                string query = list_queue.Items[i] as string;\r
                 Process hbProc = new Process();\r
                 hbProc.StartInfo.FileName = "hbcli.exe";\r
                 hbProc.StartInfo.Arguments = query;\r
@@ -88,8 +83,8 @@ namespace Handbrake
                 hbProc.Start();\r
 \r
                 // Set the process Priority\r
-                string priority = Properties.Settings.Default.processPriority;\r
-                switch (priority)\r
+\r
+                switch (Properties.Settings.Default.processPriority)\r
                 {\r
                     case "Realtime":\r
                         hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
@@ -113,22 +108,22 @@ namespace Handbrake
 \r
                 hbProc.WaitForExit();\r
                 hbProc.Close();\r
-                counter++;\r
 \r
-                updateUIElements(progressSplit);\r
+                updateUIElements();\r
             }\r
         }\r
 \r
-        private void updateUIElements(int progressSplit)\r
+        private void updateUIElements()\r
         {\r
             if (this.InvokeRequired)\r
             {\r
-                this.BeginInvoke(new ProgressUpdateHandler(updateUIElements), new object[] { progressSplit });\r
+                this.BeginInvoke(new ProgressUpdateHandler(updateUIElements));\r
                 return;\r
             }\r
 \r
-            this.list_queue.Items.Remove(0);\r
-            progressBar.Value = progressBar.Value + progressSplit;\r
+            this.list_queue.Items.RemoveAt(0);\r
+            progressBar.PerformStep();\r
+            lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);\r
             progressBar.Update();\r
         }\r
     }\r