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
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
}\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
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
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
\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
using System.Drawing;\r
using System.Text;\r
using System.Windows.Forms;\r
+using System.IO;\r
+\r
\r
namespace Handbrake\r
{\r
{\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