OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 25 Jul 2007 21:07:13 +0000 (21:07 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 25 Jul 2007 21:07:13 +0000 (21:07 +0000)
- Excluded brianmario's CLI handler until it's completed.
- Enabled cancel button on frmReadDVD (yes it actually works ;))

git-svn-id: svn://localhost/HandBrake/trunk@735 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Functions/CLI.cs
win/C#/HandBrakeCS.csproj
win/C#/frmReadDVD.cs
win/C#/frmSplashScreen.Designer.cs

index 3ed958d..f6c774d 100644 (file)
@@ -2,15 +2,17 @@ using System;
 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
@@ -43,5 +45,23 @@ namespace Handbrake.Functions
             }\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
index 86d6e8a..6161131 100644 (file)
     <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
index b06d100..0a71088 100644 (file)
@@ -20,6 +20,7 @@ namespace Handbrake
         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
@@ -32,7 +33,7 @@ namespace Handbrake
         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
@@ -57,26 +58,28 @@ namespace Handbrake
             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
@@ -96,10 +99,10 @@ namespace Handbrake
 \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
index b85def3..f756f66 100644 (file)
@@ -44,7 +44,9 @@ namespace Handbrake
             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