diff options
author | sr55 <[email protected]> | 2007-07-25 21:58:43 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2007-07-25 21:58:43 +0000 |
commit | 293f0c3d36474e6114948e8c186a3bcc44bf4ad3 (patch) | |
tree | 8398293d22f48aed9f79136e2e7d65b2dd23cba1 /win/C#/frmMain.cs | |
parent | bc4964e49d17d09be0bf2d866579becb746fb176 (diff) |
WinGui:
- Added Cancel button to frmMain. Allows one to cancel the encode on the fly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@736 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmMain.cs')
-rw-r--r-- | win/C#/frmMain.cs | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index e70994e7f..c66cee0b6 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -638,8 +638,19 @@ namespace Handbrake queueWindow.Show();
}
+
+
+
+
+ //---------------------------------------------------
+ // Encode / Cancel Buttons
+ // Encode Progress Text Handler
+ //---------------------------------------------------
+ Functions.CLI process = new Functions.CLI();
+
private void btn_encode_Click(object sender, EventArgs e)
{
+ btn_eCancel.Enabled = true;
String query = "";
lbl_encode.Visible = true;
@@ -655,39 +666,57 @@ namespace Handbrake ThreadPool.QueueUserWorkItem(procMonitor, query);
}
- private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
+ private void btn_eCancel_Click(object sender, EventArgs e)
{
- if (this.InvokeRequired)
- {
- this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
- new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
- return;
- }
- lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
+ process.killCLI();
+ process.setNull();
+ lbl_encode.Text = "Encoding Canceled";
}
-
+
private void procMonitor(object state)
{
- Functions.CLI process = new Functions.CLI();
+
hbProc = process.runCli(this, (string)state, true, true, false, true);
MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
- //TODO: prevent this event from being subscribed more than once
- encode.OnEncodeProgress += encode_OnEncodeProgress;
- while (!encode.EndOfStream)
+ try
{
- encode.ReadLine();
+ Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
+ encode.OnEncodeProgress += encode_OnEncodeProgress;
+ while (!encode.EndOfStream)
+ {
+ encode.ReadLine();
+ }
+
+ hbProc.WaitForExit();
+ process.closeCLI();
+ hbProc = null;
+ }
+ catch (Exception)
+ {
+ // Do Nothing
}
+ //TODO: prevent this event from being subscribed more than once
+
- hbProc.WaitForExit();
- hbProc.Close();
- hbProc.Dispose();
- hbProc = null;
MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
+
+
+
+
+ private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
+ new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
+ return;
+ }
+ lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
+ }
//---------------------------------------------------
// Items that require actions on frmMain
@@ -1394,6 +1423,8 @@ namespace Handbrake return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
}
+
+
// This is the END of the road ------------------------------------------------------------------------------
}
}
\ No newline at end of file |