<Compile Include="frmOptions.Designer.cs">\r
<DependentUpon>frmOptions.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="HandBrake.cs" />\r
<Compile Include="Program.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
<EmbeddedResource Include="frmAbout.resx">\r
this.btn_close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
this.btn_close.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.btn_close.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
- this.btn_close.Location = new System.Drawing.Point(410, 208);\r
+ this.btn_close.Location = new System.Drawing.Point(415, 229);\r
this.btn_close.Name = "btn_close";\r
this.btn_close.Size = new System.Drawing.Size(99, 22);\r
this.btn_close.TabIndex = 27;\r
this.Label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.Label1.Location = new System.Drawing.Point(144, 161);\r
this.Label1.Name = "Label1";\r
- this.Label1.Size = new System.Drawing.Size(296, 39);\r
+ this.Label1.Size = new System.Drawing.Size(305, 52);\r
this.Label1.TabIndex = 22;\r
- this.Label1.Text = "\"Titer\" - The original developer of handbrake.\r\nEveryone on the current developme" +\r
- "nt team listed:\r\nhttp://handbrake.m0k.org/?page_id=9";\r
+ this.Label1.Text = "- \"Titer\" - The original developer of handbrake.\r\n- Everyone on the current devel" +\r
+ "opment team listed:\r\n http://handbrake.m0k.org/?page_id=9\r\n- Ported to C#.net w" +\r
+ "ith help from \"brianmario\"";\r
// \r
- // About\r
+ // frmAbout\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(526, 239);\r
+ this.ClientSize = new System.Drawing.Size(526, 259);\r
this.Controls.Add(this.Label4);\r
this.Controls.Add(this.btn_close);\r
this.Controls.Add(this.Version);\r
this.Controls.Add(this.PictureBox1);\r
this.Controls.Add(this.Label1);\r
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
- this.Name = "About";\r
+ this.Name = "frmAbout";\r
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
this.Text = "About Handbrake";\r
this.Load += new System.EventHandler(this.About_Load);\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.Label1 = new System.Windows.Forms.Label();\r
- this.rtf_dvdInfo = new System.Windows.Forms.RichTextBox();\r
this.SuspendLayout();\r
// \r
// Label4\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, 31);\r
+ this.Label4.Location = new System.Drawing.Point(66, 51);\r
this.Label4.Name = "Label4";\r
- this.Label4.Size = new System.Drawing.Size(130, 13);\r
+ this.Label4.Size = new System.Drawing.Size(178, 13);\r
this.Label4.TabIndex = 29;\r
- this.Label4.Text = "Press OK to continue.";\r
+ this.Label4.Text = "Press OK to start the process.";\r
// \r
// btn_ok\r
// \r
this.btn_ok.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
this.btn_ok.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.btn_ok.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
- this.btn_ok.Location = new System.Drawing.Point(405, 9);\r
+ this.btn_ok.Location = new System.Drawing.Point(405, 51);\r
this.btn_ok.Name = "btn_ok";\r
this.btn_ok.Size = new System.Drawing.Size(56, 22);\r
this.btn_ok.TabIndex = 28;\r
this.Label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.Label3.Location = new System.Drawing.Point(66, 9);\r
this.Label3.Name = "Label3";\r
- this.Label3.Size = new System.Drawing.Size(231, 13);\r
+ this.Label3.Size = new System.Drawing.Size(222, 26);\r
this.Label3.TabIndex = 27;\r
- this.Label3.Text = "The CLI is currently reading the DVD...";\r
+ this.Label3.Text = "The CLI is about to read the DVD...\r\nThis process can take up to 1 minute.";\r
// \r
// Label2\r
// \r
this.Label2.TabIndex = 26;\r
this.Label2.Text = "Status:";\r
// \r
- // Label1\r
- // \r
- this.Label1.AutoSize = true;\r
- this.Label1.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
- this.Label1.Location = new System.Drawing.Point(67, 49);\r
- this.Label1.Name = "Label1";\r
- this.Label1.Size = new System.Drawing.Size(269, 24);\r
- this.Label1.TabIndex = 25;\r
- this.Label1.Text = "Note: After pressing OK the window will remain open \r\nuntil the CLI has completed" +\r
- " the scan.";\r
- // \r
- // rtf_dvdInfo\r
- // \r
- this.rtf_dvdInfo.BorderStyle = System.Windows.Forms.BorderStyle.None;\r
- this.rtf_dvdInfo.Location = new System.Drawing.Point(11, 86);\r
- this.rtf_dvdInfo.Name = "rtf_dvdInfo";\r
- this.rtf_dvdInfo.Size = new System.Drawing.Size(450, 70);\r
- this.rtf_dvdInfo.TabIndex = 30;\r
- this.rtf_dvdInfo.Text = "";\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, 168);\r
- this.Controls.Add(this.rtf_dvdInfo);\r
+ this.ClientSize = new System.Drawing.Size(473, 86);\r
this.Controls.Add(this.Label4);\r
this.Controls.Add(this.btn_ok);\r
this.Controls.Add(this.Label3);\r
this.Controls.Add(this.Label2);\r
- this.Controls.Add(this.Label1);\r
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
this.Name = "frmReadDVD";\r
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
this.Text = "Reading DVD...";\r
- this.Load += new System.EventHandler(this.frmReadDVD_Load);\r
this.ResumeLayout(false);\r
this.PerformLayout();\r
\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 Label1;\r
- internal System.Windows.Forms.RichTextBox rtf_dvdInfo;\r
}\r
}
\ No newline at end of file
this.inputFile = inputFile;\r
}\r
\r
- private void frmReadDVD_Load(object sender, EventArgs e)\r
+ public void scan(string filename)\r
{\r
- //start(inputFile);\r
- }\r
-\r
- public void start(string filename)\r
- {\r
- MessageBox.Show(filename);\r
string query = "-i " + '"' + filename + '"' + " -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.StandardOutputEncoding = System.Text.Encoding.UTF8;\r
- //hbProc.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;\r
hbProc.StartInfo.Arguments = query;\r
hbProc.StartInfo.UseShellExecute = false;\r
hbProc.Start();\r
+ System.IO.StreamReader errorReader = new System.IO.StreamReader(new System.IO.BufferedStream(hbProc.StandardError.BaseStream));\r
+ //rtf_dvdInfo.AppendText(errorReader.ReadToEnd());\r
+ hbProc.WaitForExit();\r
+ hbProc.Close();\r
+\r
+ String DvdData = errorReader.ReadToEnd();\r
+ DvdData = DvdData + "-- end --";\r
+\r
+ String[] DvdDataArr = DvdData.Split('\n');\r
+ int DvdDataSize = DvdDataArr.Length -1;\r
+ String line = "";\r
+ int counter = 0;\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
+ {\r
+ line = DvdDataArr[counter];\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);\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);\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 titleData)\r
+ {\r
+ string[] titleInfo = new string[10];\r
+ string[] str = new string[1];\r
+\r
+ string title;\r
+ string t ="";\r
+ string d ="";\r
\r
- rtf_dvdInfo.Text = "-- Start --";\r
- while (hbProc.StandardOutput.BaseStream.CanRead && !hbProc.HasExited)\r
+ titleInfo = titleData.Split('~');\r
+ try\r
{\r
- rtf_dvdInfo.Text = rtf_dvdInfo.Text + "\n" + hbProc.StandardOutput.ReadLine();\r
- rtf_dvdInfo.Text = rtf_dvdInfo.Text + "\n" + hbProc.StandardError.ReadLine();\r
- MessageBox.Show("Test");\r
+ t = titleInfo[0].Trim().Substring(8).Replace(":", ""); // Title\r
+ d = titleInfo[1].Trim().Substring(12); //Duration\r
+ } catch(Exception){\r
+ MessageBox.Show("Incomplete DVD data found. Please copy the data on the View DVD Information tab and report this error.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
}\r
\r
- rtf_dvdInfo.Text = rtf_dvdInfo.Text + "\n" + "-- End --";\r
+ //Now lets add the info to the main form dropdowns\r
+ frmMain form = (frmMain)frmMain.ActiveForm;\r
+ title = t + " " + " " + d + " ";\r
+ form.drp_dvdtitle.Items.Add(title);\r
}\r
\r
private void btn_ok_Click(object sender, EventArgs e)\r