using System.Collections.Generic;\r
using System.Text;\r
using System.IO;\r
+using System.Text.RegularExpressions;\r
\r
namespace Handbrake.Parsing\r
{\r
/// <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
/// </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
{\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
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
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
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
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
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