using System.Threading;\r
using Handbrake.Functions;\r
using Handbrake.Presets;\r
+using Handbrake.Queue;\r
+using Handbrake.Parsing;\r
\r
namespace Handbrake\r
{\r
public partial class frmMain : Form\r
{\r
// Objects which may be used by one or more other objects\r
- private delegate void UpdateWindowHandler();\r
Main hb_common_func = new Main();\r
Encode encodeHandler = new Encode();\r
- Queue.QueueHandler encodeQueue = new Queue.QueueHandler();\r
+ QueueHandler encodeQueue = new QueueHandler();\r
PresetsHandler presetHandler = new PresetsHandler();\r
- Parsing.Title selectedTitle;\r
- Parsing.DVD thisDVD;\r
-\r
- // Objects belonging to this window only\r
QueryGenerator queryGen = new QueryGenerator();\r
\r
// Globals: Mainly used for tracking.\r
+ Title selectedTitle;\r
+ DVD thisDVD;\r
+ Process hbproc;\r
private frmQueue queueWindow;\r
private frmPreview qtpreview;\r
+ private Form splash;\r
private string lastAction;\r
public int maxWidth;\r
public int maxHeight;\r
- Process hbproc;\r
- private Form splash;\r
+\r
+ // Delegates\r
+ private delegate void UpdateWindowHandler();\r
+ private delegate void updateStatusChanger();\r
\r
// Applicaiton Startup ************************************************\r
\r
\r
public frmMain()\r
{\r
- // Load the splash screen in this thread\r
+ // Load and setup the splash screen in this thread\r
splash = new frmSplashScreen();\r
splash.Show();\r
-\r
- //Create a label that can be updated from the parent thread.\r
Label lblStatus = new Label { Size = new Size(250, 20), Location = new Point(10, 280) };\r
splash.Controls.Add(lblStatus);\r
+\r
InitializeComponent();\r
\r
// Update the users config file with the CLI version data.\r
lblStatus.Text = "Setting Version Data ...";\r
Application.DoEvents();\r
- ArrayList x = hb_common_func.getCliVersionData();\r
- Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
- Properties.Settings.Default.hb_version = x[0].ToString();\r
+ hb_common_func.setCliVersionData();\r
\r
- // show the form, but leave disabled until preloading is complete then show the main form\r
+ // Show the form, but leave disabled until preloading is complete then show the main form\r
this.Enabled = false;\r
this.Show();\r
Application.DoEvents(); // Forces frmMain to draw\r
\r
- // update the status\r
+ // Check for new versions, if update checking is enabled\r
if (Properties.Settings.Default.updateStatus == "Checked")\r
{\r
lblStatus.Text = "Checking for updates ...";\r
// Setup the GUI components\r
lblStatus.Text = "Setting up the GUI ...";\r
Application.DoEvents();\r
- x264Panel.reset2Defaults(); // Initialize all the x264 widgets to their default values\r
loadPresetPanel(); // Load the Preset Panel\r
treeView_presets.ExpandAll();\r
lbl_encode.Text = "";\r
// Load the user's default settings or Normal Preset\r
if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultPreset != "")\r
{\r
- // Ok, so, we've selected a preset. Now we want to load it.\r
if (presetHandler.getPreset(Properties.Settings.Default.defaultPreset) != null)\r
{\r
string query = presetHandler.getPreset(Properties.Settings.Default.defaultPreset).Query;\r
\r
// Enabled GUI tooltip's if Required\r
if (Properties.Settings.Default.tooltipEnable == "Checked")\r
- {\r
- x264Panel.setToolTipActive(true);\r
ToolTip.Active = true;\r
- }\r
\r
//Finished Loading\r
lblStatus.Text = "Loading Complete!";\r
queueRecovery();\r
}\r
\r
- // Startup Functions\r
- private delegate void updateStatusChanger();\r
+ // Startup Functions \r
private void startupUpdateCheck()\r
{\r
try\r
}\r
private void encodeStarted(object sender, EventArgs e)\r
{\r
- setLastAction("encode");\r
+ lastAction = "encode";\r
setEncodeStarted();\r
}\r
private void encodeEnded(object sender, EventArgs e)\r
{\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
- if (Path.HasExtension(text_destination.Text))\r
- DVD_Save.FileName = Path.Combine(Path.GetDirectoryName(text_destination.Text), Path.GetFileNameWithoutExtension(text_destination.Text));\r
+ DVD_Save.FileName = Path.GetFileNameWithoutExtension(text_destination.Text);\r
+\r
+ if (Path.IsPathRooted(text_destination.Text))\r
+ DVD_Save.InitialDirectory = Path.GetDirectoryName(text_destination.Text);\r
\r
// Show the dialog and set the main form file path\r
if (drop_format.SelectedIndex.Equals(0))\r
if (DVD_Save.FileName.StartsWith("\\"))\r
MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
- {\r
- setAudioByContainer(DVD_Save.FileName);\r
+ { \r
+ // Add a file extension manually, as FileDialog.AddExtension has issues with dots in filenames\r
+ switch (DVD_Save.FilterIndex)\r
+ {\r
+ case 1:\r
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".mp4", StringComparison.InvariantCultureIgnoreCase))\r
+ DVD_Save.FileName += ".mp4"; \r
+ break; \r
+ case 2:\r
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".m4v", StringComparison.InvariantCultureIgnoreCase)) \r
+ DVD_Save.FileName += ".m4v"; \r
+ break; \r
+ case 3: \r
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".mkv", StringComparison.InvariantCultureIgnoreCase)) \r
+ DVD_Save.FileName += ".mkv"; \r
+ break; \r
+ default: \r
+ //do nothing \r
+ break; \r
+ }\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
- text_destination.Text = text_destination.Text.Replace(".mp4", ".m4v");\r
+ drop_format.SelectedIndex = 1;\r
}\r
}\r
}\r
//Video Tab\r
private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
- if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))\r
- {\r
- check_largeFile.Enabled = true;\r
- check_optimiseMP4.Enabled = true;\r
- check_iPodAtom.Enabled = true;\r
- }\r
- else\r
- {\r
- check_largeFile.Enabled = false;\r
- check_optimiseMP4.Enabled = false;\r
- check_iPodAtom.Enabled = false;\r
- check_largeFile.Checked = false;\r
- check_optimiseMP4.Checked = false;\r
- check_iPodAtom.Checked = false;\r
- }\r
+ setContainerOpts();\r
\r
//Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
if (drp_videoEncoder.Text.Contains("H.264"))\r
check_turbo.Enabled = true;\r
\r
h264Tab.Enabled = true;\r
- if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))\r
+ if ((drop_format.Text.Contains("MP4")) || (drop_format.Text.Contains("M4V")))\r
check_iPodAtom.Enabled = true;\r
else\r
check_iPodAtom.Enabled = false;\r
break;\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Set the container format options\r
+ /// </summary>\r
+ public void setContainerOpts()\r
+ {\r
+ if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))\r
+ {\r
+ check_largeFile.Enabled = true;\r
+ check_optimiseMP4.Enabled = true;\r
+ check_iPodAtom.Enabled = true;\r
+ }\r
+ else\r
+ {\r
+ check_largeFile.Enabled = false;\r
+ check_optimiseMP4.Enabled = false;\r
+ check_iPodAtom.Enabled = false;\r
+ check_largeFile.Checked = false;\r
+ check_optimiseMP4.Checked = false;\r
+ check_iPodAtom.Checked = false;\r
+ }\r
+ }\r
private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
{\r
switch (drp_videoEncoder.Text)\r
}\r
#endregion\r
\r
+ #region GUI\r
+ /// <summary>\r
+ /// Set the GUI to it's finished encoding state.\r
+ /// </summary>\r
+ private void setEncodeFinished()\r
+ {\r
+ try\r
+ {\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
+ return;\r
+ }\r
+\r
+ lbl_encode.Text = "Encoding Finished";\r
+ btn_start.Text = "Start";\r
+ btn_start.ToolTipText = "Start the encoding process";\r
+ btn_start.Image = Properties.Resources.Play;\r
+\r
+ // If the window is minimized, display the notification in a popup.\r
+ if (FormWindowState.Minimized == this.WindowState)\r
+ {\r
+ notifyIcon.BalloonTipText = lbl_encode.Text;\r
+ notifyIcon.ShowBalloonTip(500);\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show(exc.ToString());\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Set the GUI to it's started encoding state.\r
+ /// </summary>\r
+ private void setEncodeStarted()\r
+ {\r
+ try\r
+ {\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
+ return;\r
+ }\r
+\r
+ lbl_encode.Visible = true;\r
+ lbl_encode.Text = "Encoding in Progress";\r
+ btn_start.Text = "Stop";\r
+ btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";\r
+ btn_start.Image = Properties.Resources.stop;\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show(exc.ToString());\r
+ }\r
+ }\r
+ #endregion\r
+\r
#region DVD Drive Detection\r
// Source Button Drive Detection\r
private delegate void ProgressUpdateHandler();\r
#endregion\r
\r
#region Public Methods\r
-\r
- /// <summary>\r
- /// Setup the GUI for Encoding or finished Encoding.\r
- /// 1 = Encode Running\r
- /// 0 = Encode Finished.\r
- /// </summary>\r
- public void setEncodeFinished()\r
- {\r
- try\r
- {\r
- if (InvokeRequired)\r
- {\r
- BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
- return;\r
- }\r
-\r
- lbl_encode.Text = "Encoding Finished";\r
- btn_start.Text = "Start";\r
- btn_start.ToolTipText = "Start the encoding process";\r
- btn_start.Image = Properties.Resources.Play;\r
-\r
- // If the window is minimized, display the notification in a popup.\r
- if (FormWindowState.Minimized == this.WindowState)\r
- {\r
- notifyIcon.BalloonTipText = lbl_encode.Text;\r
- notifyIcon.ShowBalloonTip(500);\r
- }\r
- }\r
- catch (Exception exc)\r
- {\r
- MessageBox.Show(exc.ToString());\r
- }\r
- }\r
- public void setEncodeStarted()\r
- {\r
- try\r
- {\r
- if (InvokeRequired)\r
- {\r
- BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
- return;\r
- }\r
-\r
- lbl_encode.Visible = true;\r
- lbl_encode.Text = "Encoding in Progress";\r
- btn_start.Text = "Stop";\r
- btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";\r
- btn_start.Image = Properties.Resources.stop;\r
- }\r
- catch (Exception exc)\r
- {\r
- MessageBox.Show(exc.ToString());\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Action can be "encode" or "scan"\r
- /// Set the last action varible in the main window.\r
- /// This is used to control which log file is displayed when the Activity window is displayed.\r
- /// </summary>\r
- /// <param name="last">String</param>\r
- public void setLastAction(string last)\r
- {\r
- this.lastAction = last;\r
- }\r
-\r
- /// <summary>\r
- /// DVD parseing. Pass in a parsed DVD.\r
- /// </summary>\r
- /// <param name="dvd"></param>\r
- public void setStreamReader(Parsing.DVD dvd)\r
- {\r
- this.thisDVD = dvd;\r
- }\r
-\r
/// <summary>\r
/// Reload the preset panel display\r
/// </summary>\r
treeView_presets.Nodes.Add(preset_treeview);\r
}\r
}\r
-\r
#endregion\r
\r
#region overrides\r