summaryrefslogtreecommitdiffstats
path: root/win/C#/frmQueue.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-12-15 12:58:04 +0000
committersr55 <[email protected]>2008-12-15 12:58:04 +0000
commit0137a81794777bc60e5dd34ea1af2b8336971a9d (patch)
tree6de8ca518a7b1d7f04f0a3695ad218f2c9d0c036 /win/C#/frmQueue.cs
parent213f5a897b6a9cf5d2ce9a84c39455e3590ada88 (diff)
WinGui:
- MainWindow now uses the Queue for encoding. Essentially works the same as the MacGUI. You start an encode in either window, and the other shows the encoding status. This prevents users from starting 2 encodes at once (1 Queue, 1 Main Window) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2032 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmQueue.cs')
-rw-r--r--win/C#/frmQueue.cs82
1 files changed, 49 insertions, 33 deletions
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index 765c940b7..86ae4b5bd 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -49,7 +49,10 @@ namespace Handbrake
if (progressBar.Value != 0)
{
progressBar.Value = 0;
- progressBar.Step = 100 / queue.count();
+ if (queue.count() == 0)
+ progressBar.Step = 100;
+ else
+ progressBar.Step = 100 / queue.count();
progressBar.PerformStep();
lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);
}
@@ -67,6 +70,28 @@ namespace Handbrake
return true;
}
+ /// <summary>
+ /// This disables encoding from the queue when a single encode from the main window is running.
+ /// </summary>
+ public void frmMain_encode()
+ {
+ cancel = false;
+ // Start the encode
+ try
+ {
+ if (queue.count() != 0)
+ {
+ Thread theQ = new Thread(startProc);
+ theQ.IsBackground = true;
+ theQ.Start();
+ }
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+
// Redraw's the queue with the latest data from the Queue class
private void redrawQueue()
{
@@ -111,6 +136,7 @@ namespace Handbrake
private void btn_encode_Click(object sender, EventArgs e)
{
mainWindow.setLastAction("encode");
+ mainWindow.setEncodeStatus(1);
if (queue.count() != 0)
{
@@ -124,10 +150,14 @@ namespace Handbrake
if (queue.count() != 0)
{
// Setup or reset some values
+ btn_encode.Enabled = false;
btn_stop.Visible = true;
progressBar.Value = 0;
lbl_progressValue.Text = "0 %";
- progressBar.Step = 100 / queue.count();
+ if (queue.count() == 0)
+ progressBar.Step = 100;
+ else
+ progressBar.Step = 100 / queue.count();
Thread theQ = new Thread(startProc);
theQ.IsBackground = true;
theQ.Start();
@@ -151,7 +181,8 @@ namespace Handbrake
queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file
setEncValue();
- updateUIElements();
+ if (this.Created)
+ updateUIElements();
hbProc = cliObj.runCli(this, query);
@@ -171,6 +202,7 @@ namespace Handbrake
}
resetQueue();
+ mainWindow.setEncodeStatus(0); // Tell the main window encodes have finished.
// After the encode is done, we may want to shutdown, suspend etc.
cliObj.afterEncodeAction();
@@ -296,7 +328,7 @@ namespace Handbrake
}
}
- // Move an item up the Queue
+ // Queue Management
private void btn_up_Click(object sender, EventArgs e)
{
if (list_queue.SelectedIndices.Count != 0)
@@ -313,8 +345,6 @@ namespace Handbrake
list_queue.Select();
}
}
-
- // Move an item down the Queue
private void btn_down_Click(object sender, EventArgs e)
{
if (list_queue.SelectedIndices.Count != 0)
@@ -331,8 +361,6 @@ namespace Handbrake
list_queue.Select();
}
}
-
- // Remove an item from the queue
private void btn_delete_Click(object sender, EventArgs e)
{
if (list_queue.SelectedIndices.Count != 0)
@@ -343,8 +371,20 @@ namespace Handbrake
lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";
}
}
+ private void list_queue_deleteKey(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Delete)
+ {
+ if (list_queue.SelectedIndices.Count != 0)
+ {
+ queue.remove(list_queue.SelectedIndices[0]);
+ queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file
+ redrawQueue();
+ }
+ }
+ }
- // Generate a Saveable batch script on the users request
+ // Queue Import/Export Features
private void mnu_batch_Click(object sender, EventArgs e)
{
SaveFile.FileName = "";
@@ -353,8 +393,6 @@ namespace Handbrake
if (SaveFile.FileName != String.Empty)
queue.writeBatchScript(SaveFile.FileName);
}
-
- // Export the HandBrake Queue to a file.
private void mnu_export_Click(object sender, EventArgs e)
{
SaveFile.FileName = "";
@@ -363,8 +401,6 @@ namespace Handbrake
if (SaveFile.FileName != String.Empty)
queue.write2disk(SaveFile.FileName);
}
-
- // Import an exported queue
private void mnu_import_Click(object sender, EventArgs e)
{
OpenFile.FileName = "";
@@ -374,26 +410,6 @@ namespace Handbrake
redrawQueue();
}
- // Delete a selected item on the queue, if the delete key is pressed.
- private void list_queue_deleteKey(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Delete)
- {
- if (list_queue.SelectedIndices.Count != 0)
- {
- queue.remove(list_queue.SelectedIndices[0]);
- queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file
- redrawQueue();
- }
- }
- }
-
- // Hide's the window from the users view.
- private void btn_Close_Click(object sender, EventArgs e)
- {
- this.Hide();
- }
-
// Hide's the window when the user tries to "x" out of the window instead of closing it.
protected override void OnClosing(CancelEventArgs e)
{