]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Fri, 13 Jul 2007 23:47:38 +0000 (23:47 +0000)
committersr55 <sr55.hb@outlook.com>
Fri, 13 Jul 2007 23:47:38 +0000 (23:47 +0000)
- Change toString method in Parsing for timestamp return. removed h,m,s letters.

- Commented out some parsing code that is not needed at this stage.

- Most of the work for the Queue has now been done. Only some cross-thread UI element changes need done.

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

win/C#/Parsing/Chapter.cs
win/C#/Parsing/Title.cs
win/C#/frmMain.cs
win/C#/frmQueue.Designer.cs
win/C#/frmQueue.cs
win/C#/frmReadDVD.cs

index 630ab090542c55fa49a315c711c1fe80e58311a8..0715e0cc5742ea8134c7ccc29f4fc30e8fa07697 100644 (file)
@@ -16,7 +16,7 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        private int[] m_cellRange;\r
+        /*private int[] m_cellRange;\r
         public int[] CellRange\r
         {\r
             get\r
@@ -32,7 +32,7 @@ namespace Handbrake.Parsing
             {\r
                 return this.m_blocks;\r
             }\r
-        }\r
+        }*/\r
 \r
         private TimeSpan m_duration;\r
         public TimeSpan Duration\r
@@ -51,8 +51,8 @@ namespace Handbrake.Parsing
                 Chapter thisChapter = new Chapter();\r
                 string[] splitter = curLine.Split(new string[] { "    + ", ": cells ", ", ", " blocks, duration ", "->" }, StringSplitOptions.RemoveEmptyEntries);\r
                 thisChapter.m_chapterNumber = int.Parse(splitter[0]);\r
-                thisChapter.m_cellRange = new int[2] { int.Parse(splitter[1]), int.Parse(splitter[2]) };\r
-                thisChapter.m_blocks = int.Parse(splitter[3]);\r
+                //thisChapter.m_cellRange = new int[2] { int.Parse(splitter[1]), int.Parse(splitter[2]) };\r
+                //thisChapter.m_blocks = int.Parse(splitter[3]);\r
                 thisChapter.m_duration = TimeSpan.Parse(splitter[4]);\r
                 return thisChapter;\r
             }\r
index 99b32cd7062caf9927ee5c3cd1f299c91b5e94a7..fab287b18649fe0868dd130b9d9ebe79f1b2fbe4 100644 (file)
@@ -35,7 +35,7 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        private int m_vts;\r
+        /*private int m_vts;\r
         public int Vts\r
         {\r
             get\r
@@ -69,7 +69,7 @@ namespace Handbrake.Parsing
             {\r
                 return this.m_blockCount;\r
             }\r
-        }\r
+        }*/\r
 \r
         private int m_titleNumber;\r
         public int TitleNumber\r
@@ -107,14 +107,14 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        private float m_fps;\r
+        /*private float m_fps;\r
         public float Fps\r
         {\r
             get\r
             {\r
                 return this.m_fps;\r
             }\r
-        }\r
+        }*/\r
 \r
         private int[] m_autoCrop;\r
         public int[] AutoCropDimensions\r
@@ -130,12 +130,12 @@ namespace Handbrake.Parsing
             this.m_audioTracks = new List<AudioTrack>();\r
             this.m_chapters = new List<Chapter>();\r
             this.m_subtitles = new List<Subtitle>();\r
-            this.m_cellRange = new int[2];\r
+            //this.m_cellRange = new int[2];\r
         }\r
 \r
         public override string ToString()\r
         {\r
-            return string.Format("{0} - {1}h{2}m{3}s", this.m_titleNumber, this.m_duration.Hours, \r
+            return string.Format("{0} ({1}:{2}:{3})", this.m_titleNumber, this.m_duration.Hours, \r
                 this.m_duration.Minutes, this.m_duration.Seconds);\r
         }\r
 \r
@@ -152,13 +152,13 @@ namespace Handbrake.Parsing
             thisTitle.m_titleNumber = int.Parse(curLine.Substring(curLine.Length - 2, 1));\r
             curLine = output.ReadLine();\r
             string[] splitter = curLine.Split(',');\r
-            thisTitle.m_vts = int.Parse(splitter[0].Substring(8));\r
-            thisTitle.m_ttn = int.Parse(splitter[1].Substring(5));\r
+            //thisTitle.m_vts = int.Parse(splitter[0].Substring(8));\r
+            //thisTitle.m_ttn = int.Parse(splitter[1].Substring(5));\r
             splitter = splitter[2].Trim().Split(' ', '(', ')');\r
-            thisTitle.m_blockCount = int.Parse(splitter[3]);\r
+            //thisTitle.m_blockCount = int.Parse(splitter[3]);\r
             splitter = splitter[1].Split('-', '>');\r
-            thisTitle.m_cellRange[0] = int.Parse(splitter[0]);\r
-            thisTitle.m_cellRange[1] = int.Parse(splitter[2]);\r
+            //thisTitle.m_cellRange[0] = int.Parse(splitter[0]);\r
+            //thisTitle.m_cellRange[1] = int.Parse(splitter[2]);\r
             curLine = output.ReadLine();\r
             splitter = curLine.Split(new string[] { "  + duration: " }, StringSplitOptions.RemoveEmptyEntries);\r
             thisTitle.m_duration = TimeSpan.Parse(splitter[0]);\r
@@ -166,7 +166,7 @@ namespace Handbrake.Parsing
             splitter = curLine.Split(new string[] { "  + size: ", "aspect: ", ", ", " fps", "x" }, StringSplitOptions.RemoveEmptyEntries);\r
             thisTitle.m_resolution = new Size(int.Parse(splitter[0]), int.Parse(splitter[1]));\r
             thisTitle.m_aspectRatio = float.Parse(splitter[2].ToString());\r
-            thisTitle.m_fps = float.Parse(splitter[3].ToString());\r
+            //thisTitle.m_fps = float.Parse(splitter[3].ToString());\r
             curLine = output.ReadLine();\r
             splitter = curLine.Split(new string[] { "  + autocrop: ", "/" }, StringSplitOptions.RemoveEmptyEntries);\r
             thisTitle.m_autoCrop = new int[4] { int.Parse(splitter[0]), int.Parse(splitter[1]), int.Parse(splitter[2]), int.Parse(splitter[3]) };\r
index 504179e0e58c80c04e4ca46aeea0635d05cfcf55..80900e522dd43ddee0af9769c4ae8c72420bab8a 100644 (file)
@@ -133,7 +133,6 @@ namespace Handbrake
         }\r
 \r
 \r
-\r
         // --------------------------------------------------------------\r
         // The Menu Bar\r
         // --------------------------------------------------------------\r
@@ -317,9 +316,7 @@ namespace Handbrake
         // TOOLS MENU --------------------------------------------------------------\r
         private void mnu_encode_Click(object sender, EventArgs e)\r
         {\r
-            string query = ""; // temp fix for bug here.\r
-            Form Queue = new frmQueue(query);\r
-            Queue.ShowDialog();\r
+            //Queue.ShowDialog();\r
         }\r
 \r
         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
@@ -507,7 +504,6 @@ namespace Handbrake
                     Form frmReadDVD = new frmReadDVD(filename, this);\r
                     frmReadDVD.ShowDialog();\r
                 }\r
-\r
             }\r
             else\r
             {\r
@@ -519,10 +515,7 @@ namespace Handbrake
                     Form frmReadDVD = new frmReadDVD(filename, this);\r
                     frmReadDVD.ShowDialog();\r
                 }\r
-\r
-            }\r
-\r
-                \r
+            }  \r
         }\r
 \r
         private void btn_destBrowse_Click(object sender, EventArgs e)\r
@@ -556,12 +549,15 @@ 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
             String query = GenerateTheQuery();\r
-            MessageBox.Show(query);\r
-            Form Queue = new frmQueue(query);\r
-            Queue.Show();\r
+            queueWindow.list_queue.Items.Add(query);\r
+            queueWindow.Show();\r
         }\r
 \r
         private void btn_encode_Click(object sender, EventArgs e)\r
index cfa3e64514d9ebc845a0175c563bc294497a4118..ccef85ce0af24dabd851d75b3e76c3e9e3815cd9 100644 (file)
@@ -36,6 +36,9 @@ namespace Handbrake
             this.btn_q_encoder = new System.Windows.Forms.Button();\r
             this.list_queue = new System.Windows.Forms.ListBox();\r
             this.btn_Close = new System.Windows.Forms.Button();\r
+            this.progressBar = new System.Windows.Forms.ProgressBar();\r
+            this.label2 = new System.Windows.Forms.Label();\r
+            this.lbl_progressValue = new System.Windows.Forms.Label();\r
             this.SuspendLayout();\r
             // \r
             // btn_down\r
@@ -52,6 +55,7 @@ namespace Handbrake
             this.btn_down.TabStop = false;\r
             this.btn_down.Text = "Move Down";\r
             this.btn_down.UseVisualStyleBackColor = false;\r
+            this.btn_down.Click += new System.EventHandler(this.btn_down_Click);\r
             // \r
             // btn_up\r
             // \r
@@ -67,6 +71,7 @@ namespace Handbrake
             this.btn_up.TabStop = false;\r
             this.btn_up.Text = "Move Up";\r
             this.btn_up.UseVisualStyleBackColor = false;\r
+            this.btn_up.Click += new System.EventHandler(this.btn_up_Click);\r
             // \r
             // btn_delete\r
             // \r
@@ -82,6 +87,7 @@ namespace Handbrake
             this.btn_delete.TabStop = false;\r
             this.btn_delete.Text = "Delete Item";\r
             this.btn_delete.UseVisualStyleBackColor = false;\r
+            this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click);\r
             // \r
             // Label1\r
             // \r
@@ -106,6 +112,7 @@ namespace Handbrake
             this.btn_q_encoder.TabStop = false;\r
             this.btn_q_encoder.Text = "Encode Video(s)";\r
             this.btn_q_encoder.UseVisualStyleBackColor = false;\r
+            this.btn_q_encoder.Click += new System.EventHandler(this.btn_q_encoder_Click);\r
             // \r
             // list_queue\r
             // \r
@@ -113,7 +120,7 @@ namespace Handbrake
             this.list_queue.FormattingEnabled = true;\r
             this.list_queue.Location = new System.Drawing.Point(10, 37);\r
             this.list_queue.Name = "list_queue";\r
-            this.list_queue.Size = new System.Drawing.Size(630, 327);\r
+            this.list_queue.Size = new System.Drawing.Size(630, 288);\r
             this.list_queue.TabIndex = 28;\r
             // \r
             // btn_Close\r
@@ -132,11 +139,40 @@ namespace Handbrake
             this.btn_Close.UseVisualStyleBackColor = false;\r
             this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click);\r
             // \r
+            // progressBar\r
+            // \r
+            this.progressBar.Location = new System.Drawing.Point(74, 331);\r
+            this.progressBar.Name = "progressBar";\r
+            this.progressBar.Size = new System.Drawing.Size(513, 23);\r
+            this.progressBar.TabIndex = 34;\r
+            // \r
+            // label2\r
+            // \r
+            this.label2.AutoSize = true;\r
+            this.label2.Location = new System.Drawing.Point(12, 336);\r
+            this.label2.Name = "label2";\r
+            this.label2.Size = new System.Drawing.Size(51, 13);\r
+            this.label2.TabIndex = 35;\r
+            this.label2.Text = "Progress:";\r
+            // \r
+            // lbl_progressValue\r
+            // \r
+            this.lbl_progressValue.AutoSize = true;\r
+            this.lbl_progressValue.Location = new System.Drawing.Point(593, 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
+            this.lbl_progressValue.Text = "0 %";\r
+            // \r
             // frmQueue\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
             this.ClientSize = new System.Drawing.Size(651, 404);\r
+            this.ControlBox = false;\r
+            this.Controls.Add(this.lbl_progressValue);\r
+            this.Controls.Add(this.label2);\r
+            this.Controls.Add(this.progressBar);\r
             this.Controls.Add(this.btn_down);\r
             this.Controls.Add(this.btn_up);\r
             this.Controls.Add(this.btn_delete);\r
@@ -148,7 +184,6 @@ namespace Handbrake
             this.Name = "frmQueue";\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
             this.Text = "Queue";\r
-            this.Load += new System.EventHandler(this.frmQueue_Load);\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -163,5 +198,8 @@ namespace Handbrake
         internal System.Windows.Forms.Button btn_q_encoder;\r
         internal System.Windows.Forms.ListBox list_queue;\r
         internal System.Windows.Forms.Button btn_Close;\r
+        private System.Windows.Forms.ProgressBar progressBar;\r
+        private System.Windows.Forms.Label label2;\r
+        private System.Windows.Forms.Label lbl_progressValue;\r
     }\r
 }
\ No newline at end of file
index e806ad87963369707964626f5278487fa1ff971e..14353319665ce41186cd9635e0edd4b5307ae695 100644 (file)
@@ -5,36 +5,100 @@ using System.Data;
 using System.Drawing;\r
 using System.Text;\r
 using System.Windows.Forms;\r
+using System.Threading;\r
+using System.Diagnostics;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmQueue : Form\r
     {\r
-        private string query = "";\r
+        private frmQueue thisWindow;\r
 \r
-        public frmQueue(string query)\r
+        public frmQueue()\r
         {\r
             InitializeComponent();\r
-            this.query = query;\r
         }\r
 \r
-        public void addItem(String item)\r
+        private void btn_Close_Click(object sender, EventArgs e)\r
         {\r
-            list_queue.Items.Add(item);\r
-            MessageBox.Show("test");\r
+            this.Hide();\r
         }\r
 \r
-        private void btn_Close_Click(object sender, EventArgs e)\r
+        private void btn_delete_Click(object sender, EventArgs e)\r
+        {\r
+            list_queue.Items.Remove(list_queue.SelectedItem);\r
+        }\r
+\r
+        private void btn_up_Click(object sender, EventArgs e)\r
+        {\r
+            int count = list_queue.Items.Count;\r
+            int itemToMove = list_queue.SelectedIndex;\r
+            int previousItemint = 0; \r
+            String previousItem = "";\r
+\r
+             if (itemToMove > 0){\r
+                previousItemint = itemToMove - 1;\r
+                previousItem = list_queue.Items[previousItemint].ToString();\r
+                list_queue.Items[previousItemint] = list_queue.Items[itemToMove];\r
+                list_queue.Items[itemToMove] = previousItem;\r
+                list_queue.SelectedIndex = list_queue.SelectedIndex - 1;\r
+            }\r
+        }\r
+\r
+        private void btn_down_Click(object sender, EventArgs e)\r
         {\r
-            this.Close();\r
+            int count = list_queue.Items.Count;\r
+            int itemToMove = list_queue.SelectedIndex;\r
+            int itemAfterInt = 0; \r
+            String itemAfter = "";\r
+\r
+            if (itemToMove < (count - 1))\r
+            {\r
+                itemAfterInt = itemToMove + 1;\r
+                itemAfter = list_queue.Items[itemAfterInt].ToString();\r
+                list_queue.Items[itemAfterInt] = list_queue.Items[itemToMove];\r
+                list_queue.Items[itemToMove] = itemAfter;\r
+                list_queue.SelectedIndex = list_queue.SelectedIndex + 1;\r
+            }\r
         }\r
 \r
-        private void frmQueue_Load(object sender, EventArgs e)\r
+        private void btn_q_encoder_Click(object sender, EventArgs e)\r
         {\r
-            addItem(query);\r
-            MessageBox.Show("test");\r
+            progressBar.Value = 0;\r
+            lbl_progressValue.Text = "0 %";\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
+            {\r
+                String query = list_queue.Items[0].ToString();\r
 \r
+                Process hbProc = new Process();\r
+                hbProc.StartInfo.FileName = "hbcli.exe";\r
+                hbProc.StartInfo.Arguments = query;\r
+                hbProc.StartInfo.UseShellExecute = false;\r
+                hbProc.Start();\r
+                hbProc.WaitForExit();\r
+                hbProc.Close();\r
+                counter++;\r
+                //updateUIElements(progressSplit);\r
+            }\r
+        }\r
+\r
+        private void updateUIElements(int progressSplit)\r
+        {\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
+        }\r
     }\r
 }
\ No newline at end of file
index 1c18ce7a2d8f622c17b3116fcbeb6b4475a0f916..070cb5421dcb9aa3c4554cbed9b82a9a78026803 100644 (file)
@@ -33,7 +33,7 @@ namespace Handbrake
             // throw cli call and parsing on it's own thread\r
             ThreadPool.QueueUserWorkItem(startProc);\r
         }\r
-\r
+     \r
         private void updateUIElements()\r
         {\r
             if (this.InvokeRequired)\r