OSDN Git Service

WinGui:
authorbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 18 Jul 2007 19:24:04 +0000 (19:24 +0000)
committerbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 18 Jul 2007 19:24:04 +0000 (19:24 +0000)
added OnScanProgress event to Parser class which is raised upon noticing "Scanning title # of #..." in the output
added progress bar to frmReadDVD to give better visual notification of scan progress

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

win/C#/Parsing/Parser.cs
win/C#/frmReadDVD.Designer.cs
win/C#/frmReadDVD.cs

index 8c3c24b..ef6476f 100644 (file)
@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;\r
 using System.Text;\r
 using System.IO;\r
+using System.Text.RegularExpressions;\r
 \r
 namespace Handbrake.Parsing\r
 {\r
@@ -12,6 +13,8 @@ namespace Handbrake.Parsing
     /// <param name="Data">The data parsed from the stream</param>\r
     public delegate void DataReadEventHandler(object Sender, string Data);\r
 \r
+    public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);\r
+\r
     /// <summary>\r
     /// A simple wrapper around a StreamReader to keep track of the entire output from a cli process\r
     /// </summary>\r
@@ -39,6 +42,8 @@ namespace Handbrake.Parsing
         /// </summary>\r
         public static event DataReadEventHandler OnReadToEnd;\r
 \r
+        public static event ScanProgressEventHandler OnScanProgress;\r
+\r
         /// <summary>\r
         /// Default constructor for this object\r
         /// </summary>\r
@@ -52,10 +57,15 @@ namespace Handbrake.Parsing
         {\r
             string tmp = base.ReadLine();\r
             this.m_buffer += tmp;\r
+            Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
             if (OnReadLine != null)\r
             {\r
                 OnReadLine(this, tmp);\r
             }\r
+            if (m.Success && OnScanProgress != null)\r
+            {\r
+                OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+            }\r
             return tmp;\r
         }\r
 \r
index 18bbd36..40ab0fc 100644 (file)
@@ -33,14 +33,14 @@ namespace Handbrake
             this.btn_ok = new System.Windows.Forms.Button();\r
             this.Label3 = new System.Windows.Forms.Label();\r
             this.Label2 = new System.Windows.Forms.Label();\r
-            this.lbl_status = new System.Windows.Forms.Label();\r
+            this.scanProgress = new System.Windows.Forms.ProgressBar();\r
             this.SuspendLayout();\r
             // \r
             // lbl_pressOk\r
             // \r
             this.lbl_pressOk.AutoSize = true;\r
             this.lbl_pressOk.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_pressOk.Location = new System.Drawing.Point(66, 60);\r
+            this.lbl_pressOk.Location = new System.Drawing.Point(216, 56);\r
             this.lbl_pressOk.Name = "lbl_pressOk";\r
             this.lbl_pressOk.Size = new System.Drawing.Size(178, 13);\r
             this.lbl_pressOk.TabIndex = 29;\r
@@ -82,23 +82,20 @@ namespace Handbrake
             this.Label2.TabIndex = 26;\r
             this.Label2.Text = "Status:";\r
             // \r
-            // lbl_status\r
+            // scanProgress\r
             // \r
-            this.lbl_status.AutoSize = true;\r
-            this.lbl_status.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_status.Location = new System.Drawing.Point(66, 41);\r
-            this.lbl_status.Name = "lbl_status";\r
-            this.lbl_status.Size = new System.Drawing.Size(178, 13);\r
-            this.lbl_status.TabIndex = 30;\r
-            this.lbl_status.Text = "Processing.... Please Wait!";\r
-            this.lbl_status.Visible = false;\r
+            this.scanProgress.Location = new System.Drawing.Point(22, 51);\r
+            this.scanProgress.Name = "scanProgress";\r
+            this.scanProgress.Size = new System.Drawing.Size(361, 23);\r
+            this.scanProgress.TabIndex = 30;\r
+            this.scanProgress.Visible = false;\r
             // \r
             // frmReadDVD\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(473, 86);\r
-            this.Controls.Add(this.lbl_status);\r
+            this.Controls.Add(this.scanProgress);\r
             this.Controls.Add(this.lbl_pressOk);\r
             this.Controls.Add(this.btn_ok);\r
             this.Controls.Add(this.Label3);\r
@@ -119,6 +116,6 @@ namespace Handbrake
         internal System.Windows.Forms.Button btn_ok;\r
         internal System.Windows.Forms.Label Label3;\r
         internal System.Windows.Forms.Label Label2;\r
-        internal System.Windows.Forms.Label lbl_status;\r
+        private System.Windows.Forms.ProgressBar scanProgress;\r
     }\r
 }
\ No newline at end of file
index 2958bdf..eaecf82 100644 (file)
@@ -27,13 +27,15 @@ namespace Handbrake
             this.inputFile = inputFile;\r
             this.mainWindow = parent;\r
             this.dvdInfo = dvdInfoWindow;\r
+            Parsing.Parser.OnScanProgress += Parser_OnScanProgress;\r
         }\r
 \r
         private void btn_ok_Click(object sender, EventArgs e)\r
         {\r
-            lbl_status.Visible = true;\r
             btn_ok.Enabled = false;\r
             lbl_pressOk.Visible = false;\r
+            scanProgress.Value = 0;\r
+            scanProgress.Visible = true;\r
             // throw cli call and parsing on it's own thread\r
             ThreadPool.QueueUserWorkItem(startProc);\r
         }\r
@@ -71,5 +73,15 @@ namespace Handbrake
             updateUIElements();\r
         }\r
 \r
+        private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)\r
+        {\r
+            if (this.InvokeRequired)\r
+            {\r
+                this.BeginInvoke(new Parsing.ScanProgressEventHandler(Parser_OnScanProgress), new object[] { Sender, CurrentTitle, TitleCount });\r
+                return;\r
+            }\r
+            this.scanProgress.Value = Convert.ToInt32(Convert.ToDouble(CurrentTitle) / Convert.ToDouble(TitleCount) * 100) + 1;\r
+        }\r
+\r
     }\r
 }
\ No newline at end of file