summaryrefslogtreecommitdiffstats
path: root/win/C#/frmQueue.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-01-03 22:46:52 +0000
committersr55 <[email protected]>2009-01-03 22:46:52 +0000
commit7c7ee204435c13146895355b545d313c1cc7a707 (patch)
tree013c6af3fb9801ddfc112f7561318b3e65c64430 /win/C#/frmQueue.cs
parent0b30a330672919074117c371de7d1fee4ff5cbbc (diff)
WinGui:
- Fixes some bugs/issues with the Queue Windows / Main Window Queue/Encoding tie-in git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2057 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmQueue.cs')
-rw-r--r--win/C#/frmQueue.cs157
1 files changed, 61 insertions, 96 deletions
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index afa9f467e..43f198a86 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -26,7 +26,7 @@ namespace Handbrake
Functions.Encode cliObj = new Functions.Encode();
Boolean paused = false;
Process hbProc = null;
- Queue.Queue queue;
+ Queue.QueueHandler queue;
frmMain mainWindow = null;
Thread theQ;
@@ -40,7 +40,7 @@ namespace Handbrake
/// Initializes the Queue list with the Arraylist from the Queue class
/// </summary>
/// <param name="qw"></param>
- public void setQueue(Queue.Queue qw)
+ public void setQueue(Queue.QueueHandler qw)
{
queue = qw;
redrawQueue();
@@ -60,83 +60,15 @@ namespace Handbrake
}
/// <summary>
- /// This disables encoding from the queue when a single encode from the main window is running.
+ /// Allows frmMain to start an encode.
+ /// Should probably find a cleaner way of doing this.
/// </summary>
public void frmMain_encode()
{
- paused = false;
- // Start the encode
- try
- {
- if (queue.count() != 0)
- {
- // Setup or reset some values
- btn_encode.Enabled = false;
- btn_stop.Visible = true;
-
- Thread theQ = new Thread(startProc);
- theQ.IsBackground = true;
- theQ.Start();
- }
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.ToString());
- }
+ btn_encode_Click(this, null);
}
- public void frmMain_cancelEncode()
- {
- Process[] aProc = Process.GetProcessesByName("HandBrakeCLI");
- Process HandBrakeCLI;
- if (aProc.Length > 0)
- {
- HandBrakeCLI = aProc[0];
- HandBrakeCLI.Kill();
- }
- }
-
- // Redraw's the queue with the latest data from the Queue class
- private void redrawQueue()
- {
- list_queue.Items.Clear();
- List<Queue.QueueItem> theQueue = queue.getQueue();
- foreach (Queue.QueueItem queue_item in theQueue)
- {
- string q_item = queue_item.Query;
- Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);
-
- // Get the DVD Title
- string title = "";
- if (parsed.DVDTitle == 0)
- title = "Auto";
- else
- title = parsed.DVDTitle.ToString();
-
- // Get the DVD Chapters
- string chapters = "";
- if (parsed.DVDChapterStart == 0)
- chapters = "Auto";
- else
- {
- chapters = parsed.DVDChapterStart.ToString();
- if (parsed.DVDChapterFinish != 0)
- chapters = chapters + " - " + parsed.DVDChapterFinish;
- }
-
- ListViewItem item = new ListViewItem();
- item.Text = title; // Title
- item.SubItems.Add(chapters); // Chapters
- item.SubItems.Add(queue_item.Source); // Source
- item.SubItems.Add(queue_item.Destination); // Destination
- item.SubItems.Add(parsed.VideoEncoder); // Video
- item.SubItems.Add(parsed.AudioEncoder1); // Audio
-
- list_queue.Items.Add(item);
- }
- }
-
- // Initializes the encode process
+ // Start and Stop Controls
private void btn_encode_Click(object sender, EventArgs e)
{
if (queue.count() != 0)
@@ -146,7 +78,6 @@ namespace Handbrake
paused = false;
btn_encode.Enabled = false;
btn_stop.Visible = true;
- MessageBox.Show("Encoding will now continue!","Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
@@ -173,6 +104,15 @@ namespace Handbrake
}
}
}
+ private void btn_stop_Click(object sender, EventArgs e)
+ {
+ paused = true;
+ btn_stop.Visible = false;
+ btn_encode.Enabled = true;
+ mainWindow.setEncodeFinished();
+ resetQueue();
+ MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
// Starts the encoding process
private void startProc(object state)
@@ -185,7 +125,7 @@ namespace Handbrake
string query = queue.getNextItemForEncoding();
queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file
- setEncValue();
+ setCurrentEncodeInformation();
if (this.Created)
updateUIElements();
@@ -193,7 +133,7 @@ namespace Handbrake
hbProc.WaitForExit();
cliObj.addCLIQueryToLog(query);
- cliObj.copyLog(query, queue.getLastQuery().Destination);
+ cliObj.copyLog(query, queue.getLastQueryItem().Destination);
hbProc.Close();
hbProc.Dispose();
@@ -217,8 +157,8 @@ namespace Handbrake
}
}
- // Reset's the window to the default state.
- private void resetQueue()
+ // Window Display Management
+ private void resetQueue()
{
try
{
@@ -246,18 +186,45 @@ namespace Handbrake
MessageBox.Show(exc.ToString());
}
}
-
- // Stop's the queue from continuing.
- private void btn_stop_Click(object sender, EventArgs e)
+ private void redrawQueue()
{
- paused = true;
- btn_stop.Visible = false;
- btn_encode.Enabled = true;
- MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
+ list_queue.Items.Clear();
+ List<Queue.QueueItem> theQueue = queue.getQueue();
+ foreach (Queue.QueueItem queue_item in theQueue)
+ {
+ string q_item = queue_item.Query;
+ Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);
+
+ // Get the DVD Title
+ string title = "";
+ if (parsed.DVDTitle == 0)
+ title = "Auto";
+ else
+ title = parsed.DVDTitle.ToString();
+
+ // Get the DVD Chapters
+ string chapters = "";
+ if (parsed.DVDChapterStart == 0)
+ chapters = "Auto";
+ else
+ {
+ chapters = parsed.DVDChapterStart.ToString();
+ if (parsed.DVDChapterFinish != 0)
+ chapters = chapters + " - " + parsed.DVDChapterFinish;
+ }
- // Updates the progress bar and progress label for a new status.
- private void updateUIElements()
+ ListViewItem item = new ListViewItem();
+ item.Text = title; // Title
+ item.SubItems.Add(chapters); // Chapters
+ item.SubItems.Add(queue_item.Source); // Source
+ item.SubItems.Add(queue_item.Destination); // Destination
+ item.SubItems.Add(parsed.VideoEncoder); // Video
+ item.SubItems.Add(parsed.AudioEncoder1); // Audio
+
+ list_queue.Items.Add(item);
+ }
+ }
+ private void updateUIElements()
{
try
{
@@ -275,21 +242,19 @@ namespace Handbrake
MessageBox.Show(exc.ToString());
}
}
-
- // Set's the information lables about the current encode.
- private void setEncValue()
+ private void setCurrentEncodeInformation()
{
try
{
if (this.InvokeRequired)
{
- this.BeginInvoke(new setEncoding(setEncValue));
+ this.BeginInvoke(new setEncoding(setCurrentEncodeInformation));
}
// found query is a global varible
- Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQuery().Query);
- lbl_source.Text = queue.getLastQuery().Source;
- lbl_dest.Text = queue.getLastQuery().Destination;
+ Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQueryItem().Query);
+ lbl_source.Text = queue.getLastQueryItem().Source;
+ lbl_dest.Text = queue.getLastQueryItem().Destination;
if (parsed.DVDTitle == 0)