using System.Collections.Generic;\r
using System.Threading;\r
using System.Diagnostics;\r
+using System.Windows.Forms;\r
\r
\r
namespace Handbrake.Functions\r
{\r
class CLI\r
{\r
+ Process hbProc = new Process();\r
+ \r
public Process runCli(object s, string query, bool stderr, bool stdout, bool useShellExec, bool noWindow)\r
{\r
- Process hbProc = new Process();\r
hbProc.StartInfo.FileName = "hbcli.exe";\r
hbProc.StartInfo.Arguments = query;\r
hbProc.StartInfo.RedirectStandardOutput = stdout;\r
}\r
return hbProc;\r
}\r
+\r
+ public void killCLI()\r
+ {\r
+ try\r
+ {\r
+ hbProc.Kill();\r
+ }\r
+ catch (Exception)\r
+ {\r
+ // No need to do anything. Chances are the process was already dead.\r
+ }\r
+ }\r
+\r
+ public void closeCLI()\r
+ {\r
+ hbProc.Close();\r
+ hbProc.Dispose();\r
+ }\r
}\r
}\r
<Reference Include="System.Xml" />\r
</ItemGroup>\r
<ItemGroup>\r
- <Compile Include="CLI\Jobs\Encode.cs" />\r
- <Compile Include="CLI\Jobs\Job.cs" />\r
- <Compile Include="CLI\Jobs\ParseDVD.cs" />\r
- <Compile Include="CLI\Manager.cs" />\r
<Compile Include="frmAbout.cs">\r
<SubType>Form</SubType>\r
</Compile>\r
private Parsing.DVD thisDvd;\r
private Process hbProc;\r
private delegate void UpdateUIHandler();\r
+ private int cancel = 0;\r
\r
public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)\r
{\r
private void btn_ok_Click(object sender, EventArgs e)\r
{\r
btn_ok.Enabled = false;\r
- //btn_skip.Visible = true;\r
+ btn_skip.Visible = true;\r
lbl_pressOk.Visible = false;\r
lbl_progress.Text = "0%";\r
lbl_progress.Visible = true;\r
this.Close();\r
}\r
\r
+ Functions.CLI process = new Functions.CLI();\r
private void startProc(object state)\r
{\r
string query = "-i " + '"' + inputFile + '"' + " -t0";\r
\r
- Functions.CLI process = new Functions.CLI();\r
+ \r
hbProc = process.runCli(this, query, true, true, false, true);\r
\r
Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
readData.OnScanProgress += Parser_OnScanProgress;\r
- \r
-\r
readData.OnReadLine += dvdInfo.HandleParsedData;\r
readData.OnReadToEnd += dvdInfo.HandleParsedData;\r
- hbProc.Close();\r
- hbProc.Dispose();\r
- \r
+\r
// Setup the parser\r
thisDvd = Parsing.DVD.Parse(readData);\r
\r
- updateUIElements();\r
+ if (cancel != 1)\r
+ {\r
+ updateUIElements();\r
+ process.killCLI();\r
+ process.closeCLI();\r
+ }\r
}\r
\r
private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)\r
\r
private void btn_skip_Click(object sender, EventArgs e)\r
{\r
- // TODO *****************************************************************\r
- // This needs to be implimented so that is destroys the above thread\r
- // closing hbcli with it.\r
- //***********************************************************************\r
+ process.killCLI();\r
+ this.Close();\r
+ cancel = 1;\r
+ \r
}\r
\r
}\r
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;\r
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
this.Name = "frmSplashScreen";\r
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
this.Text = "SplashScreen";\r
+ this.TopMost = true;\r
this.ResumeLayout(false);\r
\r
}\r