using System.Text;\r
using System.Windows.Forms;\r
using System.Net;\r
+using System.IO;\r
\r
namespace Handbrake\r
{\r
// FILE MENU --------------------------------------------------------------\r
private void mnu_open_Click(object sender, EventArgs e)\r
{\r
+ string filename;\r
File_Open.ShowDialog();\r
+ filename = File_Open.FileName;\r
+ if (filename != "")\r
+ {\r
+ try\r
+ {\r
+ // Create StreamReader & open file\r
+ StreamReader line = new StreamReader(filename);\r
+ string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.\r
+ \r
+ // Read in the data and set the correct GUI component with the setting.\r
+ text_source.Text = line.ReadLine();\r
+ drp_dvdtitle.Text = line.ReadLine();\r
+ drop_chapterStart.Text = line.ReadLine();\r
+ drop_chapterFinish.Text = line.ReadLine();\r
+ text_destination.Text = line.ReadLine();\r
+ drp_videoEncoder.Text = line.ReadLine();\r
+ drp_audioCodec.Text = line.ReadLine();\r
+ text_width.Text = line.ReadLine();\r
+ text_height.Text = line.ReadLine();\r
+ text_top.Text = line.ReadLine();\r
+ text_bottom.Text = line.ReadLine();\r
+ text_left.Text = line.ReadLine();\r
+ text_right.Text = line.ReadLine();\r
+ drp_subtitle.Text = line.ReadLine();\r
+ text_bitrate.Text = line.ReadLine();\r
+ text_filesize.Text = line.ReadLine();\r
+ slider_videoQuality.Value = int.Parse(line.ReadLine());\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ check_2PassEncode.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ check_DeInterlace.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ check_grayscale.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ drp_videoFramerate.Text = line.ReadLine();\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ Check_ChapterMarkers.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ CheckPixelRatio.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ check_turbo.CheckState = CheckState.Checked;\r
+ }\r
+\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ check_largeFile.CheckState = CheckState.Checked;\r
+ }\r
+ \r
+ drp_audioBitrate.Text = line.ReadLine();\r
+ drp_audioSampleRate.Text = line.ReadLine();\r
+ drp_audioChannels.Text = line.ReadLine();\r
+ drp_audioMixDown.Text = line.ReadLine();\r
+ \r
+ // Advanced H264 Options\r
+ temporyLine = line.ReadLine();\r
+ if (temporyLine == "Checked")\r
+ {\r
+ CheckCRF.CheckState = CheckState.Checked;\r
+ }\r
+ rtf_h264advanced.Text = line.ReadLine();\r
+\r
+ // Close the stream\r
+ line.Close();\r
+\r
+\r
+ // Fix for SliderValue not appearing when Opening saved file\r
+ SliderValue.Text = slider_videoQuality.Value + "%";\r
+\r
+ } catch (Exception){\r
+ MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ }\r
+ }\r
}\r
\r
private void mnu_save_Click(object sender, EventArgs e)\r
{\r
+ // Note : All these declarations are not really needed and should be removed at some point.\r
+ // The values can simply be added directly to the WriteLine statments.\r
+ \r
+ //Source\r
+ string source = text_source.Text;\r
+ string dvdTitle = drp_dvdtitle.Text;\r
+ string ChapterStart = drop_chapterStart.Text;\r
+ string ChapterFinish = drop_chapterFinish.Text;\r
+ //Destination\r
+ string destination = text_destination.Text;\r
+ string videoEncoder = drp_videoEncoder.Text;\r
+ string audioEncoder = drp_audioCodec.Text;\r
+ string width = text_width.Text;\r
+ string height = text_height.Text;\r
+ //Picture Settings Tab\r
+ string cropTop = text_top.Text;\r
+ string cropBottom = text_bottom.Text;\r
+ string cropLeft = text_left.Text;\r
+ string cropRight = text_right.Text;\r
+ string subtitles = drp_subtitle.Text;\r
+ //Video Settings Tab\r
+ string videoBitrate = text_bitrate.Text;\r
+ string videoFilesize = text_filesize.Text;\r
+ string videoQuality = slider_videoQuality.Value.ToString();\r
+ string twoPassEncoding = check_2PassEncode.CheckState.ToString();\r
+ string deinterlace = check_DeInterlace.CheckState.ToString();\r
+ string grayscale = check_grayscale.CheckState.ToString();\r
+ string videoFramerate = drp_videoFramerate.Text;\r
+ string pixelRation = CheckPixelRatio.CheckState.ToString();\r
+ string ChapterMarkers = Check_ChapterMarkers.CheckState.ToString();\r
+ string turboH264 = check_turbo.CheckState.ToString();\r
+ string largeFile = check_largeFile.CheckState.ToString();\r
+ //Audio Settings Tab\r
+ string audioBitrate = drp_audioBitrate.Text;\r
+ string audioSampleRate = drp_audioSampleRate.Text;\r
+ string audioChannels = drp_audioChannels.Text;\r
+ string AudioMixDown = drp_audioMixDown.Text;\r
+ //H264 Tab\r
+ string CRF = CheckCRF.CheckState.ToString();\r
+ string advH264 = rtf_h264advanced.Text;\r
+\r
+ string filename;\r
File_Save.ShowDialog();\r
+ filename = File_Save.FileName;\r
+ if (filename != "")\r
+ {\r
+ try\r
+ {\r
+ // Create a StreamWriter and open the file\r
+ StreamWriter line = new StreamWriter(filename);\r
+\r
+ line.WriteLine(source);\r
+ line.WriteLine(dvdTitle);\r
+ line.WriteLine(ChapterStart);\r
+ line.WriteLine(ChapterFinish);\r
+ line.WriteLine(destination);\r
+ line.WriteLine(videoEncoder);\r
+ line.WriteLine(audioEncoder);\r
+ line.WriteLine(width);\r
+ line.WriteLine(height);\r
+ line.WriteLine(cropTop);\r
+ line.WriteLine(cropBottom);\r
+ line.WriteLine(cropLeft);\r
+ line.WriteLine(cropRight);\r
+ line.WriteLine(subtitles);\r
+ line.WriteLine(videoBitrate);\r
+ line.WriteLine(videoFilesize);\r
+ line.WriteLine(videoQuality);\r
+ line.WriteLine(twoPassEncoding);\r
+ line.WriteLine(deinterlace);\r
+ line.WriteLine(grayscale);\r
+ line.WriteLine(videoFramerate);\r
+ line.WriteLine(ChapterMarkers);\r
+ line.WriteLine(pixelRation);\r
+ line.WriteLine(turboH264);\r
+ line.WriteLine(largeFile);\r
+ line.WriteLine(audioBitrate);\r
+ line.WriteLine(audioSampleRate);\r
+ line.WriteLine(audioChannels);\r
+ line.WriteLine(AudioMixDown);\r
+ line.WriteLine(CRF);\r
+ line.WriteLine(advH264);\r
+ // close the stream\r
+ line.Close();\r
+ MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ }\r
+ catch(Exception)\r
+ {\r
+ MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ }\r
+ \r
+ }\r
}\r
\r
private void mnu_update_Click(object sender, EventArgs e)\r
text_height.BackColor = Color.White;\r
}\r
\r
- private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
+ private void drp_dvdtitle_Click(object sender, EventArgs e)\r
{\r
if (drp_dvdtitle.Items.Count == 1)\r
{\r
}\r
}\r
\r
+ private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
+ {\r
+ //TODO: Convert the Parsing Code.\r
+ } \r
+\r
//\r
// The Query Generation Function\r
//\r
// ----------------------------------------------------------------------\r
\r
return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;\r
- } \r
-\r
+ }\r
\r
// This is the END of the road ------------------------------------------------------------------------------\r
}\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
+ 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);\r
+ add(fullTitleData, titleData, duationData);\r
counter = counter + 1;\r
}\r
titleData = line;\r
}\r
}\r
\r
- public void add(string titleData)\r
+ public void add(string fullTitleData, string titleData, string durationData)\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
- titleInfo = titleData.Split('~');\r
try\r
{\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
+ 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
- title = t + " " + " " + d + " ";\r
- form.drp_dvdtitle.Items.Add(title);\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
}\r
\r
+\r
private void btn_ok_Click(object sender, EventArgs e)\r
{\r
scan(inputFile);\r