// Encode / Cancel Buttons\r
// Encode Progress Text Handler\r
//---------------------------------------------------\r
+\r
Functions.CLI process = new Functions.CLI();\r
\r
private void btn_encode_Click(object sender, EventArgs e)\r
\r
private void procMonitor(object state)\r
{\r
- \r
- hbProc = process.runCli(this, (string)state, true, true, false, true);\r
+ // Make sure we are not already encoding and if we are then display an error.\r
+ if (hbProc != null)\r
+ {\r
+ MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ }\r
+ else\r
+ {\r
+ hbProc = process.runCli(this, (string)state, true, true, false, true);\r
\r
- MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
\r
- try\r
- {\r
- Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
- encode.OnEncodeProgress += encode_OnEncodeProgress;\r
- while (!encode.EndOfStream)\r
+ try\r
{\r
- encode.ReadLine();\r
+ Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
+ encode.OnEncodeProgress += encode_OnEncodeProgress;\r
+ while (!encode.EndOfStream)\r
+ {\r
+ encode.ReadLine();\r
+ }\r
+\r
+ hbProc.WaitForExit();\r
+ process.closeCLI();\r
+ hbProc = null;\r
+ }\r
+ catch (Exception)\r
+ {\r
+ // Do nothing\r
}\r
\r
- hbProc.WaitForExit();\r
- process.closeCLI();\r
- hbProc = null;\r
+ MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
}\r
- catch (Exception)\r
- { \r
- // Do Nothing\r
- }\r
-\r
- //TODO: prevent this event from being subscribed more than once\r
-\r
- \r
- MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
}\r
\r
-\r
-\r
-\r
private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
{\r
if (this.InvokeRequired)\r