From 9c138236af326852e383d680cd63ec20dbc38d0c Mon Sep 17 00:00:00 2001 From: brianmario Date: Sun, 15 Jul 2007 21:05:49 +0000 Subject: [PATCH] WinGui: added initial CLI call managment class (work in progress) 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 | 20 ++++++++++++++++++++ win/C#/HandBrakeCS.csproj | 1 + win/C#/Parsing/Title.cs | 2 +- win/C#/frmQueue.cs | 29 ++++++++++++----------------- 4 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 win/C#/CLI/Manager.cs diff --git a/win/C#/CLI/Manager.cs b/win/C#/CLI/Manager.cs new file mode 100644 index 00000000..ac20609a --- /dev/null +++ b/win/C#/CLI/Manager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; + +namespace Handbrake.CLI +{ + /// + /// still workin on this + /// + class Manager + { + private static Queue m_processQueue = new Queue(); + + public static void Enqueue(object s) + { + //TODO: create new Process object from passed + } + } +} diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 6dc73b4f..235cf276 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -37,6 +37,7 @@ + Form diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index fab287b1..d1ccd8a0 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -135,7 +135,7 @@ namespace Handbrake.Parsing public override string ToString() { - return string.Format("{0} ({1}:{2}:{3})", this.m_titleNumber, this.m_duration.Hours, + return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.m_titleNumber, this.m_duration.Hours, this.m_duration.Minutes, this.m_duration.Seconds); } diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 8d915760..f9f59fee 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -12,7 +12,7 @@ namespace Handbrake { public partial class frmQueue : Form { - private delegate void ProgressUpdateHandler(int progressSplit); + private delegate void ProgressUpdateHandler(); public frmQueue() { @@ -66,21 +66,16 @@ namespace Handbrake { progressBar.Value = 0; lbl_progressValue.Text = "0 %"; + progressBar.Step = 100 / list_queue.Items.Count; progressBar.Update(); ThreadPool.QueueUserWorkItem(startProc); } private void startProc(object state) { - int listSize = list_queue.Items.Count; - listSize--; - int counter = 0; - int progressSplit = listSize / 100; - - while (counter <= listSize) + for (int i = 0; i < list_queue.Items.Count; i++) { - String query = list_queue.Items[0].ToString(); - + string query = list_queue.Items[i] as string; Process hbProc = new Process(); hbProc.StartInfo.FileName = "hbcli.exe"; hbProc.StartInfo.Arguments = query; @@ -88,8 +83,8 @@ namespace Handbrake hbProc.Start(); // Set the process Priority - string priority = Properties.Settings.Default.processPriority; - switch (priority) + + switch (Properties.Settings.Default.processPriority) { case "Realtime": hbProc.PriorityClass = ProcessPriorityClass.RealTime; @@ -113,22 +108,22 @@ namespace Handbrake hbProc.WaitForExit(); hbProc.Close(); - counter++; - updateUIElements(progressSplit); + updateUIElements(); } } - private void updateUIElements(int progressSplit) + private void updateUIElements() { if (this.InvokeRequired) { - this.BeginInvoke(new ProgressUpdateHandler(updateUIElements), new object[] { progressSplit }); + this.BeginInvoke(new ProgressUpdateHandler(updateUIElements)); return; } - this.list_queue.Items.Remove(0); - progressBar.Value = progressBar.Value + progressSplit; + this.list_queue.Items.RemoveAt(0); + progressBar.PerformStep(); + lbl_progressValue.Text = string.Format("{0} %", progressBar.Value); progressBar.Update(); } } -- 2.11.0