]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Mon, 16 Jul 2007 16:52:58 +0000 (16:52 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 16 Jul 2007 16:52:58 +0000 (16:52 +0000)
- CLI process handling code moved into its own class. Reduces code replication. Returns hbProc

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@696 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/HandBrakeCS.csproj
win/C#/Parsing/Chapter.cs
win/C#/Parsing/DVD.cs
win/C#/Parsing/Subtitle.cs
win/C#/Parsing/Title.cs
win/C#/frmMain.cs
win/C#/frmQueue.cs
win/C#/frmReadDVD.cs

index 235cf2762daabfa03936cf30bf1705bd0e537079..2316eb6787867f77a90ec57f5e9458841974c617 100644 (file)
@@ -62,6 +62,8 @@
     <Compile Include="frmOptions.Designer.cs">\r
       <DependentUpon>frmOptions.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="Functions\CLI.cs" />\r
+    <Compile Include="Functions\Update.cs" />\r
     <Compile Include="Parsing\AudioTrack.cs" />\r
     <Compile Include="Parsing\Chapter.cs" />\r
     <Compile Include="Parsing\DVD.cs" />\r
index 44627ac6370ee3ef95b5ce4a118106d5806de5b7..c74f0d56e8bf8f31ab97cc0116d5c80e422849d3 100644 (file)
@@ -16,24 +16,6 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        /*private int[] m_cellRange;\r
-        public int[] CellRange\r
-        {\r
-            get\r
-            {\r
-                return this.m_cellRange;\r
-            }\r
-        }\r
-\r
-        private int m_blocks;\r
-        public int BlockCount\r
-        {\r
-            get\r
-            {\r
-                return this.m_blocks;\r
-            }\r
-        }*/\r
-\r
         private TimeSpan m_duration;\r
         public TimeSpan Duration\r
         {\r
@@ -56,8 +38,6 @@ namespace Handbrake.Parsing
                 Chapter thisChapter = new Chapter();\r
                 string[] splitter = curLine.Split(new string[] { "    + ", ": cells ", ", ", " blocks, duration ", "->" }, StringSplitOptions.RemoveEmptyEntries);\r
                 thisChapter.m_chapterNumber = int.Parse(splitter[0]);\r
-                //thisChapter.m_cellRange = new int[2] { int.Parse(splitter[1]), int.Parse(splitter[2]) };\r
-                //thisChapter.m_blocks = int.Parse(splitter[3]);\r
                 thisChapter.m_duration = TimeSpan.Parse(splitter[4]);\r
                 return thisChapter;\r
             }\r
@@ -74,6 +54,7 @@ namespace Handbrake.Parsing
             while (!curLine.Contains("  + audio tracks:"))\r
             {\r
                 Chapter thisChapter = Chapter.Parse(output);\r
+           \r
                 if (thisChapter != null)\r
                 {\r
                     chapters.Add(thisChapter);\r
index 4b09ac8288615b027e743f9fca4a4cb780d8c606..ef6586e39b63f309ae317ddb6acedf3c27d992da 100644 (file)
@@ -2,6 +2,8 @@ using System;
 using System.Collections.Generic;\r
 using System.Text;\r
 using System.IO;\r
+using System.Windows.Forms;\r
+\r
 \r
 namespace Handbrake.Parsing\r
 {\r
index 343806ab0d9b3790bf94f49c551fbb1dffdcce8c..d91638076d67b27e39d30e7e0e140821d7b58fb1 100644 (file)
@@ -53,6 +53,7 @@ namespace Handbrake.Parsing
             while ((char)output.Peek() != '+') // oh glorious hack, serve me well\r
             {\r
                 Subtitle thisSubtitle = Subtitle.Parse(output);\r
+\r
                 if (thisSubtitle != null)\r
                 {\r
                     subtitles.Add(thisSubtitle);\r
index 245adfcdb311d495c2314ef0e22b17322d7fae16..e55bd78e60b878240927e7339f9930c9d8e521fd 100644 (file)
@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Text;\r
 using System.Drawing;\r
 using System.IO;\r
+using System.Windows.Forms;\r
 \r
 namespace Handbrake.Parsing\r
 {\r
@@ -35,42 +36,6 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        /*private int m_vts;\r
-        public int Vts\r
-        {\r
-            get\r
-            {\r
-                return this.m_vts;\r
-            }\r
-        }\r
-\r
-        private int m_ttn;\r
-        public int Ttn\r
-        {\r
-            get\r
-            {\r
-                return this.m_ttn;\r
-            }\r
-        }\r
-\r
-        private int[] m_cellRange;\r
-        public int[] CellRange\r
-        {\r
-            get\r
-            {\r
-                return this.m_cellRange;\r
-            }\r
-        }\r
-\r
-        private int m_blockCount;\r
-        public int BlockCount\r
-        {\r
-            get\r
-            {\r
-                return this.m_blockCount;\r
-            }\r
-        }*/\r
-\r
         private int m_titleNumber;\r
         public int TitleNumber\r
         {\r
@@ -107,14 +72,6 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        /*private float m_fps;\r
-        public float Fps\r
-        {\r
-            get\r
-            {\r
-                return this.m_fps;\r
-            }\r
-        }*/\r
 \r
         private int[] m_autoCrop;\r
         public int[] AutoCropDimensions\r
@@ -130,7 +87,6 @@ namespace Handbrake.Parsing
             this.m_audioTracks = new List<AudioTrack>();\r
             this.m_chapters = new List<Chapter>();\r
             this.m_subtitles = new List<Subtitle>();\r
-            //this.m_cellRange = new int[2];\r
         }\r
 \r
         public override string ToString()\r
@@ -147,19 +103,16 @@ namespace Handbrake.Parsing
              * This will be converted to use Regex soon, I promise ;)\r
              * brianmario - 7/9/07\r
              */\r
-            try\r
-            {\r
+        \r
                 string curLine = output.ReadLine();\r
                 thisTitle.m_titleNumber = int.Parse(curLine.Substring(curLine.Length - 2, 1));\r
                 curLine = output.ReadLine();\r
                 string[] splitter = curLine.Split(',');\r
-                //thisTitle.m_vts = int.Parse(splitter[0].Substring(8));\r
-                //thisTitle.m_ttn = int.Parse(splitter[1].Substring(5));\r
+   \r
                 splitter = splitter[2].Trim().Split(' ', '(', ')');\r
-                //thisTitle.m_blockCount = int.Parse(splitter[3]);\r
+\r
                 splitter = splitter[1].Split('-', '>');\r
-                //thisTitle.m_cellRange[0] = int.Parse(splitter[0]);\r
-                //thisTitle.m_cellRange[1] = int.Parse(splitter[2]);\r
+\r
                 curLine = output.ReadLine();\r
                 splitter = curLine.Split(new string[] { "  + duration: " }, StringSplitOptions.RemoveEmptyEntries);\r
                 thisTitle.m_duration = TimeSpan.Parse(splitter[0]);\r
@@ -167,20 +120,14 @@ namespace Handbrake.Parsing
                 splitter = curLine.Split(new string[] { "  + size: ", "aspect: ", ", ", " fps", "x" }, StringSplitOptions.RemoveEmptyEntries);\r
                 thisTitle.m_resolution = new Size(int.Parse(splitter[0]), int.Parse(splitter[1]));\r
                 thisTitle.m_aspectRatio = float.Parse(splitter[2].ToString());\r
-                //thisTitle.m_fps = float.Parse(splitter[3].ToString());\r
+     \r
                 curLine = output.ReadLine();\r
                 splitter = curLine.Split(new string[] { "  + autocrop: ", "/" }, StringSplitOptions.RemoveEmptyEntries);\r
                 thisTitle.m_autoCrop = new int[4] { int.Parse(splitter[0]), int.Parse(splitter[1]), int.Parse(splitter[2]), int.Parse(splitter[3]) };\r
                 thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
                 thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
                 thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
-            }\r
-            catch (Exception)\r
-            {\r
-                // hbcli crashed caused an exception here. Just threw this in to prevent a program error.\r
-                // Can be debuged later.\r
-            }\r
-\r
+            \r
             return thisTitle;\r
         }\r
 \r
index 5361a34898e9e27541442b05f38b12cbd27df247..234af0aa4c67cd764b32403feafa0274386ef4bc 100644 (file)
@@ -603,38 +603,10 @@ namespace Handbrake
                 query = QueryEditorText.Text;\r
             }\r
 \r
-            hbProc = new System.Diagnostics.Process();\r
-            hbProc.StartInfo.FileName = "hbcli.exe";\r
-            hbProc.StartInfo.Arguments = query;\r
-            hbProc.StartInfo.UseShellExecute = false;\r
-            hbProc.Start();\r
-\r
-            // Set the process Priority\r
-            string priority = Properties.Settings.Default.processPriority;\r
-            switch (priority)\r
-            {\r
-                case "Realtime":\r
-                    hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
-                    break;\r
-                case "High":\r
-                    hbProc.PriorityClass = ProcessPriorityClass.High;\r
-                    break;\r
-                case "Above Normal":\r
-                    hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
-                    break;\r
-                case "Normal":\r
-                    hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
-                    break;\r
-                case "Low":\r
-                    hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
-                    break;\r
-                default:\r
-                    hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
-                    break;\r
-            }\r
+            Functions.CLI process = new Functions.CLI();\r
+            Process hbProc = process.runCli(this, query, false, false, false, false);\r
 \r
             ThreadPool.QueueUserWorkItem(procMonitor);\r
-            // TODO: Need to write a bit of code here to do process monitoring.\r
         }\r
 \r
         private void procMonitor(object state)\r
@@ -744,9 +716,10 @@ namespace Handbrake
                         text_width.BackColor = Color.LightGreen;\r
                     }\r
                 }\r
-\r
\r
                 // There is a bug here *******************************************************************\r
-                if (!lbl_Aspect.Text.Equals("Select a Title")){\r
+                if (lbl_Aspect.Text != "Select a Title")\r
+                {\r
                     int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);\r
                     MessageBox.Show("test");\r
                     int mod16 = height % 16;\r
index 09b3f19c808187b3af4f80037f7c1cae55301056..8d273215d0ca0f8052c126a2a44f4b075aefb28e 100644 (file)
@@ -77,41 +77,14 @@ namespace Handbrake
             for (int i = 0; i < initialListCount; i++)\r
             {\r
                 string query = list_queue.Items[0].ToString();\r
-                Process hbProc = new Process();\r
-                hbProc.StartInfo.FileName = "hbcli.exe";\r
-                hbProc.StartInfo.Arguments = query;\r
-                hbProc.StartInfo.UseShellExecute = false;\r
-                hbProc.Start();\r
-\r
-                // Set the process Priority\r
-\r
-                switch (Properties.Settings.Default.processPriority)\r
-                {\r
-                    case "Realtime":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
-                        break;\r
-                    case "High":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.High;\r
-                        break;\r
-                    case "Above Normal":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
-                        break;\r
-                    case "Normal":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
-                        break;\r
-                    case "Low":\r
-                        hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
-                        break;\r
-                    default:\r
-                        hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
-                        break;\r
-                }\r
 \r
+                Functions.CLI process = new Functions.CLI();\r
+                Process hbProc = process.runCli(this, query, false, false, false, false);\r
+       \r
                 hbProc.WaitForExit();\r
                 hbProc.Close();\r
                 hbProc.Dispose();\r
 \r
-\r
                 updateUIElements();\r
             }\r
         }\r
index 04a47029bc2d5bd030e1a1132729cc439a92abde..62a1563cc8eef20dca144f3ee6b7413eb0e83a98 100644 (file)
@@ -7,6 +7,7 @@ using System.Text;
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Threading;\r
+using System.Diagnostics;\r
 \r
 \r
 namespace Handbrake\r
@@ -59,15 +60,10 @@ namespace Handbrake
         private void startProc(object state)\r
         {\r
             string query = "-i " + '"' + inputFile + '"' + " -t0";\r
-            System.Diagnostics.Process hbProc = new System.Diagnostics.Process();\r
-            hbProc.StartInfo.FileName = "hbcli.exe";\r
-            hbProc.StartInfo.RedirectStandardOutput = true;\r
-            hbProc.StartInfo.RedirectStandardError = true;\r
-            hbProc.StartInfo.Arguments = query;\r
-            hbProc.StartInfo.UseShellExecute = false;\r
-            hbProc.StartInfo.CreateNoWindow = true;\r
+          \r
+            Functions.CLI process = new Functions.CLI();\r
+            Process hbProc = process.runCli(this, query, true, true, false, true);\r
 \r
-            hbProc.Start();\r
             Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
             hbProc.WaitForExit();\r
             hbProc.Close();\r