+/* frmMain.cs $\r
+ \r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.m0k.org/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
using System;\r
-using System.Collections.Generic;\r
+using System.Collections;\r
using System.ComponentModel;\r
using System.Data;\r
using System.Drawing;\r
using System.IO;\r
using System.Diagnostics;\r
using System.Threading;\r
+using System.Runtime.InteropServices;\r
+using System.Globalization;\r
+using System.Text.RegularExpressions;\r
\r
namespace Handbrake\r
{\r
public partial class frmMain : Form\r
{\r
- System.Diagnostics.Process hbProc;\r
+ // -------------------------------------------------------------- \r
+ // Applicaiton Startup Stuff\r
+ // --------------------------------------------------------------\r
+\r
+ #region Application Startup\r
+\r
+ // Some stuff that needs to be Initialized. \r
+ private Process hbProc;\r
+ private Parsing.DVD thisDVD;\r
+ private frmQueue queueWindow = new frmQueue();\r
+ private delegate void updateStatusChanger();\r
+ Functions.Common hb_common_func = new Functions.Common();\r
\r
public frmMain()\r
{\r
+ // Load the splash screen in this thread\r
+ Form splash = new frmSplashScreen();\r
+ splash.Show();\r
+\r
+ //Create a label that can be updated from the parent thread.\r
+ Label lblStatus = new Label();\r
+ lblStatus.Size = new Size(250, 20);\r
+ lblStatus.Location = new Point(10, 280);\r
+ splash.Controls.Add(lblStatus);\r
+\r
+ //Fire a thread to wait for 2 seconds. The splash screen will exit when the time expires\r
+ Thread timer = new Thread(splashTimer);\r
+ timer.Start();\r
+\r
InitializeComponent();\r
- }\r
\r
- // --------------------------------------------------------------\r
- // onLoad - setup the program ready for use.\r
- // --------------------------------------------------------------\r
- private void frmMain_Load(object sender, EventArgs e)\r
- {\r
- // Set the Version number lable to the corect version.\r
- Version.Text = "Version " + Properties.Settings.Default.GuiVersion;\r
+ // show the form, but leave disabled until preloading is complete then show the main form\r
+ this.Enabled = false;\r
\r
- // Run the update checker.\r
- updateCheck();\r
+ this.Show();\r
\r
- // Now load the users default if required.\r
- loadUserDefaults();\r
- \r
- }\r
+ // Forces frmMain to draw\r
+ Application.DoEvents();\r
\r
- public void loadUserDefaults()\r
- { \r
- try\r
+ // update the status\r
+ if (Properties.Settings.Default.updateStatus == "Checked")\r
{\r
- if (Properties.Settings.Default.defaultSettings == "Checked")\r
- {\r
- //Source\r
- text_source.Text = Properties.Settings.Default.DVDSource;\r
- drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;\r
- drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;\r
- drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;\r
- //Destination\r
- text_destination.Text = Properties.Settings.Default.VideoDest;\r
- drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;\r
- drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;\r
- text_width.Text = Properties.Settings.Default.Width;\r
- text_height.Text = Properties.Settings.Default.Height;\r
- //Picture Settings Tab\r
- drp_crop.Text = Properties.Settings.Default.CroppingOption;\r
- text_top.Text = Properties.Settings.Default.CropTop;\r
- text_bottom.Text = Properties.Settings.Default.CropBottom;\r
- text_left.Text = Properties.Settings.Default.CropLeft;\r
- text_right.Text = Properties.Settings.Default.CropRight;\r
- drp_subtitle.Text = Properties.Settings.Default.Subtitles;\r
- //Video Settings Tab\r
- text_bitrate.Text = Properties.Settings.Default.VideoBitrate;\r
- text_filesize.Text = Properties.Settings.Default.VideoFilesize;\r
- slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;\r
- if (Properties.Settings.Default.TwoPass == "Checked")\r
- {\r
- check_2PassEncode.CheckState = CheckState.Checked;\r
- }\r
- if (Properties.Settings.Default.DeInterlace == "Checked")\r
- {\r
- check_DeInterlace.CheckState = CheckState.Checked;\r
- }\r
- if (Properties.Settings.Default.Grayscale == "Checked")\r
- {\r
- check_grayscale.CheckState = CheckState.Checked;\r
- }\r
-\r
- drp_videoFramerate.Text = Properties.Settings.Default.Framerate;\r
+ lblStatus.Text = "Checking for updates ...";\r
+ Application.DoEvents();\r
+ Thread updateCheckThread = new Thread(startupUpdateCheck);\r
+ updateCheckThread.Start();\r
+ Thread.Sleep(100);\r
+ }\r
\r
- if (Properties.Settings.Default.PixelRatio == "Checked")\r
- {\r
- CheckPixelRatio.CheckState = CheckState.Checked;\r
- }\r
- if (Properties.Settings.Default.turboFirstPass == "Checked")\r
- {\r
- check_turbo.CheckState = CheckState.Checked;\r
- }\r
- if (Properties.Settings.Default.largeFile == "Checked")\r
- {\r
- check_largeFile.CheckState = CheckState.Checked;\r
- }\r
- //Audio Settings Tab\r
- drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;\r
- drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;\r
- drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;\r
- //H264 Tab\r
- if (Properties.Settings.Default.CRF == "Checked")\r
- {\r
- CheckCRF.CheckState = CheckState.Checked;\r
- }\r
- rtf_h264advanced.Text = Properties.Settings.Default.H264;\r
- }\r
+ // Load the presets\r
+ lblStatus.Text = "Loading Presets ...";\r
+ Application.DoEvents();\r
+ loadPresetPanel();\r
+ Thread.Sleep(200);\r
+ \r
+ // Now load the users default if required. (Will overide the above setting)\r
+ if (Properties.Settings.Default.defaultSettings == "Checked")\r
+ {\r
+ lblStatus.Text = "Loading User Default Settings...";\r
+ Application.DoEvents();\r
+ loadUserDefaults();\r
+ Thread.Sleep(100);\r
}\r
- catch (Exception)\r
+ else\r
+ loadNormalPreset();\r
+\r
+ // Enable or disable tooltips\r
+ if (Properties.Settings.Default.tooltipEnable == "Checked")\r
{\r
- // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.\r
+ lblStatus.Text = "Loading Tooltips ...";\r
+ Application.DoEvents();\r
+ ToolTip.Active = true;\r
+ Thread.Sleep(100);\r
}\r
- }\r
\r
- public void updateCheck()\r
+ // Set some defaults for the dropdown menus. Just incase the normal or user presets dont load.\r
+ drp_crop.SelectedIndex = 0;\r
+ drp_videoEncoder.SelectedIndex = 2;\r
+ drp_audioCodec.SelectedIndex = 0;\r
+\r
+ //Finished Loading\r
+ lblStatus.Text = "Loading Complete!";\r
+ Application.DoEvents();\r
+ Thread.Sleep(200);\r
+\r
+ // Wait until splash screen is done\r
+ while (timer.IsAlive)\r
+ { Thread.Sleep(100); }\r
+\r
+ //Close the splash screen\r
+ splash.Close();\r
+ splash.Dispose();\r
+\r
+ // Turn the interface back to the user\r
+ this.Enabled = true;\r
+ }\r
+ \r
+ private void startupUpdateCheck()\r
{\r
- if (Properties.Settings.Default.updateStatus == "Checked")\r
+ try\r
{\r
-\r
- try\r
+ if (this.InvokeRequired)\r
{\r
- String updateFile = Properties.Settings.Default.updateFile;\r
- WebClient client = new WebClient();\r
- String data = client.DownloadString(updateFile);\r
- String[] versionData = data.Split('\n');\r
-\r
- if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))\r
- {\r
- lbl_update.Visible = true;\r
- }\r
+ this.BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
+ return;\r
}\r
- //else fail displaying an error message.\r
- catch (Exception)\r
+ \r
+ Boolean update = hb_common_func.updateCheck();\r
+ if (update == true)\r
{\r
- //Silently ignore the error\r
+ frmUpdater updateWindow = new frmUpdater();\r
+ updateWindow.Show();\r
}\r
}\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show(exc.ToString());\r
+ }\r
}\r
\r
- // --------------------------------------------------------------\r
- // Some windows that require only 1 instance.\r
- // --------------------------------------------------------------\r
+ private void splashTimer(object sender)\r
+ {\r
+ Thread.Sleep(1000); //sit for 1 seconds then exit\r
+ }\r
\r
- private frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
- private frmQueue queueWindow = new frmQueue();\r
+ private void showSplash(object sender)\r
+ {\r
+ Form splash = new frmSplashScreen();\r
+ splash.Show();\r
+ }\r
\r
- // --------------------------------------------------------------\r
- // The Menu Bar\r
- // --------------------------------------------------------------\r
+ private void loadUserDefaults()\r
+ {\r
+ string userDefaults = Properties.Settings.Default.defaultUserSettings;\r
+ try\r
+ {\r
+ // Some things that need to be done to reset some gui components:\r
+ CheckPixelRatio.CheckState = CheckState.Unchecked;\r
+\r
+ // Send the query from the file to the Query Parser class Then load the preset\r
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
+ hb_common_func.presetLoader(this, presetQuery, "User Defaults ");\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("Unable to load user Default Settings. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ #region Set Varible Function\r
+ public void setStreamReader(Parsing.DVD dvd)\r
+ {\r
+ this.thisDVD = dvd;\r
+ }\r
+ #endregion\r
+\r
+ // -------------------------------------------------------------- \r
+ // The main Menu bar.\r
+ // -------------------------------------------------------------- \r
\r
- // FILE MENU --------------------------------------------------------------\r
+ #region 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
+\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
+ // Send the query from the file to the Query Parser class then load the preset\r
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(line.ReadLine());\r
+ hb_common_func.presetLoader(this, presetQuery, filename);\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
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("Unable to load profile. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
}\r
}\r
}\r
\r
private void mnu_save_Click(object sender, EventArgs e)\r
{\r
-\r
string filename;\r
File_Save.ShowDialog();\r
filename = File_Save.FileName;\r
// Create a StreamWriter and open the file\r
StreamWriter line = new StreamWriter(filename);\r
\r
- //Source\r
- line.WriteLine(text_source.Text);\r
- line.WriteLine(drp_dvdtitle.Text);\r
- line.WriteLine(drop_chapterStart.Text);\r
- line.WriteLine(drop_chapterFinish.Text);\r
- //Destination\r
- line.WriteLine(text_destination.Text);\r
- line.WriteLine(drp_videoEncoder.Text);\r
- line.WriteLine(drp_audioCodec.Text);\r
- line.WriteLine(text_width.Text);\r
- line.WriteLine(text_height.Text);\r
- //Picture Settings Tab\r
- line.WriteLine(text_top.Text);\r
- line.WriteLine(text_bottom.Text);\r
- line.WriteLine(text_left.Text);\r
- line.WriteLine(text_right.Text);\r
- line.WriteLine(drp_subtitle.Text);\r
- //Video Settings Tab\r
- line.WriteLine(text_bitrate.Text);\r
- line.WriteLine(text_filesize.Text);\r
- line.WriteLine(slider_videoQuality.Value.ToString());\r
- line.WriteLine(check_2PassEncode.CheckState.ToString());\r
- line.WriteLine(check_DeInterlace.CheckState.ToString());\r
- line.WriteLine(check_grayscale.CheckState.ToString());\r
- line.WriteLine(drp_videoFramerate.Text);\r
- line.WriteLine(Check_ChapterMarkers.CheckState.ToString());\r
- line.WriteLine(CheckPixelRatio.CheckState.ToString());\r
- line.WriteLine(check_turbo.CheckState.ToString());\r
- line.WriteLine(check_largeFile.CheckState.ToString());\r
- //Audio Settings Tab\r
- line.WriteLine(drp_audioBitrate.Text);\r
- line.WriteLine(drp_audioSampleRate.Text);\r
- line.WriteLine(drp_audioChannels.Text);\r
- line.WriteLine(drp_audioMixDown.Text);\r
- //H264 Tab\r
- line.WriteLine(CheckCRF.CheckState.ToString());\r
- line.WriteLine(rtf_h264advanced.Text);\r
+ // Generate and write the query string to the file\r
+ String query = hb_common_func.GenerateTheQuery(this);\r
+ line.WriteLine(query);\r
+\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
+ 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
- {\r
- Form Update = new frmUpdate();\r
- Update.ShowDialog();\r
+ }\r
}\r
\r
private void mnu_exit_Click(object sender, EventArgs e)\r
{\r
- this.Close();\r
+ Application.Exit();\r
}\r
\r
- // TOOLS MENU --------------------------------------------------------------\r
+ #endregion\r
+\r
+ #region Tools Menu\r
+\r
private void mnu_encode_Click(object sender, EventArgs e)\r
{\r
showQueue();\r
\r
private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
{\r
+ frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
dvdInfoWindow.Show();\r
}\r
\r
Options.ShowDialog();\r
}\r
\r
- // PRESETS MENU --------------------------------------------------------------\r
- private void mnu_preset_ipod133_Click(object sender, EventArgs e)\r
- {\r
- CheckPixelRatio.CheckState = CheckState.Unchecked;\r
- text_width.Text = "640";\r
- text_height.Text = "480";\r
- drp_videoEncoder.Text = "H.264 (iPod)";\r
- text_bitrate.Text = "1000";\r
- text_filesize.Text = "";\r
- slider_videoQuality.Value = 0;\r
- SliderValue.Text = "0%";\r
- drp_audioBitrate.Text = "160";\r
- rtf_h264advanced.Text = "";\r
- drp_crop.Text = "No Crop";\r
- }\r
\r
- private void mnu_preset_ipod178_Click(object sender, EventArgs e)\r
- {\r
- CheckPixelRatio.CheckState = CheckState.Unchecked;\r
- text_width.Text = "640";\r
- text_height.Text = "352";\r
- drp_videoEncoder.Text = "H.264 (iPod)";\r
- text_bitrate.Text = "1000";\r
- text_filesize.Text = "";\r
- slider_videoQuality.Value = 0;\r
- SliderValue.Text = "0%";\r
- drp_audioBitrate.Text = "160";\r
- rtf_h264advanced.Text = "";\r
- drp_crop.Text = "No Crop";\r
- }\r
+ #endregion\r
\r
- private void mnu_preset_ipod235_Click(object sender, EventArgs e)\r
- {\r
- CheckPixelRatio.CheckState = CheckState.Unchecked;\r
- text_width.Text = "640";\r
- text_height.Text = "272";\r
- drp_videoEncoder.Text = "H.264 (iPod)";\r
- text_bitrate.Text = "1000";\r
- text_filesize.Text = "";\r
- slider_videoQuality.Value = 0;\r
- SliderValue.Text = "0%";\r
- drp_audioBitrate.Text = "160";\r
- rtf_h264advanced.Text = "";\r
- drp_crop.Text = "No Crop";\r
- }\r
+ #region Presets Menu\r
\r
- private void mnu_appleTv_Click(object sender, EventArgs e)\r
+ private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
- text_width.Text = "";\r
- text_height.Text = "";\r
- drp_videoEncoder.Text = "H.264";\r
- text_bitrate.Text = "3000";\r
- text_filesize.Text = "";\r
- slider_videoQuality.Value = 0;\r
- SliderValue.Text = "0%";\r
- drp_audioBitrate.Text = "160";\r
- CheckPixelRatio.CheckState = CheckState.Checked;\r
- drp_audioSampleRate.Text = "48";\r
- rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";\r
- drp_crop.Text = "No Crop";\r
- \r
+ treeView_presets.Nodes.Clear();\r
+ grabCLIPresets();\r
+ loadPresetPanel();\r
+ if (treeView_presets.Nodes.Count == 0)\r
+ MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ else\r
+ MessageBox.Show("Presets have been updated", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
}\r
\r
- private void mnu_presetPS3_Click(object sender, EventArgs e)\r
+ private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
{\r
- CheckPixelRatio.CheckState = CheckState.Unchecked;\r
- text_width.Text = "";\r
- text_height.Text = "";\r
- drp_videoEncoder.Text = "H.264";\r
- text_bitrate.Text = "3000";\r
- text_filesize.Text = "";\r
- slider_videoQuality.Value = 0;\r
- SliderValue.Text = "0%";\r
- drp_audioBitrate.Text = "160";\r
- CheckPixelRatio.CheckState = CheckState.Checked;\r
- drp_audioSampleRate.Text = "48";\r
- rtf_h264advanced.Text = "level=41";\r
- drp_crop.Text = "No Crop";\r
+ loadNormalPreset();\r
}\r
\r
- private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)\r
- {\r
- //Source\r
- Properties.Settings.Default.DVDSource = text_source.Text;\r
- Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;\r
- Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;\r
- Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;\r
- //Destination\r
- Properties.Settings.Default.VideoDest = text_destination.Text;\r
- Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;\r
- Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;\r
- Properties.Settings.Default.Width = text_width.Text;\r
- Properties.Settings.Default.Height = text_height.Text;\r
- //Picture Settings Tab\r
- Properties.Settings.Default.CroppingOption = drp_crop.Text;\r
- Properties.Settings.Default.CropTop = text_top.Text;\r
- Properties.Settings.Default.CropBottom = text_bottom.Text;\r
- Properties.Settings.Default.CropLeft = text_left.Text;\r
- Properties.Settings.Default.CropRight = text_right.Text;\r
- Properties.Settings.Default.Subtitles = drp_subtitle.Text;\r
- //Video Settings Tab\r
- Properties.Settings.Default.VideoBitrate = text_bitrate.Text;\r
- Properties.Settings.Default.VideoFilesize = text_filesize.Text;\r
- Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;\r
- Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();\r
- Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();\r
- Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();\r
- Properties.Settings.Default.Framerate = drp_videoFramerate.Text;\r
- Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();\r
- Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();\r
- Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();\r
- //Audio Settings Tab\r
- Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;\r
- Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;\r
- Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;\r
- //H264 Tab\r
- Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();\r
- Properties.Settings.Default.H264 = rtf_h264advanced.Text;\r
- Properties.Settings.Default.Save();\r
- }\r
+ #endregion\r
+\r
+ #region Help Menu\r
\r
- // Help Menu --------------------------------------------------------------\r
private void mnu_wiki_Click(object sender, EventArgs e)\r
{\r
- Process.Start("http://handbrake.m0k.org/trac");\r
+ Process.Start("http://handbrake.m0k.org/trac");\r
}\r
\r
- private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
+ private void mnu_faq_Click(object sender, EventArgs e)\r
{\r
- Process.Start("http://handbrake.m0k.org/?page_id=11");\r
+ Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
}\r
\r
- private void mnu_faq_Click(object sender, EventArgs e)\r
+ private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
{\r
- Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
+ Process.Start("http://handbrake.m0k.org/?page_id=11");\r
}\r
\r
private void mnu_homepage_Click(object sender, EventArgs e)\r
{\r
- Process.Start("http://handbrake.m0k.org");\r
+ Process.Start("http://handbrake.m0k.org");\r
}\r
\r
private void mnu_forum_Click(object sender, EventArgs e)\r
Process.Start("http://handbrake.m0k.org/forum");\r
}\r
\r
+ private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
+ {\r
+ Boolean update = hb_common_func.updateCheck();\r
+ if (update == true)\r
+ {\r
+ frmUpdater updateWindow = new frmUpdater();\r
+ updateWindow.Show();\r
+ }\r
+ else\r
+ MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+ }\r
+\r
private void mnu_about_Click(object sender, EventArgs e)\r
{\r
- Form About = new frmAbout();\r
+ Form About = new frmAbout();\r
About.ShowDialog();\r
}\r
\r
-\r
+ #endregion\r
\r
// -------------------------------------------------------------- \r
- // Buttons on the main Window\r
+ // Buttons on the main Window and items that require actions\r
// --------------------------------------------------------------\r
+\r
+ #region Buttons\r
+\r
private void btn_Browse_Click(object sender, EventArgs e)\r
{\r
- \r
- String filename ="";\r
+ String filename = "";\r
text_source.Text = "";\r
+ frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
\r
if (RadioDVD.Checked)\r
{\r
DVD_Open.ShowDialog();\r
filename = DVD_Open.SelectedPath;\r
- if (filename != "")\r
- {\r
- text_source.Text = filename;\r
- Form frmReadDVD = new frmReadDVD(filename, this, dvdInfoWindow);\r
- frmReadDVD.ShowDialog();\r
- }\r
}\r
else\r
{\r
ISO_Open.ShowDialog();\r
filename = ISO_Open.FileName;\r
- if (filename != "")\r
- {\r
- text_source.Text = filename;\r
- Form frmReadDVD = new frmReadDVD(filename, this, dvdInfoWindow);\r
- frmReadDVD.ShowDialog();\r
- }\r
- } \r
+ }\r
\r
- // Quick check to make sure some titles were found.\r
if (filename != "")\r
{\r
- if (drp_dvdtitle.Items.Count == 0)\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
+ Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);\r
+ text_source.Text = filename;\r
+ frmRD.ShowDialog();\r
}\r
else\r
- {\r
text_source.Text = "Click 'Browse' to continue";\r
- }\r
\r
+ // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
+ if (drp_dvdtitle.Items.Count == 0)\r
+ MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source. Please refer to the FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
}\r
\r
private void btn_destBrowse_Click(object sender, EventArgs e)\r
{\r
- // TODO: Need to write some code to check if there is a reasonable amount of disk space left.\r
+ // This removes the file extension from the filename box on the save file dialog.\r
+ // It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.\r
+ DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", "");\r
\r
+ // Show the dialog and set the main form file path\r
DVD_Save.ShowDialog();\r
text_destination.Text = DVD_Save.FileName;\r
\r
+ // Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)\r
if (Check_ChapterMarkers.Checked)\r
- {\r
- string destination = text_destination.Text;\r
- destination = destination.Replace(".mp4", ".m4v");\r
- text_destination.Text = destination;\r
- }\r
+ text_destination.Text = text_destination.Text.Replace(".mp4", ".m4v");\r
}\r
\r
private void btn_h264Clear_Click(object sender, EventArgs e)\r
rtf_h264advanced.Text = "";\r
}\r
\r
- private void GenerateQuery_Click(object sender, EventArgs e)\r
+ private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
{\r
- String query = GenerateTheQuery();\r
- QueryEditorText.Text = query;\r
+ Form ActivityWindow = new frmActivityWindow();\r
+ ActivityWindow.ShowDialog();\r
}\r
\r
- private void btn_ClearQuery_Click(object sender, EventArgs e)\r
- {\r
- QueryEditorText.Text = "";\r
- }\r
+ #endregion\r
\r
- private void btn_queue_Click(object sender, EventArgs e)\r
- {\r
- String query = GenerateTheQuery();\r
- queueWindow.list_queue.Items.Add(query);\r
- queueWindow.Show();\r
- }\r
+ #region frmMain Actions\r
\r
- private void showQueue()\r
+ private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- queueWindow.Show();\r
- }\r
+ // Reset some values on the form\r
+ lbl_Aspect.Text = "Select a Title";\r
+ lbl_RecomendedCrop.Text = "Select a Title";\r
+ drop_chapterStart.Items.Clear();\r
+ drop_chapterFinish.Items.Clear();\r
\r
- private void btn_encode_Click(object sender, EventArgs e)\r
- {\r
- String query = "";\r
- \r
- if (QueryEditorText.Text == "")\r
- {\r
- query = GenerateTheQuery();\r
- }\r
- else\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
- 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
+ Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;\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
+ // Set the Aspect Ratio\r
+ lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();\r
\r
- ThreadPool.QueueUserWorkItem(procMonitor);\r
- // TODO: Need to write a bit of code here to do process monitoring.\r
- }\r
+ // Set the Recommended Cropping values\r
+ lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);\r
\r
- private void procMonitor(object state)\r
- {\r
- MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
- hbProc.WaitForExit();\r
- hbProc.Close();\r
- hbProc.Dispose();\r
- MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
- }\r
+ // Populate the Start chapter Dropdown\r
+ drop_chapterStart.Items.Clear();\r
+ drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());\r
+ if (drop_chapterStart.Items.Count > 0)\r
+ drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();\r
\r
+ // Populate the Final Chapter Dropdown\r
+ drop_chapterFinish.Items.Clear();\r
+ drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());\r
+ if (drop_chapterFinish.Items.Count > 0)\r
+ drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
+\r
+ // Populate the Audio Channels Dropdown\r
+ drp_track1Audio.Items.Clear();\r
+ drp_track1Audio.Items.Add("Automatic");\r
+ drp_track1Audio.Items.Add("None");\r
+ drp_track1Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
+ if (drp_track1Audio.Items.Count > 0)\r
+ drp_track1Audio.Text = drp_track1Audio.Items[0].ToString();\r
+\r
+ drp_track2Audio.Items.Clear();\r
+ drp_track2Audio.Items.Add("None");\r
+ drp_track2Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
+ if (drp_track2Audio.Items.Count > 0)\r
+ drp_track2Audio.Text = drp_track2Audio.Items[0].ToString();\r
+\r
+ // Populate the Subtitles dropdown\r
+ drp_subtitle.Items.Clear();\r
+ drp_subtitle.Items.Add("None");\r
+ drp_subtitle.Items.Add("Autoselect");\r
+ drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
+ if (drp_subtitle.Items.Count > 0)\r
+ drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
\r
- // -------------------------------------------------------------- \r
- // Items that require actions on frmMain\r
- // --------------------------------------------------------------\r
+ }\r
\r
+ // Run the autoName & chapterNaming functions\r
+ hb_common_func.autoName(this);\r
+ hb_common_func.chapterNaming(this);\r
+ }\r
\r
private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- QueryEditorText.Text = "";\r
+ drop_chapterStart.BackColor = Color.White;\r
if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
{\r
try\r
int chapterStart = int.Parse(drop_chapterStart.Text);\r
\r
if (chapterFinish < chapterStart)\r
- {\r
- MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- }\r
+ drop_chapterStart.BackColor = Color.LightCoral;\r
}\r
catch (Exception)\r
{\r
- MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ drop_chapterStart.BackColor = Color.LightCoral;\r
}\r
}\r
-\r
- \r
+ // Run the Autonaming function\r
+ hb_common_func.autoName(this);\r
}\r
\r
private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- QueryEditorText.Text = "";\r
+ drop_chapterFinish.BackColor = Color.White;\r
if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
{\r
try\r
int chapterStart = int.Parse(drop_chapterStart.Text);\r
\r
if (chapterFinish < chapterStart)\r
- {\r
- MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- }\r
+ drop_chapterFinish.BackColor = Color.LightCoral;\r
}\r
catch (Exception)\r
{\r
- MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ drop_chapterFinish.BackColor = Color.LightCoral;\r
}\r
}\r
+\r
+ // Run the Autonaming function\r
+ hb_common_func.autoName(this);\r
}\r
\r
private void text_bitrate_TextChanged(object sender, EventArgs e)\r
text_filesize.Text = "";\r
slider_videoQuality.Value = 0;\r
SliderValue.Text = "0%";\r
- CheckCRF.CheckState = CheckState.Unchecked;\r
}\r
\r
private void text_filesize_TextChanged(object sender, EventArgs e)\r
text_bitrate.Text = "";\r
slider_videoQuality.Value = 0;\r
SliderValue.Text = "0%";\r
- CheckCRF.CheckState = CheckState.Unchecked;\r
}\r
\r
private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
{\r
try\r
{\r
- if (CheckPixelRatio.Checked) {\r
+ if (CheckPixelRatio.Checked)\r
+ {\r
text_width.Text = "";\r
- } else {\r
- if ((int.Parse(text_width.Text) % 16) != 0){\r
+ text_width.BackColor = Color.LightCoral;\r
+ CheckPixelRatio.BackColor = Color.LightCoral;\r
+ }\r
+ else\r
+ {\r
+ if ((int.Parse(text_width.Text) % 16) != 0)\r
text_width.BackColor = Color.LightCoral;\r
- }else {\r
+ else\r
text_width.BackColor = Color.LightGreen;\r
- }\r
}\r
\r
- // There is a bug here *******************************************************************\r
- if (!lbl_Aspect.Text.Equals("Select a Title")){\r
- int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);\r
- MessageBox.Show("test");\r
- int mod16 = height % 16;\r
+ if ((lbl_Aspect.Text != "Select a Title") && (drp_crop.SelectedIndex == 2))\r
+ {\r
+ double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);\r
+ double mod16 = height % 16;\r
height = height - mod16;\r
- text_height.Text = height.ToString();\r
+\r
+ if (text_width.Text == "")\r
+ {\r
+ text_height.Text = "";\r
+ text_width.BackColor = Color.White;\r
+ }\r
+ else\r
+ text_height.Text = height.ToString();\r
}\r
- \r
- } catch(Exception){\r
- // No need to alert the user if there is a problem here.\r
+ }\r
+ catch (Exception)\r
+ {\r
+ // No need to throw an error here.\r
}\r
}\r
\r
if (CheckPixelRatio.Checked)\r
{\r
text_height.Text = "";\r
+ text_height.BackColor = Color.LightCoral;\r
+ CheckPixelRatio.BackColor = Color.LightCoral;\r
}\r
else\r
{\r
if ((int.Parse(text_height.Text) % 16) != 0)\r
- {\r
text_height.BackColor = Color.LightCoral;\r
- }\r
else\r
- {\r
text_height.BackColor = Color.LightGreen;\r
- }\r
}\r
- } catch(Exception){\r
- // No need to alert the user.\r
- }\r
- }\r
+\r
+ }\r
+ catch (Exception)\r
+ {\r
+ // No need to alert the user.\r
+ }\r
+ }\r
\r
private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- if ((string)drp_crop.SelectedItem == "Manual")\r
+ if ((string)drp_crop.SelectedItem == "Custom")\r
{\r
- text_left.Enabled = true;\r
- text_right.Enabled = true;\r
- text_top.Enabled = true;\r
- text_bottom.Enabled = true;\r
+ text_left.Enabled = true;\r
+ text_right.Enabled = true;\r
+ text_top.Enabled = true;\r
+ text_bottom.Enabled = true;\r
+ text_left.Text = "0";\r
+ text_right.Text = "0";\r
+ text_top.Text = "0";\r
+ text_bottom.Text = "0";\r
}\r
\r
- if ((string)drp_crop.SelectedItem == "Auto Crop")\r
+ if ((string)drp_crop.SelectedItem == "Automatic")\r
{\r
text_left.Enabled = false;\r
text_right.Enabled = false;\r
text_top.Enabled = false;\r
text_bottom.Enabled = false;\r
- text_left.Text = "";\r
- text_right.Text = "";\r
- text_top.Text = "";\r
- text_bottom.Text = "";\r
\r
if (lbl_RecomendedCrop.Text != "Select a Title")\r
{\r
text_top.Text = temp[0];\r
text_bottom.Text = temp[1];\r
}\r
+ else\r
+ {\r
+ text_left.Text = "";\r
+ text_right.Text = "";\r
+ text_top.Text = "";\r
+ text_bottom.Text = "";\r
+ }\r
}\r
\r
if ((string)drp_crop.SelectedItem == "No Crop")\r
\r
}\r
}\r
- \r
+\r
+ private void check_vfr_CheckedChanged(object sender, EventArgs e)\r
+ {\r
+ if (check_vfr.CheckState == CheckState.Checked)\r
+ {\r
+ check_detelecine.Enabled = false;\r
+ check_detelecine.CheckState = CheckState.Checked;\r
+ drp_videoFramerate.Enabled = false;\r
+ drp_videoFramerate.SelectedItem = "29.97";\r
+ lbl_vfr.Visible = true;\r
+ }\r
+ else\r
+ {\r
+ check_detelecine.Enabled = true;\r
+ drp_videoFramerate.Enabled = true;\r
+ drp_videoFramerate.SelectedItem = "Automatic";\r
+ lbl_vfr.Visible = false;\r
+ }\r
+ }\r
+\r
private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)\r
{\r
text_width.Text = "";\r
text_height.Text = "";\r
text_width.BackColor = Color.White;\r
text_height.BackColor = Color.White;\r
+ CheckPixelRatio.BackColor = TabPage1.BackColor;\r
+\r
+ if (CheckPixelRatio.Checked)\r
+ {\r
+ check_lAnamorphic.Enabled = false;\r
+ check_lAnamorphic.Checked = false;\r
+ text_height.BackColor = Color.LightGray;\r
+ text_width.BackColor = Color.LightGray;\r
+ text_height.Enabled = false;\r
+ text_width.Enabled = false;\r
+ }\r
+ else\r
+ {\r
+ check_lAnamorphic.Enabled = true;\r
+ text_height.BackColor = Color.White;\r
+ text_width.BackColor = Color.White;\r
+ text_height.Enabled = true;\r
+ text_width.Enabled = true;\r
+ }\r
}\r
\r
- private void drp_dvdtitle_Click(object sender, EventArgs e)\r
+ private void check_lAnamorphic_CheckedChanged(object sender, EventArgs e)\r
{\r
- if (drp_dvdtitle.Items.Count == 1)\r
+ if (check_lAnamorphic.Checked)\r
{\r
- MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ CheckPixelRatio.Enabled = false;\r
+ CheckPixelRatio.Checked = false;\r
+ text_height.Text = "";\r
+ text_height.Enabled = false;\r
+ text_height.BackColor = Color.LightGray;\r
+ }\r
+ else\r
+ {\r
+ CheckPixelRatio.Enabled = true;\r
+ text_height.Enabled = true;\r
+ text_height.BackColor = Color.White;\r
}\r
}\r
\r
- private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
+ private void check_2PassEncode_CheckedChanged(object sender, EventArgs e)\r
{\r
+ if (check_2PassEncode.CheckState.ToString() == "Checked")\r
+ {\r
+ if (drp_videoEncoder.Text.Contains("H.264"))\r
+ check_turbo.Enabled = true;\r
+ }\r
+ else\r
+ {\r
+ check_turbo.Enabled = false;\r
+ check_turbo.CheckState = CheckState.Unchecked;\r
+ }\r
+ }\r
\r
- //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch\r
+ private void check_largeFile_CheckedChanged(object sender, EventArgs e)\r
+ {\r
+ if (!text_destination.Text.Contains(".mp4"))\r
+ {\r
+ lbl_largeMp4Warning.Text = "Warning: Only mp4 files are supported";\r
+ lbl_largeMp4Warning.ForeColor = Color.Red;\r
+ check_largeFile.CheckState = CheckState.Unchecked;\r
+ }\r
+ else\r
+ {\r
+ lbl_largeMp4Warning.Text = "Warning: Breaks iPod, @TV, PS3 compatibility.";\r
+ lbl_largeMp4Warning.ForeColor = Color.Black;\r
+ }\r
+ }\r
+\r
+ private void check_iPodAtom_CheckedChanged(object sender, EventArgs e)\r
+ {\r
+ if (!text_destination.Text.Contains(".mp4"))\r
+ {\r
+ lbl_ipodAtom.Visible = true;\r
+ check_iPodAtom.CheckState = CheckState.Unchecked;\r
+ }\r
+ else\r
+ lbl_ipodAtom.Visible = false;\r
+ }\r
+\r
+ private void check_optimiseMP4_CheckedChanged(object sender, EventArgs e)\r
+ {\r
+ if (!text_destination.Text.Contains(".mp4"))\r
+ {\r
+ check_optimiseMP4.BackColor = Color.LightCoral;\r
+ check_optimiseMP4.CheckState = CheckState.Unchecked;\r
+ }\r
+ else\r
+ check_optimiseMP4.BackColor = Color.Transparent;\r
+ }\r
\r
- drp_audioMixDown.Items.Clear();\r
+ private void drp_dvdtitle_Click(object sender, EventArgs e)\r
+ {\r
+ if (drp_dvdtitle.Items.Count == 0)\r
+ MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ }\r
\r
+ private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
+ {\r
if (drp_audioCodec.Text == "AAC")\r
{\r
drp_audioMixDown.Items.Clear();\r
drp_audioMixDown.Items.Add("Dolby Surround");\r
drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
drp_audioMixDown.Items.Add("6 Channel Discrete");\r
- \r
+\r
drp_audioBitrate.Items.Clear();\r
drp_audioBitrate.Items.Add("32");\r
drp_audioBitrate.Items.Add("40");\r
drp_audioBitrate.Items.Add("224");\r
drp_audioBitrate.Items.Add("256");\r
drp_audioBitrate.Items.Add("320");\r
- drp_audioBitrate.Items.Add("384");\r
}\r
}\r
\r
private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- if (drp_audioCodec.Text == "AAC")\r
+ if ((drp_audioCodec.Text == "AAC") && (drp_audioMixDown.Text == "6 Channel Discrete"))\r
{\r
- if (drp_audioMixDown.Text == "6 Channel Discrete")\r
- {\r
-\r
- drp_audioBitrate.Items.Clear();\r
- drp_audioBitrate.Items.Add("32");\r
- drp_audioBitrate.Items.Add("40");\r
- drp_audioBitrate.Items.Add("48");\r
- drp_audioBitrate.Items.Add("56");\r
- drp_audioBitrate.Items.Add("64");\r
- drp_audioBitrate.Items.Add("80");\r
- drp_audioBitrate.Items.Add("86");\r
- drp_audioBitrate.Items.Add("112");\r
- drp_audioBitrate.Items.Add("128");\r
- drp_audioBitrate.Items.Add("160");\r
- drp_audioBitrate.Items.Add("192");\r
- drp_audioBitrate.Items.Add("224");\r
- drp_audioBitrate.Items.Add("256");\r
- drp_audioBitrate.Items.Add("320");\r
- drp_audioBitrate.Items.Add("384");\r
- }\r
+ drp_audioBitrate.Items.Clear();\r
+ drp_audioBitrate.Items.Add("32");\r
+ drp_audioBitrate.Items.Add("40");\r
+ drp_audioBitrate.Items.Add("48");\r
+ drp_audioBitrate.Items.Add("56");\r
+ drp_audioBitrate.Items.Add("64");\r
+ drp_audioBitrate.Items.Add("80");\r
+ drp_audioBitrate.Items.Add("86");\r
+ drp_audioBitrate.Items.Add("112");\r
+ drp_audioBitrate.Items.Add("128");\r
+ drp_audioBitrate.Items.Add("160");\r
+ drp_audioBitrate.Items.Add("192");\r
+ drp_audioBitrate.Items.Add("224");\r
+ drp_audioBitrate.Items.Add("256");\r
+ drp_audioBitrate.Items.Add("320");\r
+ drp_audioBitrate.Items.Add("384");\r
}\r
}\r
\r
- private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
+ private void slider_drc_Scroll(object sender, EventArgs e)\r
{\r
- if (Check_ChapterMarkers.Checked)\r
- {\r
- string destination = text_destination.Text;\r
- destination = destination.Replace(".mp4", ".m4v");\r
- text_destination.Text = destination;\r
- }\r
+ double value = slider_drc.Value / 10.0;\r
+ value++;\r
+\r
+ lbl_drc.Text = value.ToString();\r
}\r
\r
- private void check_largeFile_CheckedChanged(object sender, EventArgs e)\r
+ private void drp_subtitle_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- if (!text_destination.Text.Contains(".mp4"))\r
+ if (drp_subtitle.Text.Contains("None"))\r
{\r
- MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- check_largeFile.CheckState = CheckState.Unchecked;\r
+ check_forced.Enabled = false;\r
+ check_forced.Checked = false;\r
}\r
+ else\r
+ check_forced.Enabled = true;\r
}\r
\r
- private void check_turbo_CheckedChanged(object sender, EventArgs e)\r
+ private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
{\r
- if (!drp_videoEncoder.Text.Contains("H.264"))\r
+ if (Check_ChapterMarkers.Checked)\r
{\r
- MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- check_turbo.CheckState = CheckState.Unchecked;\r
+ string destination = text_destination.Text;\r
+ destination = destination.Replace(".mp4", ".m4v");\r
+ text_destination.Text = destination;\r
+ data_chpt.Rows.Clear();\r
+ data_chpt.Enabled = true;\r
+ hb_common_func.chapterNaming(this);\r
+ }\r
+ else\r
+ {\r
+ string destination = text_destination.Text;\r
+ destination = destination.Replace(".m4v", ".mp4");\r
+ text_destination.Text = destination;\r
+ data_chpt.Rows.Clear();\r
+ data_chpt.Enabled = false;\r
}\r
}\r
\r
if (!drp_videoEncoder.Text.Contains("H.264"))\r
{\r
check_turbo.CheckState = CheckState.Unchecked;\r
- CheckCRF.CheckState = CheckState.Unchecked;\r
+ check_turbo.Enabled = false;\r
+ h264Tab.Enabled = false;\r
+ rtf_h264advanced.Text = "";\r
+ check_iPodAtom.Enabled = false;\r
+ check_iPodAtom.Checked = false;\r
+ lbl_ipodAtom.Visible = false;\r
+ check_optimiseMP4.Enabled = false;\r
+ check_lAnamorphic.Enabled = false;\r
+ check_lAnamorphic.Checked = false;\r
}\r
- }\r
-\r
- private void CheckCRF_CheckedChanged(object sender, EventArgs e)\r
- {\r
- if (slider_videoQuality.Value == 0)\r
+ else\r
{\r
- MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- CheckCRF.CheckState = CheckState.Unchecked;\r
+ if (check_2PassEncode.CheckState == CheckState.Checked)\r
+ check_turbo.Enabled = true;\r
+\r
+ h264Tab.Enabled = true;\r
+ check_iPodAtom.Enabled = true;\r
+ lbl_ipodAtom.Visible = false;\r
+ check_optimiseMP4.Enabled = true;\r
+ check_lAnamorphic.Enabled = true;\r
}\r
+\r
}\r
\r
- Parsing.DVD thisDVD;\r
- public void setStreamReader(Parsing.DVD dvd)\r
+ #endregion\r
+\r
+ #region Query Editor Tab\r
+\r
+ private void btn_clear_Click(object sender, EventArgs e)\r
{\r
- this.thisDVD = dvd;\r
+ rtf_query.Clear();\r
}\r
\r
- private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
+ private void btn_generate_Query_Click(object sender, EventArgs e)\r
{\r
- // Reset some values on the form\r
- lbl_Aspect.Text = "Select a Title";\r
- lbl_RecomendedCrop.Text = "Select a Title";\r
- drop_chapterStart.Items.Clear();\r
- drop_chapterFinish.Items.Clear();\r
- QueryEditorText.Text = "";\r
+ rtf_query.Text = hb_common_func.GenerateTheQuery(this);\r
+ }\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
- Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;\r
- lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();\r
- lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);\r
+ private void btn_copy2C_Click(object sender, EventArgs e)\r
+ {\r
+ if (rtf_query.Text != "")\r
+ Clipboard.SetText(rtf_query.Text, TextDataFormat.Text);\r
+ }\r
\r
- drop_chapterStart.Items.Clear();\r
- drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());\r
- drop_chapterStart.Text = selectedTitle.Chapters[0].ToString();\r
+ #endregion\r
\r
- drop_chapterFinish.Items.Clear();\r
- drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());\r
- drop_chapterFinish.Text = selectedTitle.Chapters[selectedTitle.Chapters.Count - 1].ToString();\r
+ // -------------------------------------------------------------- \r
+ // Main Window Preset System\r
+ // --------------------------------------------------------------\r
\r
- drp_audioChannels.Items.Clear();\r
- drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
- if (drp_audioChannels.Items.Count > 0)\r
- {\r
- drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();\r
- }\r
+ #region Preset System\r
\r
- drp_subtitle.Items.Clear();\r
- drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
- if (drp_subtitle.Items.Count > 0)\r
- {\r
- drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
- }\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
+ // Import Current Presets\r
+ private void loadPresetPanel()\r
+ {\r
+ ArrayList presetNameList = new ArrayList();\r
+ \r
+ string appPath = Application.StartupPath.ToString() + "\\presets.dat";\r
+ if (File.Exists(appPath))\r
{\r
-\r
- if (thisDVD.Titles[counter].TitleNumber.ToString() == title)\r
+ StreamReader presetInput = new StreamReader(appPath);\r
+ while (!presetInput.EndOfStream)\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
-\r
- // Chapter Dropdown Menus\r
- int chapterCount = thisDVD.Titles[counter].Chapters.Count;\r
- int loopCouter = 1;\r
- while (loopCouter <= chapterCount) \r
- {\r
- drop_chapterStart.Items.Add(loopCouter);\r
- drop_chapterFinish.Items.Add(loopCouter);\r
-\r
- drop_chapterStart.Text = "1";\r
- drop_chapterFinish.Text = loopCouter.ToString();\r
- loopCouter++;\r
- }\r
-\r
- // Audio Drop down Menu.\r
- int audioCount = thisDVD.Titles[counter].AudioTracks.Count -1;\r
- loopCouter = 0;\r
- string audioTrack = "";\r
- while (loopCouter <= audioCount)\r
+ if ((char)presetInput.Peek() == '+')\r
{\r
- audioTrack = thisDVD.Titles[counter].AudioTracks[loopCouter].TrackNumber + " " + thisDVD.Titles[counter].AudioTracks[loopCouter].Language + " (" + thisDVD.Titles[counter].AudioTracks[loopCouter].Format + ") (" + thisDVD.Titles[counter].AudioTracks[loopCouter].SubFormat + ")";\r
- drp_audioChannels.Items.Add(audioTrack);\r
- loopCouter++;\r
+ string preset = presetInput.ReadLine().Replace("+ ", "");\r
+ Regex r = new Regex("(: )"); // Split on hyphens. \r
+ presetNameList.Add(r.Split(preset));\r
}\r
- \r
- // Subtitle Dropdown Menu.\r
- int subtitleCount = thisDVD.Titles[counter].Subtitles.Count - 1;\r
- loopCouter = 0;\r
- string subtitleTrack = "";\r
-\r
- while (loopCouter <= audioCount)\r
- {\r
- subtitleTrack = thisDVD.Titles[counter].Subtitles[loopCouter].TrackNumber + " " + thisDVD.Titles[counter].Subtitles[loopCouter].Language;\r
- drp_subtitle.Items.Add(subtitleTrack);\r
- loopCouter++;\r
- } \r
+ else\r
+ presetInput.ReadLine();\r
}\r
- counter++;\r
- }*/\r
- }\r
- } \r
-\r
- //\r
- // The Query Generation Function\r
- //\r
-\r
-\r
- // This function was imported from old vb.net version of this application.\r
- // It could probably do with being cleaned up a good deal at some point\r
- public string GenerateTheQuery()\r
- {\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
- int totalChapters = drop_chapterFinish.Items.Count - 1;\r
- string dvdChapter = "";\r
-\r
- if (source == "")\r
- MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- else\r
+ }\r
+ \r
+ TreeNode preset_treeview = new TreeNode();\r
+ foreach (string[] preset in presetNameList)\r
{\r
- source = " -i " + '"' + source+ '"'; //'"'+\r
- }\r
+ preset_treeview = new TreeNode(preset[0]);\r
\r
- if (dvdTitle == "Automatic")\r
- dvdTitle = "";\r
- else\r
- {\r
- string[] titleInfo = dvdTitle.Split(' ');\r
- dvdTitle = " -t "+ titleInfo[0];\r
+ // Now Fill Out List View with Items\r
+ treeView_presets.Nodes.Add(preset_treeview);\r
}\r
+ }\r
\r
- if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))\r
- dvdChapter = "";\r
- else if (chapterFinish == chapterStart)\r
- dvdChapter = " -c " + chapterStart;\r
- else\r
- dvdChapter = " -c " + chapterStart + "-" + chapterFinish;\r
-\r
- string querySource = source+ dvdTitle+ dvdChapter;\r
- // ----------------------------------------------------------------------\r
-\r
- // Destination\r
+ // Generate a new presets.dat file from the CLI\r
+ private void grabCLIPresets()\r
+ {\r
+ string appPath = Application.StartupPath.ToString() + "\\";\r
+ string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " --preset-list >" + '"' + appPath + "presets.dat" + '"' + " 2>&1" + '"';\r
+ Process hbproc = Process.Start("CMD.exe", strCmdLine);\r
+ hbproc.WaitForExit();\r
+ hbproc.Dispose();\r
+ hbproc.Close();\r
+ }\r
\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
+ // Selects the preset called "normal". This is HandBrakes default settings\r
+ private void loadNormalPreset()\r
+ {\r
+ try\r
+ {\r
+ string appPath = Application.StartupPath.ToString() + "\\presets.dat";\r
+ if (File.Exists(appPath))\r
+ {\r
\r
- if (destination == "")\r
- MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- else\r
- destination = " -o " + '"' + destination + '"'; //'"'+ \r
+ int normal = 0;\r
+ foreach (TreeNode treenode in treeView_presets.Nodes)\r
+ {\r
+ if (treenode.ToString().Equals("TreeNode: Normal"))\r
+ normal = treenode.Index;\r
+ }\r
\r
+ TreeNode np = treeView_presets.Nodes[normal];\r
\r
- switch (videoEncoder)\r
- {\r
- case "Mpeg 4":\r
- videoEncoder = " -e ffmpeg";\r
- break;\r
- case "Xvid":\r
- videoEncoder = " -e xvid";\r
- break;\r
- case "H.264":\r
- videoEncoder = " -e x264";\r
- break;\r
- case "H.264 Baseline 1.3":\r
- videoEncoder = " -e x264b13";\r
- break;\r
- case "H.264 (iPod)":\r
- videoEncoder = " -e x264b30";\r
- break;\r
- default:\r
- videoEncoder = " -e x264";\r
- break;\r
+ treeView_presets.SelectedNode = np;\r
+ }\r
}\r
- \r
- switch (audioEncoder)\r
+ catch (Exception)\r
{\r
- case "AAC":\r
- audioEncoder = " -E faac";\r
- break;\r
- case "MP3":\r
- audioEncoder = " -E lame";\r
- break;\r
- case "Vorbis":\r
- audioEncoder = " -E vorbis";\r
- break;\r
- case "AC3":\r
- audioEncoder = " -E ac3";\r
- break;\r
- default:\r
- audioEncoder = " -E faac";\r
- break;\r
+ // Do nothing\r
}\r
+ }\r
\r
- if (width != "")\r
- width = " -w "+ width;\r
- \r
-\r
- if (height != "")\r
- height = " -l "+ height;\r
- \r
+ // Set's the current options set in the program as the new defaults for the program.\r
+ private void btn_setDefault_Click(object sender, EventArgs e)\r
+ {\r
+ String query = hb_common_func.GenerateTheQuery(this);\r
+ Properties.Settings.Default.defaultUserSettings = query;\r
+ // Save the new default Settings\r
+ Properties.Settings.Default.Save();\r
+ MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ }\r
\r
- string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;\r
- // ----------------------------------------------------------------------\r
+ // When the user select a preset from the treeview, load it\r
+ private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
+ {\r
+ string selectedPreset = null;\r
+ selectedPreset = treeView_presets.SelectedNode.Text;\r
\r
- // Picture Settings Tab\r
+ try\r
+ {\r
+ string appPath = Application.StartupPath.ToString() + "\\presets.dat";\r
+ if (File.Exists(appPath))\r
+ {\r
+ StreamReader presetInput = new StreamReader(appPath);\r
+ while (!presetInput.EndOfStream)\r
+ {\r
+ if ((char)presetInput.Peek() == '+')\r
+ {\r
+ string preset = presetInput.ReadLine().Replace("+ ", "");\r
+ Regex r = new Regex("(: )"); // Split on hyphens. \r
+ string[] presetName = r.Split(preset);\r
\r
- string cropSetting = drp_crop.Text;\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
- string cropOut = "";\r
- // Returns Crop Query\r
+ if (selectedPreset == presetName[0])\r
+ {\r
+ // Need to disable anamorphic now, otherwise it may overide the width / height values later.\r
+ CheckPixelRatio.CheckState = CheckState.Unchecked;\r
\r
- if (cropSetting == "Auto Crop")\r
- cropOut = "";\r
- else if (cropSetting == "No Crop")\r
- cropOut = " --crop 0:0:0:0 ";\r
- else\r
- cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
+ // Send the query from the file to the Query Parser class\r
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);\r
\r
- if (subtitles == "None")\r
- subtitles = "";\r
- else if (subtitles == "")\r
- subtitles = "";\r
- else\r
+ // Now load the preset\r
+ hb_common_func.presetLoader(this, presetQuery, selectedPreset);\r
+ }\r
+ }\r
+ else\r
+ presetInput.ReadLine();\r
+ }\r
+ }\r
+ }\r
+ catch (Exception exc)\r
{\r
- string[] tempSub;\r
- tempSub = subtitles.Split(' ');\r
- subtitles = " -s "+ tempSub[0];\r
+ MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
+ }\r
\r
- string queryPictureSettings = cropOut+ subtitles;\r
- // ----------------------------------------------------------------------\r
-\r
- // Video Settings Tab\r
+ #endregion\r
\r
- string videoBitrate = text_bitrate.Text;\r
- string videoFilesize = text_filesize.Text;\r
- int videoQuality = slider_videoQuality.Value;\r
- string vidQSetting = "";\r
- string twoPassEncoding = "";\r
- string deinterlace = "";\r
- string grayscale = "";\r
- string videoFramerate = drp_videoFramerate.Text;\r
- string pixelRatio = "";\r
- string ChapterMarkers = "";\r
- string turboH264 = "";\r
- string largeFile = "";\r
+ //---------------------------------------------------\r
+ // Encode / Cancel Buttons\r
+ // Encode Progress Text Handler\r
+ //---------------------------------------------------\r
\r
- if (videoBitrate != "")\r
- videoBitrate = " -b "+ videoBitrate;\r
+ #region Encodeing and Queue\r
\r
- if (videoFilesize != "")\r
- videoFilesize = " -S "+ videoFilesize;\r
+ Functions.CLI process = new Functions.CLI();\r
+ private delegate void UpdateUIHandler();\r
\r
- // Video Quality Setting\r
+ [DllImport("user32.dll")]\r
+ public static extern void LockWorkStation();\r
+ [DllImport("user32.dll")]\r
+ public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
\r
- if ((videoQuality == 0))\r
- vidQSetting = "";\r
+ private void btn_start_Click(object sender, EventArgs e)\r
+ {\r
+ if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")\r
+ MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
{\r
- videoQuality = videoQuality/ 100;\r
- if (videoQuality == 1)\r
- {\r
- vidQSetting = "1.0";\r
- }\r
+ String query;\r
+ if (rtf_query.Text != "")\r
+ query = rtf_query.Text;\r
+ else\r
+ query = hb_common_func.GenerateTheQuery(this);\r
\r
- vidQSetting = " -q " + videoQuality.ToString();\r
+ ThreadPool.QueueUserWorkItem(procMonitor, query);\r
+ lbl_encode.Visible = true;\r
+ lbl_encode.Text = "Encoding in Progress";\r
}\r
+ }\r
\r
- if (check_2PassEncode.Checked)\r
- twoPassEncoding = " -2 ";\r
-\r
- if (check_DeInterlace.Checked)\r
- deinterlace = " -d ";\r
-\r
- if (check_grayscale.Checked)\r
- grayscale = " -g ";\r
-\r
- if (videoFramerate == "Automatic")\r
- videoFramerate = "";\r
- else\r
- videoFramerate = " -r "+ videoFramerate;\r
-\r
- if (CheckPixelRatio.Checked)\r
- pixelRatio = " -p ";\r
-\r
- if (Check_ChapterMarkers.Checked)\r
- ChapterMarkers = " -m ";\r
-\r
- if (check_turbo.Checked)\r
- turboH264 = " -T ";\r
-\r
- if (check_largeFile.Checked)\r
- largeFile = " -4 ";\r
-\r
- string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;\r
- // ----------------------------------------------------------------------\r
-\r
- // Audio Settings Tab\r
-\r
- string audioBitrate = drp_audioBitrate.Text;\r
- string audioSampleRate = drp_audioSampleRate.Text;\r
- string audioChannels = drp_audioChannels.Text;\r
- string Mixdown = drp_audioMixDown.Text;\r
- string SixChannelAudio = "";\r
-\r
- if (audioBitrate != "")\r
- audioBitrate = " -B "+ audioBitrate;\r
-\r
- if (audioSampleRate != "")\r
- audioSampleRate = " -R "+ audioSampleRate;\r
-\r
- if (audioChannels == "Automatic")\r
- audioChannels = "";\r
- else if (audioChannels == "")\r
- audioChannels = "";\r
+ private void btn_add2Queue_Click(object sender, EventArgs e)\r
+ {\r
+ if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")\r
+ MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
{\r
- string[] tempSub;\r
- tempSub = audioChannels.Split(' ');\r
- audioChannels = " -a "+ tempSub[0];\r
- }\r
+ String query;\r
+ if (rtf_query.Text != "")\r
+ query = rtf_query.Text;\r
+ else\r
+ query = hb_common_func.GenerateTheQuery(this);\r
\r
- switch (Mixdown)\r
- {\r
- case "Automatic":\r
- Mixdown = "";\r
- break;\r
- case "Mono":\r
- Mixdown = "mono";\r
- break;\r
- case "Stereo":\r
- Mixdown = "stereo";\r
- break;\r
- case "Dolby Surround":\r
- Mixdown = "dpl1";\r
- break;\r
- case "Dolby Pro Logic II":\r
- Mixdown = "dpl2";\r
- break;\r
- case "6 Channel Discrete":\r
- Mixdown = "6ch";\r
- break;\r
- default:\r
- Mixdown = "stero";\r
- break;\r
+ queueWindow.list_queue.Items.Add(query);\r
+ queueWindow.Show();\r
}\r
+ }\r
\r
- if (Mixdown != "")\r
- SixChannelAudio = " -6 "+ Mixdown;\r
- else\r
- SixChannelAudio = "";\r
-\r
- string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;\r
- // ----------------------------------------------------------------------\r
-\r
- // H.264 Tab\r
-\r
- string CRF = CheckCRF.CheckState.ToString();\r
- string h264Advanced = rtf_h264advanced.Text;\r
- if ((CRF == "1"))\r
- CRF = " -Q ";\r
- else\r
- CRF = "";\r
-\r
- if ((h264Advanced == ""))\r
- h264Advanced = "";\r
- else\r
- h264Advanced = " -x "+ h264Advanced;\r
- \r
-\r
- string h264Settings = CRF+ h264Advanced;\r
- // ----------------------------------------------------------------------\r
-\r
- // Processors (Program Settings)\r
+ private void btn_showQueue_Click(object sender, EventArgs e)\r
+ {\r
+ showQueue();\r
+ }\r
\r
- string processors = Properties.Settings.Default.Processors;\r
- // Number of Processors Handler\r
+ private void showQueue()\r
+ {\r
+ queueWindow.Show();\r
+ }\r
\r
- if (processors == "Automatic")\r
- processors = "";\r
+ private void procMonitor(object state)\r
+ {\r
+ // Make sure we are not already encoding and if we are then display an error.\r
+ if (hbProc != null)\r
+ MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
- processors = " -C "+ processors+ " ";\r
+ {\r
+ hbProc = process.runCli(this, (string)state, false, false, false, false);\r
+ hbProc.WaitForExit();\r
\r
+ setEncodeLabel();\r
+ hbProc = null;\r
\r
- string queryAdvancedSettings = processors;\r
- // ----------------------------------------------------------------------\r
+ // Do something whent he encode ends.\r
+ switch (Properties.Settings.Default.CompletionOption)\r
+ {\r
+ case "Shutdown":\r
+ System.Diagnostics.Process.Start("Shutdown", "-s -t 60");\r
+ break;\r
+ case "Log Off":\r
+ ExitWindowsEx(0, 0);\r
+ break;\r
+ case "Suspend":\r
+ Application.SetSuspendState(PowerState.Suspend, true, true);\r
+ break;\r
+ case "Hibernate":\r
+ Application.SetSuspendState(PowerState.Hibernate, true, true);\r
+ break;\r
+ case "Lock System":\r
+ LockWorkStation();\r
+ break;\r
+ case "Quit HandBrake":\r
+ Application.Exit();\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ }\r
\r
- // Verbose option (Program Settings)\r
+ private void setEncodeLabel()\r
+ {\r
+ if (this.InvokeRequired)\r
+ {\r
+ this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));\r
+ return;\r
+ }\r
+ lbl_encode.Text = "Encoding Finished";\r
+ }\r
\r
- string verbose = "";\r
- if (Properties.Settings.Default.verbose == "Checked")\r
- verbose = " -v ";\r
+ #endregion\r
\r
- // ----------------------------------------------------------------------\r
\r
- return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;\r
- }\r
\r
// This is the END of the road ------------------------------------------------------------------------------\r
}\r