]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Tue, 10 Jul 2007 22:35:11 +0000 (22:35 +0000)
committersr55 <sr55.hb@outlook.com>
Tue, 10 Jul 2007 22:35:11 +0000 (22:35 +0000)
- Just some more C# getting checked in. Not far from completion now.

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

win/C#/HandBrakeCS.csproj
win/C#/HandBrakeCS.suo
win/C#/frmMain.cs
win/C#/frmReadDVD.Designer.cs
win/C#/frmReadDVD.cs
win/Handbrake.suo

index 1cd5a4e49165cd5fbe7e93b4bf7c68bfd639de32..499cf29f62c863febe52d8d100cc5cfcbeb1831e 100644 (file)
@@ -37,6 +37,7 @@
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Content Include="file.txt" />\r
     <Compile Include="frmAbout.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
index bc9c1e19d94c129a490bad34ca1223ca03e9616d..ba8ae8e7c319dcdb4f3c974ce722e08e06e58576 100644 (file)
Binary files a/win/C#/HandBrakeCS.suo and b/win/C#/HandBrakeCS.suo differ
index 70b8c48e39ca1c9414fbb6bfeefbcb847fbb44b9..471e61a3fd455e30ff47a249a206219bfc4fc871 100644 (file)
@@ -536,7 +536,7 @@ namespace Handbrake
                 if (filename != "")\r
                 {\r
                     text_source.Text = filename;\r
-                    Form frmReadDVD = new frmReadDVD(filename);\r
+                    Form frmReadDVD = new frmReadDVD(filename, (frmMain)frmMain.ActiveForm);\r
                     frmReadDVD.Show();\r
                 }\r
 \r
@@ -548,7 +548,7 @@ namespace Handbrake
                 if (filename != "")\r
                 {\r
                     text_source.Text = filename;\r
-                    Form frmReadDVD = new frmReadDVD(filename);\r
+                    Form frmReadDVD = new frmReadDVD(filename, (frmMain)frmMain.ActiveForm);\r
                     frmReadDVD.Show();\r
                 }\r
 \r
@@ -936,9 +936,49 @@ namespace Handbrake
             }\r
         }\r
 \r
+        Parsing.DVD thisDVD;\r
+        public void setStreamReader(Parsing.DVD dvd)\r
+        {\r
+            this.thisDVD = dvd;\r
+        }\r
+\r
         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            //TODO: Convert the Parsing Code.\r
+            // Reset some values on the form\r
+            lbl_Aspect.Text = "Select a Title";\r
+            lbl_RecomendedCrop.Text = "Select a Title";\r
+            QueryEditorText.Text = "";\r
+\r
+            // If the dropdown is set to automatic nothing else needs to be done.\r
+            // Otheriwse if its not, title data has to be loased from parsing.\r
+            if (drp_dvdtitle.Text != "Automatic")\r
+            {\r
+                string[] temp;\r
+                string title;\r
+                temp = drp_dvdtitle.Text.Split(' ');\r
+                title = temp[0].Trim();\r
+              \r
+                int count = thisDVD.Titles.Count - 1;\r
+                int counter = 0;\r
+\r
+                while (count >= counter)\r
+                {\r
+\r
+                    if (thisDVD.Titles[counter].TitleNumber.ToString() == title)\r
+                    {\r
+                        lbl_Aspect.Text = thisDVD.Titles[counter].AspectRatio.ToString();\r
+                        lbl_RecomendedCrop.Text = thisDVD.Titles[counter].AutoCropDimensions[0] + "/" + thisDVD.Titles[counter].AutoCropDimensions[1] + "/" + thisDVD.Titles[counter].AutoCropDimensions[2] + "/" + thisDVD.Titles[counter].AutoCropDimensions[3];\r
+                        // Still need to set these up.\r
+                        MessageBox.Show(thisDVD.Titles[counter].AudioTracks[0].ToString());\r
+                        MessageBox.Show(thisDVD.Titles[counter].Chapters.ToString());\r
+                        MessageBox.Show(thisDVD.Titles[counter].Subtitles.ToString());\r
+                    }\r
+                    counter++;\r
+                }\r
+\r
+\r
+            }\r
+            \r
         } \r
 \r
         //\r
index 5cf290e1fc06bec9bd261f028299a0d583a3ff93..c55d243be10b62605f9e684b39a5b15c507eafd7 100644 (file)
@@ -29,21 +29,22 @@ namespace Handbrake
         private void InitializeComponent()\r
         {\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReadDVD));\r
-            this.Label4 = new System.Windows.Forms.Label();\r
+            this.lbl_pressOk = new System.Windows.Forms.Label();\r
             this.btn_ok = new System.Windows.Forms.Button();\r
             this.Label3 = new System.Windows.Forms.Label();\r
             this.Label2 = new System.Windows.Forms.Label();\r
+            this.lbl_status = new System.Windows.Forms.Label();\r
             this.SuspendLayout();\r
             // \r
-            // Label4\r
+            // lbl_pressOk\r
             // \r
-            this.Label4.AutoSize = true;\r
-            this.Label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label4.Location = new System.Drawing.Point(66, 51);\r
-            this.Label4.Name = "Label4";\r
-            this.Label4.Size = new System.Drawing.Size(178, 13);\r
-            this.Label4.TabIndex = 29;\r
-            this.Label4.Text = "Press OK to start the process.";\r
+            this.lbl_pressOk.AutoSize = true;\r
+            this.lbl_pressOk.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_pressOk.Location = new System.Drawing.Point(66, 60);\r
+            this.lbl_pressOk.Name = "lbl_pressOk";\r
+            this.lbl_pressOk.Size = new System.Drawing.Size(178, 13);\r
+            this.lbl_pressOk.TabIndex = 29;\r
+            this.lbl_pressOk.Text = "Press OK to start the process.";\r
             // \r
             // btn_ok\r
             // \r
@@ -81,12 +82,24 @@ namespace Handbrake
             this.Label2.TabIndex = 26;\r
             this.Label2.Text = "Status:";\r
             // \r
+            // lbl_status\r
+            // \r
+            this.lbl_status.AutoSize = true;\r
+            this.lbl_status.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_status.Location = new System.Drawing.Point(66, 41);\r
+            this.lbl_status.Name = "lbl_status";\r
+            this.lbl_status.Size = new System.Drawing.Size(178, 13);\r
+            this.lbl_status.TabIndex = 30;\r
+            this.lbl_status.Text = "Processing.... Please Wait!";\r
+            this.lbl_status.Visible = false;\r
+            // \r
             // frmReadDVD\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
             this.ClientSize = new System.Drawing.Size(473, 86);\r
-            this.Controls.Add(this.Label4);\r
+            this.Controls.Add(this.lbl_status);\r
+            this.Controls.Add(this.lbl_pressOk);\r
             this.Controls.Add(this.btn_ok);\r
             this.Controls.Add(this.Label3);\r
             this.Controls.Add(this.Label2);\r
@@ -101,9 +114,10 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        internal System.Windows.Forms.Label Label4;\r
+        internal System.Windows.Forms.Label lbl_pressOk;\r
         internal System.Windows.Forms.Button btn_ok;\r
         internal System.Windows.Forms.Label Label3;\r
         internal System.Windows.Forms.Label Label2;\r
+        internal System.Windows.Forms.Label lbl_status;\r
     }\r
 }
\ No newline at end of file
index 2c95731df516e08630abb2c2f600ae3eb414daa1..0d8e109e9a2a86748f38c16cfe55814149a9a784 100644 (file)
@@ -5,6 +5,8 @@ using System.Data;
 using System.Drawing;\r
 using System.Text;\r
 using System.Windows.Forms;\r
+using System.IO;\r
+\r
 \r
 namespace Handbrake\r
 {\r
@@ -12,197 +14,54 @@ namespace Handbrake
     {\r
 \r
         string inputFile;\r
+        frmMain mainWindow;\r
 \r
-        public frmReadDVD(string inputFile)\r
+        public frmReadDVD(string inputFile, frmMain window)\r
         {\r
             InitializeComponent();\r
             this.inputFile = inputFile;\r
+            this.mainWindow = window;\r
         }\r
 \r
-        public void scan(string filename)\r
+        private void btn_ok_Click(object sender, EventArgs e)\r
         {\r
-            string query = "-i " + '"' + filename + '"' + " -t0";\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
+            \r
             hbProc.Start();\r
-            System.IO.StreamReader errorReader = new System.IO.StreamReader(new System.IO.BufferedStream(hbProc.StandardError.BaseStream));\r
+            StreamReader readData = new StreamReader(new BufferedStream(hbProc.StandardError.BaseStream));\r
             hbProc.WaitForExit();\r
             hbProc.Close();\r
 \r
-            //Parsing.DVD thisDvd = Parsing.DVD.Parse(errorReader);\r
+            // Setup the parser\r
+            Parsing.DVD thisDvd = Parsing.DVD.Parse(readData);\r
 \r
-            String DvdData = errorReader.ReadToEnd();\r
-            DvdData = DvdData + "-- end --";\r
+            // Now pass this streamreader to frmMain so that it can be used there.\r
+            mainWindow.setStreamReader(thisDvd);\r
 \r
-            String[] DvdDataArr = DvdData.Split('\n');\r
-            int DvdDataSize = DvdDataArr.Length -1;\r
-            String line = "";\r
+            // Setup frmMain drp_dvdTitle with the title information in the form:  1 (02:34:11)\r
+            int count = thisDvd.Titles.Count -1;\r
             int counter = 0;\r
+            string title;\r
 \r
-            //\r
-            // Some varbiles used for parseing HandBrakes output\r
-            //\r
-\r
-            // DVD info stroage varibles\r
-            string titleData  = "";\r
-            string duationData  = "";\r
-            string sizeData  = "";\r
-            string cropdata  = "";\r
-            string chatperData  = "";\r
-            string audioData  = "";\r
-            string subtitleData  = "";\r
-\r
-            string fullTitleData  = "";\r
-\r
-            // Position Pointers\r
-            bool chapterPointer  = false;\r
-            bool audioPointer = false;\r
-            bool subtitlePointer = false;\r
-\r
-            // Error handling varibles\r
-            bool titleError = false;\r
-            bool readError = false;\r
-            \r
-            while (counter <= DvdDataSize)\r
+            while (count >= counter)\r
             {\r
-                line = DvdDataArr[counter];\r
+                title = thisDvd.Titles[counter].TitleNumber.ToString() + " (" + thisDvd.Titles[counter].Duration.ToString() + ")";\r
+                mainWindow.drp_dvdtitle.Items.Add(title);\r
                 counter++;\r
-                 \r
-                // Get all the 1 liner data and set chaper potiner to true when done\r
-                if (line.Contains("exited.")){\r
-                    subtitlePointer = false;\r
-                    fullTitleData = titleData.Trim() + " ~ " + duationData.Trim() + " ~ " + sizeData.Trim() + " ~ " + cropdata.Trim() + " ~ " + chatperData.Trim() + " ~ " + audioData.Trim() + " ~ " + subtitleData.Trim();\r
-                    add(fullTitleData, titleData, duationData);\r
-                    counter++;\r
-                }else if (line.Contains("+ title")){\r
-                    if (titleData != "") {\r
-                        subtitlePointer = true;\r
-                        fullTitleData = titleData.Trim() + " ~ " + duationData.Trim() + " ~ " + sizeData.Trim() + " ~ " + cropdata.Trim() + " ~ " + chatperData.Trim() + " ~ " + audioData.Trim() + " ~ " + subtitleData.Trim();\r
-                        add(fullTitleData, titleData, duationData);\r
-                        counter = counter + 1;\r
-                    }\r
-                    titleData = line;\r
-                }else if (line.Contains("+ duration")) {\r
-                    duationData = line;\r
-                }else if (line.Contains("+ size")) {\r
-                    sizeData = line;\r
-                }else if (line.Contains("+ autocrop")) {\r
-                    cropdata = line;\r
-                }else if (line.Contains("+ chapters")) {\r
-                    chatperData = line;\r
-                    chapterPointer = true;\r
-                }\r
-\r
-                // Get all the chapter information in 1 varible\r
-                if (chapterPointer == true)\r
-                {\r
-                    if (!line.Contains("+ audio"))\r
-                    {\r
-                        chapterPointer = false;\r
-                        audioPointer = true;\r
-                        audioData = line;\r
-                   }\r
-                    else \r
-                    {\r
-                        if (!chatperData.Equals(line))\r
-                        {\r
-                            chatperData = chatperData + " & " + line.Trim();\r
-                        }\r
-                    }\r
-                }\r
-\r
-                 // Get all the audio channel information in 1 varible\r
-                if (audioPointer == true)\r
-                { \r
-                    if (line.Contains("+ subtitle"))\r
-                    {\r
-                        audioPointer = false;\r
-                        subtitlePointer = true;\r
-                        subtitleData = line;\r
-                    } \r
-                    else \r
-                    {\r
-                        if (!audioData.Equals(line))\r
-                        {\r
-                            audioData = audioData + " & " + line.Trim();\r
-                        }\r
-                    }\r
-                 }\r
-\r
-                 //Get all the subtitle data into 1 varible\r
-                 if (subtitlePointer == true)\r
-                 {\r
-                            if (line.Contains("+ subtitle")) \r
-                            {\r
-                                subtitleData = line;\r
-                            } else \r
-                            {\r
-                                if (!subtitleData.Equals(line))\r
-                                {\r
-                                    subtitleData = subtitleData + " & " + line.Trim();\r
-                                }\r
-                            }\r
-                  }\r
-\r
-                  // Handle some of Handbrakes Error outputs if they occur.\r
-                  if (line.Contains("No title"))\r
-                  {\r
-                    titleError = true;\r
-                  }\r
-\r
-                  if (line.Contains("***")) \r
-                  {\r
-                    readError = true;\r
-                  }\r
-\r
-                 // Display error messages for errors detected above.\r
-                 if (readError == true)\r
-                 {\r
-                     MessageBox.Show("Some DVD Title information may be missing however you may still be able to select your required title for encoding!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
-                 }\r
-\r
-                 if (titleError == true)\r
-                 {\r
-                     MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
-                 }\r
-\r
-            }\r
-        }\r
-\r
-        public void add(string fullTitleData, string titleData, string durationData)\r
-        {\r
-\r
-            try\r
-            {\r
-                string t = titleData.Trim().Substring(8).Replace(":", "");\r
-                string d = durationData.Trim().Substring(12);\r
-\r
-                // Lets store the captured full title data as a string in the programs settings file.\r
-                // This can then be used by the DVD title dropdown menu to populate other fields.\r
-\r
-                Properties.Settings.Default.FullDVDInfo = Properties.Settings.Default.FullDVDInfo + " \n " + fullTitleData;\r
-\r
-                //Now lets add the info to the main form dropdowns\r
-                frmMain form = (frmMain)frmMain.ActiveForm;\r
-                string title = t + " " + " " + d + " ";\r
-                form.drp_dvdtitle.Items.Add(title);\r
-            }\r
-            catch (Exception)\r
-            {\r
-                // Don't really need to do anything about it.\r
             }\r
+            this.Close();\r
         }\r
 \r
 \r
-        private void btn_ok_Click(object sender, EventArgs e)\r
-        {\r
-            scan(inputFile);\r
-        }\r
-\r
        \r
     }\r
 }
\ No newline at end of file
index 69e3c52546b4595b74d194759c5676231f03ce0d..d694413309a3788850f6a55ae732f3384798a129 100644 (file)
Binary files a/win/Handbrake.suo and b/win/Handbrake.suo differ