diff options
-rw-r--r-- | win/C#/Functions/Encode.cs | 11 | ||||
-rw-r--r-- | win/C#/frmActivityWindow.cs | 10 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 41 | ||||
-rw-r--r-- | win/C#/frmQueue.cs | 8 |
4 files changed, 52 insertions, 18 deletions
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs index 7c3f436fa..99db0bc94 100644 --- a/win/C#/Functions/Encode.cs +++ b/win/C#/Functions/Encode.cs @@ -25,6 +25,7 @@ namespace Handbrake.Functions // Declarations
Process hbProc = new Process();
+ Boolean encoding = false;
// CLI output is based on en-US locale,
static readonly private CultureInfo Culture = new CultureInfo("en-US", false);
@@ -47,6 +48,7 @@ namespace Handbrake.Functions if (Properties.Settings.Default.cli_minimized == "Checked")
cliStart.WindowStyle = ProcessWindowStyle.Minimized;
hbProc = Process.Start(cliStart);
+ encoding = true;
// Set the process Priority
switch (Properties.Settings.Default.processPriority)
@@ -83,6 +85,7 @@ namespace Handbrake.Functions /// </summary>
public void afterEncodeAction()
{
+ encoding = false;
// Do something whent he encode ends.
switch (Properties.Settings.Default.CompletionOption)
{
@@ -168,5 +171,13 @@ namespace Handbrake.Functions }
}
+ /// <summary>
+ /// Returns whether HandBrake is currently encoding or not.
+ /// </summary>
+ public Boolean isEncoding
+ {
+ get { if (encoding == false) return false; else return true; }
+ }
+
}
}
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 468e36cce..d1a1376cb 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -26,14 +26,13 @@ namespace Handbrake delegate void SetTextCallback(string text);
String read_file;
Thread monitor;
- frmMain mainWindow;
- frmQueue queueWindow;
+ Functions.Encode encodeHandler;
int position = 0; // Position in the arraylist reached by the current log output in the rtf box.
/// <summary>
/// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.
/// </summary>
- public frmActivityWindow(string file, frmMain fm, frmQueue fq)
+ public frmActivityWindow(string file, Functions.Encode eh)
{
InitializeComponent();
this.rtf_actLog.Text = string.Empty;
@@ -41,8 +40,7 @@ namespace Handbrake // When the window closes, we want to abort the monitor thread.
this.Disposed += new EventHandler(forceQuit);
- mainWindow = fm;
- queueWindow = fq;
+ encodeHandler = eh;
read_file = file;
position = 0;
@@ -162,7 +160,7 @@ namespace Handbrake updateTextFromThread();
while (true)
{
- if (queueWindow.isEncoding() == true)
+ if (encodeHandler.isEncoding == true)
updateTextFromThread();
else
{
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 8c7be7a62..5110b0b41 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -22,8 +22,9 @@ namespace Handbrake public partial class frmMain : Form
{
// Objects which may be used by one or more other objects
+ private delegate void UpdateWindowHandler();
Functions.Main hb_common_func = new Functions.Main();
- Functions.Encode cliObj = new Functions.Encode();
+ Functions.Encode encodeHandler = new Functions.Encode();
Queue.Queue encodeQueue = new Queue.Queue();
Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();
Parsing.Title selectedTitle;
@@ -201,7 +202,7 @@ namespace Handbrake else
file = "hb_encode_log.dat";
- frmActivityWindow dvdInfoWindow = new frmActivityWindow(file, this, queueWindow);
+ frmActivityWindow dvdInfoWindow = new frmActivityWindow(file, encodeHandler);
dvdInfoWindow.Show();
}
private void mnu_options_Click(object sender, EventArgs e)
@@ -504,7 +505,7 @@ namespace Handbrake {
queueWindow.frmMain_cancelEncode();
if (!queueWindow.isEncoding())
- setEncodeStatus(0);
+ setEncodeFinished();
}
}
else
@@ -532,7 +533,7 @@ namespace Handbrake queueWindow.frmMain_encode();
- setEncodeStatus(1); // Encode is running, so setup the GUI appropriately
+ setEncodeStarted(); // Encode is running, so setup the GUI appropriately
}
else if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)
MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -589,7 +590,7 @@ namespace Handbrake else
file = "hb_encode_log.dat";
- frmActivityWindow ActivityWindow = new frmActivityWindow(file, this, queueWindow);
+ frmActivityWindow ActivityWindow = new frmActivityWindow(file, encodeHandler);
ActivityWindow.Show();
}
#endregion
@@ -1701,10 +1702,16 @@ namespace Handbrake /// 0 = Encode Finished.
/// </summary>
/// <param name="i">Int</param>
- public void setEncodeStatus(int i)
+ public void setEncodeFinished()
{
- if (i == 0)
+ try
{
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateWindowHandler(setEncodeFinished));
+ return;
+ }
+
lbl_encode.Text = "Encoding Finished";
btn_start.Text = "Start";
btn_start.ToolTipText = "Start the encoding process";
@@ -1716,15 +1723,33 @@ namespace Handbrake notifyIcon.BalloonTipText = lbl_encode.Text;
notifyIcon.ShowBalloonTip(500);
}
+
}
- else
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+ public void setEncodeStarted()
+ {
+ try
{
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateWindowHandler(setEncodeStarted));
+ return;
+ }
+
lbl_encode.Visible = true;
lbl_encode.Text = "Encoding in Progress";
btn_start.Text = "Stop";
btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";
btn_start.Image = Properties.Resources.stop;
}
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
}
/// <summary>
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 8e71a7398..afa9f467e 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -153,7 +153,7 @@ namespace Handbrake paused = false;
btn_encode.Enabled = false;
mainWindow.setLastAction("encode");
- mainWindow.setEncodeStatus(1);
+ mainWindow.setEncodeStarted();
// Start the encode
try
@@ -207,8 +207,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();
}
@@ -227,7 +226,6 @@ namespace Handbrake {
this.BeginInvoke(new ProgressUpdateHandler(resetQueue));
return;
-
}
btn_stop.Visible = false;
btn_encode.Enabled = true;
@@ -240,6 +238,8 @@ namespace Handbrake lbl_chapt.Text = "-";
lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";
+
+ mainWindow.setEncodeFinished(); // Tell the main window encodes have finished.
}
catch (Exception exc)
{
|