diff options
author | sr55 <[email protected]> | 2009-01-03 22:46:52 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-01-03 22:46:52 +0000 |
commit | 7c7ee204435c13146895355b545d313c1cc7a707 (patch) | |
tree | 013c6af3fb9801ddfc112f7561318b3e65c64430 | |
parent | 0b30a330672919074117c371de7d1fee4ff5cbbc (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
-rw-r--r-- | win/C#/Functions/QueryParser.cs | 4 | ||||
-rw-r--r-- | win/C#/Queue/QueueHandler.cs | 8 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 10 | ||||
-rw-r--r-- | win/C#/frmQueue.cs | 157 |
4 files changed, 77 insertions, 102 deletions
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index 32179d8f5..759a58da1 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -9,11 +9,13 @@ using System.Collections.Generic; using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
+using System.Globalization;
namespace Handbrake.Functions
{
class QueryParser
{
+ static readonly private CultureInfo Culture = new CultureInfo("en-US", false);
// All the Main Window GUI options
#region Varibles
@@ -1022,7 +1024,7 @@ namespace Handbrake.Functions double qConvert = 0;
if (videoQuality.Success != false)
{
- qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;
+ qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture) * 100;
qConvert = System.Math.Ceiling(qConvert);
thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
}
diff --git a/win/C#/Queue/QueueHandler.cs b/win/C#/Queue/QueueHandler.cs index 6810dec5f..956801401 100644 --- a/win/C#/Queue/QueueHandler.cs +++ b/win/C#/Queue/QueueHandler.cs @@ -5,10 +5,12 @@ using System.Collections; using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;
+using System.Threading;
+using System.Diagnostics;
namespace Handbrake.Queue
{
- public class Queue
+ public class QueueHandler
{
private static XmlSerializer ser = new XmlSerializer(typeof(List<QueueItem>));
List<QueueItem> queue = new List<QueueItem>();
@@ -37,7 +39,7 @@ namespace Handbrake.Queue /// Get the last query that was returned by getNextItemForEncoding()
/// </summary>
/// <returns></returns>
- public QueueItem getLastQuery()
+ public QueueItem getLastQueryItem()
{
return lastItem;
}
@@ -201,5 +203,5 @@ namespace Handbrake.Queue }
}
}
- }
+ }
}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 5110b0b41..418a15f69 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -25,7 +25,7 @@ namespace Handbrake private delegate void UpdateWindowHandler();
Functions.Main hb_common_func = new Functions.Main();
Functions.Encode encodeHandler = new Functions.Encode();
- Queue.Queue encodeQueue = new Queue.Queue();
+ Queue.QueueHandler encodeQueue = new Queue.QueueHandler();
Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();
Parsing.Title selectedTitle;
Parsing.DVD thisDVD;
@@ -503,7 +503,13 @@ namespace Handbrake if (result == DialogResult.Yes)
{
- queueWindow.frmMain_cancelEncode();
+ Process[] aProc = Process.GetProcessesByName("HandBrakeCLI");
+ Process HandBrakeCLI;
+ if (aProc.Length > 0)
+ {
+ HandBrakeCLI = aProc[0];
+ HandBrakeCLI.Kill();
+ }
if (!queueWindow.isEncoding())
setEncodeFinished();
}
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)
|