From: sr55 Date: Tue, 31 Jul 2007 18:31:06 +0000 (+0000) Subject: WinGui: X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=024b28c86d806e888021016aafe7932f713ff703;p=handbrake-jp%2Fhandbrake-jp-git.git WinGui: - Few queue bugs fixed. - Active queueing now works properly. Items can be added on the fly. DVD's can be scanned on the fly while the there is an encode process already going etc. - Fixed a potential unhandled exception in the DVD information window. git-svn-id: svn://localhost/HandBrake/trunk@770 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/C#/frmDvdInfo.cs b/win/C#/frmDvdInfo.cs index 7f503227..3b2cfd87 100644 --- a/win/C#/frmDvdInfo.cs +++ b/win/C#/frmDvdInfo.cs @@ -20,18 +20,25 @@ namespace Handbrake InitializeComponent(); this.rtf_dvdInfo.Text = string.Empty; - string appPath = Application.StartupPath.ToString(); - appPath = appPath + "\\"; - StreamReader sr = new StreamReader(appPath + "dvdinfo.dat"); - - string line = sr.ReadLine(); - - while (line != null) + try { - this.rtf_dvdInfo.AppendText(line + System.Environment.NewLine); - line = sr.ReadLine(); + string appPath = Application.StartupPath.ToString(); + appPath = appPath + "\\"; + StreamReader sr = new StreamReader(appPath + "dvdinfo.dat"); + + string line = sr.ReadLine(); + + while (line != null) + { + this.rtf_dvdInfo.AppendText(line + System.Environment.NewLine); + line = sr.ReadLine(); + } + sr.Close(); + } + catch (Exception) + { + // Don't do anything } - sr.Close(); } /*public void HandleParsedData(object Sender, string Data) diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 69864827..fc0c3f50 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -1075,7 +1075,7 @@ namespace Handbrake this.TabPage3.Location = new System.Drawing.Point(4, 22); this.TabPage3.Name = "TabPage3"; this.TabPage3.Padding = new System.Windows.Forms.Padding(3); - this.TabPage3.Size = new System.Drawing.Size(639, 242); + this.TabPage3.Size = new System.Drawing.Size(622, 242); this.TabPage3.TabIndex = 2; this.TabPage3.Text = "Video Settings"; // @@ -1317,7 +1317,7 @@ namespace Handbrake this.TabPage2.Location = new System.Drawing.Point(4, 22); this.TabPage2.Name = "TabPage2"; this.TabPage2.Padding = new System.Windows.Forms.Padding(3); - this.TabPage2.Size = new System.Drawing.Size(639, 242); + this.TabPage2.Size = new System.Drawing.Size(622, 242); this.TabPage2.TabIndex = 3; this.TabPage2.Text = "Audio Settings"; // @@ -1470,7 +1470,7 @@ namespace Handbrake this.h264Tab.Location = new System.Drawing.Point(4, 22); this.h264Tab.Name = "h264Tab"; this.h264Tab.Padding = new System.Windows.Forms.Padding(3); - this.h264Tab.Size = new System.Drawing.Size(639, 242); + this.h264Tab.Size = new System.Drawing.Size(622, 242); this.h264Tab.TabIndex = 5; this.h264Tab.Text = "H.264"; // @@ -1557,7 +1557,7 @@ namespace Handbrake this.TabPage6.Location = new System.Drawing.Point(4, 22); this.TabPage6.Name = "TabPage6"; this.TabPage6.Padding = new System.Windows.Forms.Padding(3); - this.TabPage6.Size = new System.Drawing.Size(639, 242); + this.TabPage6.Size = new System.Drawing.Size(622, 242); this.TabPage6.TabIndex = 6; this.TabPage6.Text = "Query Editor"; // diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 1e84ef1f..59e31c53 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -638,8 +638,15 @@ namespace Handbrake { if (text_destination.Text != "" && text_source.Text != "") { - - String query = GenerateTheQuery(); + string query; + if (QueryEditorText.Text == "") + { + query = GenerateTheQuery(); + } + else + { + query = QueryEditorText.Text; + } queueWindow.list_queue.Items.Add(query); queueWindow.Show(); } diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index c0c0a8c8..ee6301ae 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -19,24 +19,90 @@ namespace Handbrake InitializeComponent(); } - private void btn_Close_Click(object sender, EventArgs e) + int initialListCount = 0; + bool started = false; + + + private void btn_q_encoder_Click(object sender, EventArgs e) { - this.Hide(); + progressBar.Value = 0; + lbl_progressValue.Text = "0 %"; + progressBar.Step = 100 / list_queue.Items.Count; + progressBar.Update(); + ThreadPool.QueueUserWorkItem(startProc); } - private void btn_delete_Click(object sender, EventArgs e) + /* + * + * Code to Handle the CLI and updating of the UI as each process is completed. + * + */ + private void startProc(object state) { - list_queue.Items.Remove(list_queue.SelectedItem); + started = true; + initialListCount = list_queue.Items.Count; + for (int i = 0; i < initialListCount; i++) + { + string query = list_queue.Items[0].ToString(); + + Functions.CLI process = new Functions.CLI(); + Process hbProc = process.runCli(this, query, false, false, false, false); + + hbProc.WaitForExit(); + hbProc.Close(); + hbProc.Dispose(); + updateUIElements(); + + if ((initialListCount - i) != (list_queue.Items.Count)) + { + MessageBox.Show("Added an Item"); + initialListCount++; + } + } + started = false; + resetQueue(); + MessageBox.Show("Encode Queue Completed!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + } + + private void updateUIElements() + { + if (this.InvokeRequired) + { + this.BeginInvoke(new ProgressUpdateHandler(updateUIElements)); + return; + } + this.list_queue.Items.RemoveAt(0); + progressBar.PerformStep(); + lbl_progressValue.Text = string.Format("{0} %", progressBar.Value); + progressBar.Update(); } + private void resetQueue() + { + if (this.InvokeRequired) + { + this.BeginInvoke(new ProgressUpdateHandler(resetQueue)); + return; + } + lbl_progressValue.Text = "0 %"; + progressBar.Value = 0; + progressBar.Update(); + } + + /* + * + * Code to Re-arrange / Delete items from the Queue + * + */ private void btn_up_Click(object sender, EventArgs e) { int count = list_queue.Items.Count; int itemToMove = list_queue.SelectedIndex; - int previousItemint = 0; + int previousItemint = 0; String previousItem = ""; - if (itemToMove > 0){ + if (itemToMove > 0) + { previousItemint = itemToMove - 1; previousItem = list_queue.Items[previousItemint].ToString(); list_queue.Items[previousItemint] = list_queue.Items[itemToMove]; @@ -49,7 +115,7 @@ namespace Handbrake { int count = list_queue.Items.Count; int itemToMove = list_queue.SelectedIndex; - int itemAfterInt = 0; + int itemAfterInt = 0; String itemAfter = ""; if (itemToMove < (count - 1)) @@ -62,52 +128,19 @@ namespace Handbrake } } - private void btn_q_encoder_Click(object sender, EventArgs e) - { - progressBar.Value = 0; - lbl_progressValue.Text = "0 %"; - progressBar.Step = 100 / list_queue.Items.Count; - progressBar.Update(); - ThreadPool.QueueUserWorkItem(startProc); - } - - private void startProc(object state) + private void btn_delete_Click(object sender, EventArgs e) { - int initialListCount = list_queue.Items.Count; - for (int i = 0; i < initialListCount; i++) - { - string query = list_queue.Items[0].ToString(); - - Functions.CLI process = new Functions.CLI(); - Process hbProc = process.runCli(this, query, false, false, false, false); - - hbProc.WaitForExit(); - hbProc.Close(); - hbProc.Dispose(); - - updateUIElements(); - } + list_queue.Items.Remove(list_queue.SelectedItem); + if (started == true) + initialListCount--; } - private void updateUIElements() + /* + * Hide the Queue Window + */ + private void btn_Close_Click(object sender, EventArgs e) { - if (this.InvokeRequired) - { - this.BeginInvoke(new ProgressUpdateHandler(updateUIElements)); - return; - } - this.list_queue.Items.RemoveAt(0); - progressBar.PerformStep(); - lbl_progressValue.Text = string.Format("{0} %", progressBar.Value); - progressBar.Update(); - - if (progressBar.Value == 100) - { - MessageBox.Show("Encode Queue Completed!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); - progressBar.Value = 0; - progressBar.Update(); - lbl_progressValue.Text = "0 %"; - } + this.Hide(); } } } \ No newline at end of file