From bc4964e49d17d09be0bf2d866579becb746fb176 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 25 Jul 2007 21:07:13 +0000 Subject: WinGui: - Excluded brianmario's CLI handler until it's completed. - Enabled cancel button on frmReadDVD (yes it actually works ;)) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@735 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/CLI.cs | 22 +++++++++++++++++++++- win/C#/HandBrakeCS.csproj | 4 ---- win/C#/frmReadDVD.cs | 27 +++++++++++++++------------ win/C#/frmSplashScreen.Designer.cs | 2 ++ 4 files changed, 38 insertions(+), 17 deletions(-) (limited to 'win/C#') diff --git a/win/C#/Functions/CLI.cs b/win/C#/Functions/CLI.cs index 3ed958d50..f6c774d68 100644 --- a/win/C#/Functions/CLI.cs +++ b/win/C#/Functions/CLI.cs @@ -2,15 +2,17 @@ using System; using System.Collections.Generic; using System.Threading; using System.Diagnostics; +using System.Windows.Forms; namespace Handbrake.Functions { class CLI { + Process hbProc = new Process(); + public Process runCli(object s, string query, bool stderr, bool stdout, bool useShellExec, bool noWindow) { - Process hbProc = new Process(); hbProc.StartInfo.FileName = "hbcli.exe"; hbProc.StartInfo.Arguments = query; hbProc.StartInfo.RedirectStandardOutput = stdout; @@ -43,5 +45,23 @@ namespace Handbrake.Functions } return hbProc; } + + public void killCLI() + { + try + { + hbProc.Kill(); + } + catch (Exception) + { + // No need to do anything. Chances are the process was already dead. + } + } + + public void closeCLI() + { + hbProc.Close(); + hbProc.Dispose(); + } } } diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 86d6e8a14..6161131be 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -38,10 +38,6 @@ - - - - Form diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index b06d1009d..0a7108893 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -20,6 +20,7 @@ namespace Handbrake private Parsing.DVD thisDvd; private Process hbProc; private delegate void UpdateUIHandler(); + private int cancel = 0; public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow) { @@ -32,7 +33,7 @@ namespace Handbrake private void btn_ok_Click(object sender, EventArgs e) { btn_ok.Enabled = false; - //btn_skip.Visible = true; + btn_skip.Visible = true; lbl_pressOk.Visible = false; lbl_progress.Text = "0%"; lbl_progress.Visible = true; @@ -57,26 +58,28 @@ namespace Handbrake this.Close(); } + Functions.CLI process = new Functions.CLI(); private void startProc(object state) { string query = "-i " + '"' + inputFile + '"' + " -t0"; - Functions.CLI process = new Functions.CLI(); + hbProc = process.runCli(this, query, true, true, false, true); Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream); readData.OnScanProgress += Parser_OnScanProgress; - - readData.OnReadLine += dvdInfo.HandleParsedData; readData.OnReadToEnd += dvdInfo.HandleParsedData; - hbProc.Close(); - hbProc.Dispose(); - + // Setup the parser thisDvd = Parsing.DVD.Parse(readData); - updateUIElements(); + if (cancel != 1) + { + updateUIElements(); + process.killCLI(); + process.closeCLI(); + } } private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount) @@ -96,10 +99,10 @@ namespace Handbrake private void btn_skip_Click(object sender, EventArgs e) { - // TODO ***************************************************************** - // This needs to be implimented so that is destroys the above thread - // closing hbcli with it. - //*********************************************************************** + process.killCLI(); + this.Close(); + cancel = 1; + } } diff --git a/win/C#/frmSplashScreen.Designer.cs b/win/C#/frmSplashScreen.Designer.cs index b85def35c..f756f66f1 100644 --- a/win/C#/frmSplashScreen.Designer.cs +++ b/win/C#/frmSplashScreen.Designer.cs @@ -44,7 +44,9 @@ namespace Handbrake this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "frmSplashScreen"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "SplashScreen"; + this.TopMost = true; this.ResumeLayout(false); } -- cgit v1.2.3