/* frmMain.cs $\r
- \r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr/>.\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.Drawing;\r
-using System.Globalization;\r
-using System.Windows.Forms;\r
-using System.IO;\r
-using System.Diagnostics;\r
-using System.Threading;\r
-using Handbrake.EncodeQueue;\r
-using Handbrake.Functions;\r
-using Handbrake.Presets;\r
-using Handbrake.Parsing;\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr/>.\r
+ It may be used under the terms of the GNU General Public License. */\r
\r
namespace Handbrake\r
{\r
+ using System;\r
+ using System.Collections.Generic;\r
+ using System.ComponentModel;\r
+ using System.Diagnostics;\r
+ using System.Drawing;\r
+ using System.Globalization;\r
+ using System.IO;\r
+ using System.Threading;\r
+ using System.Windows.Forms;\r
+ using Functions;\r
+\r
+ using HandBrake.ApplicationServices.Functions;\r
+ using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Parsing;\r
+ using HandBrake.ApplicationServices.Services;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
+\r
+ using Model;\r
+ using Presets;\r
+ using Properties;\r
+\r
+ using Main = Handbrake.Functions.Main;\r
+\r
+ /// <summary>\r
+ /// The Main Window\r
+ /// </summary>\r
public partial class frmMain : Form\r
{\r
// Objects which may be used by one or more other objects *************\r
- EncodeAndQueueHandler encodeQueue = new EncodeAndQueueHandler();\r
- PresetsHandler presetHandler = new PresetsHandler();\r
- QueryGenerator queryGen = new QueryGenerator();\r
+ private IQueue encodeQueue = new Queue();\r
+ private PresetsHandler presetHandler = new PresetsHandler();\r
\r
- // Globals: Mainly used for tracking. *********************************\r
- public Title selectedTitle;\r
+ // Windows ************************************************************\r
private frmQueue queueWindow;\r
private frmPreview qtpreview;\r
- private frmActivityWindow ActivityWindow;\r
- private Form splash;\r
+ private frmActivityWindow activityWindow;\r
+\r
+ // Globals: Mainly used for tracking. *********************************\r
+ public Title selectedTitle;\r
public string sourcePath;\r
- private string lastAction;\r
private SourceType selectedSourceType;\r
private string dvdDrivePath;\r
private string dvdDriveLabel;\r
+ private Preset currentlySelectedPreset;\r
+ private DVD currentSource;\r
+ private IScan SourceScan = new ScanService();\r
+ private List<DriveInformation> drives;\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
\r
// Applicaiton Startup ************************************************\r
\r
- #region Application Startup\r
- public frmMain()\r
+ #region Properties\r
+\r
+ /// <summary>\r
+ /// Gets SourceName.\r
+ /// </summary>\r
+ public string SourceName\r
{\r
- // Load and setup the splash screen in this thread\r
- splash = new frmSplashScreen();\r
- splash.Show(this);\r
- Label lblStatus = new Label { Size = new Size(150, 20), Location = new Point(182, 102) };\r
- splash.Controls.Add(lblStatus);\r
+ get\r
+ {\r
+ if (this.selectedSourceType == SourceType.DvdDrive)\r
+ {\r
+ return this.dvdDriveLabel;\r
+ }\r
+\r
+ if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
+ return Path.GetFileNameWithoutExtension(this.sourcePath);\r
+\r
+ return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.sourcePath));\r
+ }\r
+ }\r
\r
+ #endregion\r
+\r
+ #region Application Startup\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="frmMain"/> class.\r
+ /// </summary>\r
+ /// <param name="args">\r
+ /// The arguments passed in on application startup.\r
+ /// </param>\r
+ public frmMain(string[] args)\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
- Main.setCliVersionData();\r
+ Main.SetCliVersionData();\r
+ Main.CheckForValidCliVersion();\r
\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
+ if (Settings.Default.hb_version.Contains("svn"))\r
+ {\r
+ this.Text += " " + Settings.Default.hb_version;\r
+ }\r
\r
// Check for new versions, if update checking is enabled\r
- if (Properties.Settings.Default.updateStatus)\r
+ if (Settings.Default.updateStatus)\r
{\r
- DateTime now = DateTime.Now;\r
- DateTime lastCheck = Properties.Settings.Default.lastUpdateCheckDate;\r
- TimeSpan elapsed = now.Subtract(lastCheck);\r
- if (elapsed.TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)\r
+ if (DateTime.Now.Subtract(Settings.Default.lastUpdateCheckDate).TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)\r
{\r
- lblStatus.Text = "Checking for updates ...";\r
- Application.DoEvents();\r
-\r
Main.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false);\r
}\r
}\r
\r
+ // Clear the log files in the background\r
+ if (Settings.Default.clearOldLogs)\r
+ {\r
+ Thread clearLog = new Thread(Main.ClearOldLogs);\r
+ clearLog.Start();\r
+ }\r
+\r
// Setup the GUI components\r
- lblStatus.Text = "Setting up the GUI ...";\r
- Application.DoEvents();\r
- loadPresetPanel(); // Load the Preset Panel\r
+ LoadPresetPanel(); // Load the Preset Panel\r
treeView_presets.ExpandAll();\r
- lbl_encode.Text = "";\r
- queueWindow = new frmQueue(encodeQueue); // Prepare the Queue\r
- if (!Properties.Settings.Default.QueryEditorTab)\r
+ lbl_encode.Text = string.Empty;\r
+ drop_mode.SelectedIndex = 0;\r
+ queueWindow = new frmQueue(encodeQueue, this); // Prepare the Queue\r
+ if (!Settings.Default.QueryEditorTab)\r
tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.\r
+ if (Settings.Default.tooltipEnable)\r
+ ToolTip.Active = true;\r
\r
// Load the user's default settings or Normal Preset\r
- if (Properties.Settings.Default.defaultPreset != "")\r
+ if (Settings.Default.defaultPreset != string.Empty && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
{\r
- if (presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
+ string query = presetHandler.GetPreset(Settings.Default.defaultPreset).Query;\r
+ if (query != null)\r
{\r
- string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query;\r
- Boolean loadPictureSettings = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings;\r
-\r
- if (query != null)\r
- {\r
- //Ok, Reset all the H264 widgets before changing the preset\r
- x264Panel.reset2Defaults();\r
+ x264Panel.Reset2Defaults();\r
\r
- // Send the query from the file to the Query Parser class, then load the preset\r
- QueryParser presetQuery = QueryParser.Parse(query);\r
- PresetLoader.presetLoader(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
+ QueryParser presetQuery = QueryParser.Parse(query);\r
+ PresetLoader.LoadPreset(this, presetQuery, Settings.Default.defaultPreset);\r
\r
- // The x264 widgets will need updated, so do this now:\r
- x264Panel.X264_StandardizeOptString();\r
- x264Panel.X264_SetCurrentSettingsInPanel();\r
- }\r
+ x264Panel.StandardizeOptString();\r
+ x264Panel.SetCurrentSettingsInPanel();\r
}\r
- else\r
- loadNormalPreset();\r
}\r
else\r
loadNormalPreset();\r
\r
- // Enabled GUI tooltip's if Required\r
- if (Properties.Settings.Default.tooltipEnable)\r
- ToolTip.Active = true;\r
-\r
// Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)\r
GrowlCommunicator.Register();\r
\r
- //Finished Loading\r
- lblStatus.Text = "Loading Complete!";\r
- Application.DoEvents();\r
- splash.Close();\r
- splash.Dispose();\r
- this.Enabled = true;\r
-\r
// Event Handlers and Queue Recovery\r
events();\r
- queueRecovery();\r
+ Main.RecoverQueue(encodeQueue);\r
+\r
+ // If have a file passed in via command arguemtents, check it's a file and try scanning it.\r
+ if (args.Length >= 1 && (File.Exists(args[0]) || Directory.Exists(args[0])))\r
+ {\r
+ this.StartScan(args[0], 0);\r
+ }\r
}\r
\r
+ /// <summary>\r
+ /// When the update check is done, process the results.\r
+ /// </summary>\r
+ /// <param name="result">IAsyncResult result</param>\r
private void UpdateCheckDone(IAsyncResult result)\r
{\r
if (InvokeRequired)\r
catch (Exception ex)\r
{\r
if ((bool)result.AsyncState)\r
- MessageBox.Show("Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
- }\r
- }\r
-\r
- // Startup Functions \r
- private void queueRecovery()\r
- {\r
- if (Main.checkQueueRecovery())\r
- {\r
- DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-\r
- if (result == DialogResult.Yes)\r
- encodeQueue.LoadQueueFromFile("hb_queue_recovery.xml"); // Start Recovery\r
- else\r
- {\r
- // Remove the Queue recovery file if the user doesn't want to recovery the last queue.\r
- string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
- if (File.Exists(queuePath))\r
- File.Delete(queuePath);\r
- }\r
+ Main.ShowExceptiowWindow("Unable to check for updates, Please try again later.", ex.ToString());\r
}\r
}\r
- #endregion\r
\r
- #region Properties\r
- public string SourceName\r
- {\r
- get\r
- {\r
- if (this.selectedSourceType == SourceType.DvdDrive)\r
- {\r
- return this.dvdDriveLabel;\r
- }\r
-\r
- return Path.GetFileNameWithoutExtension(this.sourcePath);\r
- }\r
- }\r
#endregion\r
\r
#region Events\r
+\r
// Encoding Events for setting up the GUI\r
private void events()\r
{\r
this.Resize += new EventHandler(frmMain_Resize);\r
\r
// Handle Encode Start / Finish / Pause\r
- encodeQueue.CurrentJobCompleted += new EventHandler(encodeEnded);\r
- encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
- encodeQueue.NewJobStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
\r
// Handle a file being draged onto the GUI.\r
this.DragEnter += new DragEventHandler(frmMain_DragEnter);\r
check_optimiseMP4.CheckedChanged += new EventHandler(changePresetLabel);\r
\r
// Picture Settings\r
- //PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
+ PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
\r
// Filter Settings\r
Filters.FilterSettingsChanged += new EventHandler(changePresetLabel);\r
// Advanced Tab\r
x264Panel.rtf_x264Query.TextChanged += new EventHandler(changePresetLabel);\r
}\r
+\r
private void UnRegisterPresetEventHandler()\r
{\r
// Output Settings \r
check_optimiseMP4.CheckedChanged -= new EventHandler(changePresetLabel);\r
\r
// Picture Settings\r
- //PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
+ PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
\r
// Filter Settings\r
Filters.FilterSettingsChanged -= new EventHandler(changePresetLabel);\r
// Advanced Tab\r
x264Panel.rtf_x264Query.TextChanged -= new EventHandler(changePresetLabel);\r
}\r
+\r
private void changePresetLabel(object sender, EventArgs e)\r
{\r
labelPreset.Text = "Output Settings (Preset: Custom)";\r
+ this.currentlySelectedPreset = null;\r
}\r
\r
private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))\r
e.Effect = DragDropEffects.All;\r
}\r
+\r
private void frmMain_DragDrop(object sender, DragEventArgs e)\r
{\r
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];\r
\r
if (fileList != null)\r
{\r
- if (fileList[0].StartsWith("\\"))\r
+ if (!string.IsNullOrEmpty(fileList[0]))\r
{\r
- MessageBox.Show(\r
- "Sorry, HandBrake does not support UNC file paths. \nTry mounting the network share as a network drive in My Computer",\r
- "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- UpdateSourceLabel();\r
+ this.selectedSourceType = SourceType.VideoFile;\r
+ StartScan(fileList[0], 0);\r
}\r
else\r
- {\r
- if (fileList[0] != "")\r
- StartScan(fileList[0]);\r
- else\r
- UpdateSourceLabel();\r
- }\r
+ UpdateSourceLabel();\r
}\r
else\r
UpdateSourceLabel();\r
}\r
+\r
private void encodeStarted(object sender, EventArgs e)\r
{\r
- lastAction = "encode";\r
- setEncodeStarted();\r
-\r
- // Experimental HBProc Process Monitoring.\r
- if (Properties.Settings.Default.enocdeStatusInGui)\r
- {\r
- Thread encodeMon = new Thread(encodeMonitorThread);\r
- encodeMon.Start();\r
- }\r
+ SetEncodeStarted();\r
+ encodeQueue.EncodeStatusChanged += EncodeQueue_EncodeStatusChanged;\r
}\r
+\r
private void encodeEnded(object sender, EventArgs e)\r
{\r
- setEncodeFinished();\r
- }\r
- private void encodePaused(object sender, EventArgs e)\r
- {\r
- setEncodeFinished();\r
+ encodeQueue.EncodeStatusChanged -= EncodeQueue_EncodeStatusChanged;\r
+ SetEncodeFinished();\r
}\r
#endregion\r
\r
// User Interface Menus / Tool Strips *********************************\r
\r
#region File Menu\r
+\r
+ /// <summary>\r
+ /// Kill The scan menu Item\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_killCLI_Click(object sender, EventArgs e)\r
{\r
KillScan();\r
}\r
+\r
+ /// <summary>\r
+ /// Exit the Application Menu Item\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_exit_Click(object sender, EventArgs e)\r
{\r
Application.Exit();\r
}\r
+\r
#endregion\r
\r
#region Tools Menu\r
+\r
+ /// <summary>\r
+ /// Menu - Start Button\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_encode_Click(object sender, EventArgs e)\r
{\r
queueWindow.Show();\r
}\r
+\r
+ /// <summary>\r
+ /// Menu - Display the Log Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_encodeLog_Click(object sender, EventArgs e)\r
{\r
- frmActivityWindow dvdInfoWindow = new frmActivityWindow(lastAction);\r
- dvdInfoWindow.Show();\r
+ this.btn_ActivityWindow_Click(this, null);\r
}\r
+\r
+ /// <summary>\r
+ /// Menu - Display the Options Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_options_Click(object sender, EventArgs e)\r
{\r
Form options = new frmOptions(this);\r
options.ShowDialog();\r
}\r
+\r
#endregion\r
\r
#region Presets Menu\r
+\r
+ /// <summary>\r
+ /// Reset the Built in Presets\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
presetHandler.UpdateBuiltInPresets();\r
- loadPresetPanel();\r
+ LoadPresetPanel();\r
if (treeView_presets.Nodes.Count == 0)\r
- MessageBox.Show("Unable to load the presets.xml 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
+ MessageBox.Show(\r
+ "Unable to load the presets.xml 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!",\r
+ "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
else\r
MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
\r
treeView_presets.ExpandAll();\r
}\r
+\r
+ /// <summary>\r
+ /// Delete the selected preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_delete_preset_Click(object sender, EventArgs e)\r
{\r
presetHandler.RemoveBuiltInPresets();\r
- loadPresetPanel(); // Reload the preset panel\r
+ LoadPresetPanel(); // Reload the preset panel\r
}\r
+\r
+ /// <summary>\r
+ /// Select the Normal preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
{\r
loadNormalPreset();\r
}\r
+\r
+ /// <summary>\r
+ /// Import a plist Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_importMacPreset_Click(object sender, EventArgs e)\r
{\r
- importPreset();\r
+ ImportPreset();\r
}\r
+\r
+ /// <summary>\r
+ /// Export a Plist Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void mnu_exportMacPreset_Click(object sender, EventArgs e)\r
+ {\r
+ ExportPreset();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Create a new Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_new_preset_Click(object sender, EventArgs e)\r
{\r
- Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, 0, null), presetHandler);\r
- preset.ShowDialog();\r
+ Form preset = new frmAddPreset(this, presetHandler);\r
+ if (preset.ShowDialog() == DialogResult.OK)\r
+ {\r
+ TreeNode presetTreeview = new TreeNode(presetHandler.LastPresetAdded.Name) { ForeColor = Color.Black };\r
+ treeView_presets.Nodes.Add(presetTreeview);\r
+ presetHandler.LastPresetAdded = null;\r
+ }\r
}\r
+\r
#endregion\r
\r
#region Help Menu\r
- private void mnu_handbrake_forums_Click(object sender, EventArgs e)\r
- {\r
- Process.Start("http://forum.handbrake.fr/");\r
- }\r
+\r
+ /// <summary>\r
+ /// Menu - Display the User Guide Web Page\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_user_guide_Click(object sender, EventArgs e)\r
{\r
Process.Start("http://trac.handbrake.fr/wiki/HandBrakeGuide");\r
}\r
- private void mnu_handbrake_home_Click(object sender, EventArgs e)\r
- {\r
- Process.Start("http://handbrake.fr");\r
- }\r
+\r
+ /// <summary>\r
+ /// Menu - Check for Updates\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
{\r
lbl_updateCheck.Visible = true;\r
- Main.BeginCheckForUpdates(new AsyncCallback(updateCheckDoneMenu), false);\r
+ Main.BeginCheckForUpdates(new AsyncCallback(this.UpdateCheckDoneMenu), false);\r
}\r
- private void updateCheckDoneMenu(IAsyncResult result)\r
- {\r
- // Make sure it's running on the calling thread\r
- if (InvokeRequired)\r
- {\r
- Invoke(new MethodInvoker(() => updateCheckDoneMenu(result)));\r
- return;\r
- }\r
- UpdateCheckInformation info;\r
- try\r
- {\r
- // Get the information about the new build, if any, and close the window\r
- info = Main.EndCheckForUpdates(result);\r
\r
- if (info.NewVersionAvailable && info.BuildInformation != null)\r
- {\r
- frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
- updateWindow.ShowDialog();\r
- }\r
- else\r
- MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
- lbl_updateCheck.Visible = false;\r
- return;\r
- }\r
- catch (Exception ex)\r
- {\r
- if ((bool)result.AsyncState)\r
- MessageBox.Show("Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
- }\r
- }\r
+ /// <summary>\r
+ /// Menu - Display the About Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void mnu_about_Click(object sender, EventArgs e)\r
{\r
using (frmAbout About = new frmAbout())\r
About.ShowDialog();\r
}\r
}\r
+\r
#endregion\r
\r
#region Preset Bar\r
- // Right Click Menu Code\r
+\r
+ /// <summary>\r
+ /// RMenu - Expand All\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void pmnu_expandAll_Click(object sender, EventArgs e)\r
{\r
treeView_presets.ExpandAll();\r
}\r
+\r
+ /// <summary>\r
+ /// RMenu - Collaspe All\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void pmnu_collapse_Click(object sender, EventArgs e)\r
{\r
treeView_presets.CollapseAll();\r
}\r
+\r
+ /// <summary>\r
+ /// Menu - Import Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void pmnu_import_Click(object sender, EventArgs e)\r
{\r
- importPreset();\r
+ ImportPreset();\r
}\r
+\r
+ /// <summary>\r
+ /// RMenu - Save Changes to Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void pmnu_saveChanges_Click(object sender, EventArgs e)\r
{\r
- DialogResult result = MessageBox.Show("Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);\r
+ // TODO this requires a re-think since the Query Editor has changed.\r
+ DialogResult result =\r
+ MessageBox.Show(\r
+ "Do you wish to include picture settings when updating the preset: " +\r
+ treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel,\r
+ MessageBoxIcon.Question);\r
if (result == DialogResult.Yes)\r
- presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), true);\r
+ presetHandler.Update(treeView_presets.SelectedNode.Text,\r
+ QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0), true);\r
else if (result == DialogResult.No)\r
- presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), false);\r
+ presetHandler.Update(treeView_presets.SelectedNode.Text,\r
+ QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0), false);\r
}\r
+\r
+ /// <summary>\r
+ /// RMenu - Delete Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void pmnu_delete_click(object sender, EventArgs e)\r
{\r
if (treeView_presets.SelectedNode != null)\r
}\r
treeView_presets.Select();\r
}\r
- private void presets_menu_Opening(object sender, System.ComponentModel.CancelEventArgs e)\r
+\r
+ /// <summary>\r
+ /// Preset Menu Is Opening. Setup the Menu\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void presets_menu_Opening(object sender, CancelEventArgs e)\r
{\r
// Make sure that the save menu is always disabled by default\r
pmnu_saveChanges.Enabled = false;\r
}\r
\r
// Presets Management\r
+\r
+ /// <summary>\r
+ /// Button - Add a preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_addPreset_Click(object sender, EventArgs e)\r
{\r
- Form preset = new frmAddPreset(this, QueryGenerator.GenerateTabbedComponentsQuery(this), presetHandler);\r
- preset.ShowDialog();\r
+ Form preset = new frmAddPreset(this, presetHandler);\r
+ if (preset.ShowDialog() == DialogResult.OK)\r
+ {\r
+ TreeNode presetTreeview = new TreeNode(presetHandler.LastPresetAdded.Name) { ForeColor = Color.Black };\r
+ treeView_presets.Nodes.Add(presetTreeview);\r
+ presetHandler.LastPresetAdded = null;\r
+ }\r
}\r
+\r
+ /// <summary>\r
+ /// Button - remove a Preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_removePreset_Click(object sender, EventArgs e)\r
{\r
- DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset",\r
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
if (result == DialogResult.Yes)\r
{\r
if (treeView_presets.SelectedNode != null)\r
}\r
treeView_presets.Select();\r
}\r
+\r
+ /// <summary>\r
+ /// Button - Set the selected preset as the default\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_setDefault_Click(object sender, EventArgs e)\r
{\r
if (treeView_presets.SelectedNode != null)\r
{\r
- DialogResult result = MessageBox.Show("Are you sure you wish to set this preset as the default?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ DialogResult result = MessageBox.Show("Are you sure you wish to set this preset as the default?",\r
+ "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
if (result == DialogResult.Yes)\r
{\r
Properties.Settings.Default.defaultPreset = treeView_presets.SelectedNode.Text;\r
else\r
MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
+\r
+ /// <summary>\r
+ /// PresetBar Mouse Down event\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void treeview_presets_mouseUp(object sender, MouseEventArgs e)\r
{\r
if (e.Button == MouseButtons.Right)\r
\r
treeView_presets.Select();\r
}\r
+\r
+ /// <summary>\r
+ /// Preset Bar after selecting the preset\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
{\r
selectPreset();\r
}\r
+\r
+ /// <summary>\r
+ /// Preset Bar - Handle the Delete Key\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
{\r
if (e.KeyCode == Keys.Delete)\r
{\r
- DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset",\r
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
if (result == DialogResult.Yes)\r
{\r
if (treeView_presets.SelectedNode != null)\r
presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
\r
// Remember each nodes expanded status so we can reload it\r
- List<Boolean> nodeStatus = new List<Boolean>();\r
+ List<bool> nodeStatus = new List<bool>();\r
foreach (TreeNode node in treeView_presets.Nodes)\r
nodeStatus.Add(node.IsExpanded);\r
\r
// Now reload the preset panel\r
- loadPresetPanel();\r
+ LoadPresetPanel();\r
\r
// And finally, re-expand any of the nodes if required\r
int i = 0;\r
}\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Select the selected preset and setup the GUI\r
+ /// </summary>\r
private void selectPreset()\r
{\r
if (treeView_presets.SelectedNode != null)\r
{\r
// Ok, so, we've selected a preset. Now we want to load it.\r
string presetName = treeView_presets.SelectedNode.Text;\r
- if (presetHandler.GetPreset(presetName) != null)\r
+ Preset preset = presetHandler.GetPreset(presetName);\r
+ if (preset != null)\r
{\r
string query = presetHandler.GetPreset(presetName).Query;\r
- Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
\r
if (query != null)\r
{\r
- //Ok, Reset all the H264 widgets before changing the preset\r
- x264Panel.reset2Defaults();\r
+ // Ok, Reset all the H264 widgets before changing the preset\r
+ x264Panel.Reset2Defaults();\r
\r
// Send the query from the file to the Query Parser class\r
QueryParser presetQuery = QueryParser.Parse(query);\r
\r
// Now load the preset\r
- PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);\r
+ PresetLoader.LoadPreset(this, presetQuery, presetName);\r
\r
// The x264 widgets will need updated, so do this now:\r
- x264Panel.X264_StandardizeOptString();\r
- x264Panel.X264_SetCurrentSettingsInPanel();\r
+ x264Panel.StandardizeOptString();\r
+ x264Panel.SetCurrentSettingsInPanel();\r
+\r
+ // Finally, let this window have a copy of the preset settings.\r
+ this.currentlySelectedPreset = preset;\r
+ PictureSettings.SetPresetCropWarningLabel(preset);\r
}\r
}\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Load the Normal Preset\r
+ /// </summary>\r
private void loadNormalPreset()\r
{\r
foreach (TreeNode treenode in treeView_presets.Nodes)\r
}\r
}\r
}\r
- private void importPreset()\r
+\r
+ /// <summary>\r
+ /// Import a plist preset\r
+ /// </summary>\r
+ private void ImportPreset()\r
{\r
- Import imp = new Import();\r
if (openPreset.ShowDialog() == DialogResult.OK)\r
{\r
- QueryParser parsed = imp.importMacPreset(openPreset.FileName);\r
+ QueryParser parsed = PlistPresetHandler.Import(openPreset.FileName);\r
if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
{\r
- DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",\r
- MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
+ DialogResult result =\r
+ MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?",\r
+ "Overwrite preset?",\r
+ MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null),\r
- parsed.UsesPictureSettings);\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
+ presetHandler.Update(parsed.PresetName + " (Imported)",\r
+ QueryGenerator.GenerateFullQuery(this),\r
+ parsed.UsesPictureSettings);\r
}\r
}\r
else\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings);\r
-\r
- if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings))\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
+ if (presetHandler.Add(parsed.PresetName + " (Imported)",\r
+ QueryGenerator.GenerateFullQuery(this),\r
+ parsed.UsesPictureSettings))\r
{\r
- TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };\r
+ TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)")\r
+ {\r
+ ForeColor = Color.Black\r
+ };\r
treeView_presets.Nodes.Add(preset_treeview);\r
}\r
}\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Export a plist Preset\r
+ /// </summary>\r
+ private void ExportPreset()\r
+ {\r
+ MessageBox.Show("This feature has not been implimented yet.", "Not Implimented", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return;\r
+\r
+ /*SaveFileDialog savefiledialog = new SaveFileDialog();\r
+ savefiledialog.Filter = "plist|*.plist";\r
+\r
+ if (treeView_presets.SelectedNode != null)\r
+ {\r
+\r
+ if (savefiledialog.ShowDialog() == DialogResult.OK)\r
+ {\r
+ Preset preset = presetHandler.GetPreset(treeView_presets.SelectedNode.Text);\r
+ PlistPresetHandler.Export(savefiledialog.FileName, preset);\r
+ }\r
+ }*/\r
+ }\r
+\r
#endregion\r
\r
#region ToolStrip\r
+\r
+ /// <summary>\r
+ /// Toolbar - When the Source button is clicked, Clear any DVD drives and add any available DVD drives that can be used as a source.\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_source_Click(object sender, EventArgs e)\r
{\r
- mnu_dvd_drive.Visible = true;\r
- Thread driveInfoThread = new Thread(getDriveInfoThread);\r
+ // Remove old Drive Menu Items.\r
+ List<ToolStripMenuItem> itemsToRemove = new List<ToolStripMenuItem>();\r
+ foreach (var item in btn_source.DropDownItems)\r
+ {\r
+ if (item.GetType() == typeof(ToolStripMenuItem))\r
+ {\r
+ ToolStripMenuItem menuItem = (ToolStripMenuItem)item;\r
+ if (menuItem.Name.StartsWith("Drive"))\r
+ {\r
+ itemsToRemove.Add(menuItem);\r
+ }\r
+ }\r
+ }\r
+\r
+ foreach (ToolStripMenuItem item in itemsToRemove)\r
+ btn_source.DropDownItems.Remove(item);\r
+\r
+ Thread driveInfoThread = new Thread(SetDriveSelectionMenuItem);\r
driveInfoThread.Start();\r
}\r
+\r
+ /// <summary>\r
+ /// Toolbar - Start The Encode\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_start_Click(object sender, EventArgs e)\r
{\r
if (btn_start.Text == "Stop")\r
{\r
- DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ DialogResult result = !Properties.Settings.Default.showCliForInGuiEncodeStatus\r
+ ? MessageBox.Show(\r
+ "Are you sure you wish to cancel the encode?\n\nPlease note: Stopping this encode will render the file unplayable. ",\r
+ "Cancel Encode?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question)\r
+ : MessageBox.Show(\r
+ "Are you sure you wish to cancel the encode?",\r
+ "Cancel Encode?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question);\r
\r
if (result == DialogResult.Yes)\r
{\r
// Pause The Queue\r
- encodeQueue.RequestPause();\r
+ encodeQueue.Pause();\r
\r
- // Allow the CLI to exit cleanly\r
- Win32.SetForegroundWindow((int)encodeQueue.processHandle);\r
- SendKeys.Send("^C");\r
-\r
- // Update the GUI\r
- setEncodeFinished();\r
+ if (Settings.Default.showCliForInGuiEncodeStatus)\r
+ encodeQueue.SafelyClose();\r
+ else\r
+ encodeQueue.Stop();\r
}\r
}\r
else\r
{\r
- if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))\r
+ // If we have a custom query, then we'll want to figure out what the new source and destination is, otherwise we'll just use the gui components.\r
+ string jobSourcePath = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetSourceFromQuery(rtf_query.Text) : sourcePath;\r
+ string jobDestination = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetDestinationFromQuery(rtf_query.Text) : text_destination.Text;\r
+\r
+ if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(jobSourcePath) && !string.IsNullOrEmpty(jobDestination)))\r
{\r
- string generatedQuery = queryGen.GenerateCLIQuery(this, 0, null);\r
- string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, 0, null);\r
+ string generatedQuery = QueryGenerator.GenerateFullQuery(this);\r
+ string specifiedQuery = rtf_query.Text != string.Empty\r
+ ? rtf_query.Text\r
+ : QueryGenerator.GenerateFullQuery(this);\r
string query = string.Empty;\r
\r
// Check to make sure the generated query matches the GUI settings\r
- if (Properties.Settings.Default.PromptOnUnmatchingQueries && !string.IsNullOrEmpty(specifiedQuery) && generatedQuery != specifiedQuery)\r
+ if (Properties.Settings.Default.PromptOnUnmatchingQueries && !string.IsNullOrEmpty(specifiedQuery) &&\r
+ generatedQuery != specifiedQuery)\r
{\r
DialogResult result = MessageBox.Show("The query under the \"Query Editor\" tab " +\r
- "does not match the current GUI settings.\n\nBecause the manual query takes " +\r
- "priority over the GUI, your recently updated settings will not be taken " +\r
- "into account when encoding this job." + Environment.NewLine + Environment.NewLine +\r
- "Do you want to replace the manual query with the updated GUI-generated query?",\r
- "Manual Query does not Match GUI",\r
- MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk,\r
- MessageBoxDefaultButton.Button3);\r
+ "does not match the current GUI settings.\n\nBecause the manual query takes " +\r
+ "priority over the GUI, your recently updated settings will not be taken " +\r
+ "into account when encoding this job." +\r
+ Environment.NewLine + Environment.NewLine +\r
+ "Do you want to replace the manual query with the updated GUI-generated query?",\r
+ "Manual Query does not Match GUI",\r
+ MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk,\r
+ MessageBoxDefaultButton.Button3);\r
\r
switch (result)\r
{\r
}\r
\r
DialogResult overwrite = DialogResult.Yes;\r
- if (text_destination.Text != "")\r
- if (File.Exists(text_destination.Text))\r
- overwrite = MessageBox.Show("The destination file already exists. Are you sure you want to overwrite it?", "Overwrite File?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ if (!string.IsNullOrEmpty(jobDestination) && File.Exists(jobDestination))\r
+ {\r
+ overwrite = MessageBox.Show(\r
+ "The destination file already exists. Are you sure you want to overwrite it?",\r
+ "Overwrite File?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question);\r
+ }\r
\r
if (overwrite == DialogResult.Yes)\r
{\r
if (encodeQueue.Count == 0)\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
\r
- queueWindow.setQueue();\r
+ queueWindow.SetQueue();\r
if (encodeQueue.Count > 1)\r
queueWindow.Show(false);\r
\r
- setEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
- encodeQueue.StartEncodeQueue(); // Start The Queue Encoding Process\r
- lastAction = "encode"; // Set the last action to encode - Used for activity window.\r
+ SetEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
+ encodeQueue.Start(); // Start The Queue Encoding Process\r
}\r
- if (ActivityWindow != null)\r
- ActivityWindow.SetEncodeMode();\r
\r
this.Focus();\r
}\r
else if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
- MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK,\r
+ MessageBoxIcon.Warning);\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Toolbar - Add the current job to the Queue\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_add2Queue_Click(object sender, EventArgs e)\r
{\r
- if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
- MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- else\r
- {\r
- String query = queryGen.GenerateCLIQuery(this, 0, null);\r
- if (rtf_query.Text != "")\r
- query = rtf_query.Text;\r
+ // Get the CLI query or use the query editor if it's not empty.\r
+ string query = QueryGenerator.GenerateFullQuery(this);\r
+ if (!string.IsNullOrEmpty(rtf_query.Text))\r
+ query = rtf_query.Text;\r
\r
- if (encodeQueue.CheckForDestinationDuplicate(text_destination.Text))\r
- {\r
- DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?",\r
- "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
- if (result == DialogResult.Yes)\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ // If we have a custom query, then we'll want to figure out what the new source and destination is, otherwise we'll just use the gui components.\r
+ string jobSourcePath = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetSourceFromQuery(rtf_query.Text) : sourcePath;\r
+ string jobDestination = !string.IsNullOrEmpty(rtf_query.Text) ? Main.GetDestinationFromQuery(rtf_query.Text) : text_destination.Text;\r
\r
- }\r
- else\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ // Make sure we have a Source and Destination.\r
+ if (string.IsNullOrEmpty(jobSourcePath) || string.IsNullOrEmpty(jobDestination))\r
+ {\r
+ MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return;\r
+ }\r
\r
- lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
+ // Make sure the destination path exists.\r
+ if (!Directory.Exists(Path.GetDirectoryName(jobDestination)))\r
+ {\r
+ MessageBox.Show("Destination Path does not exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return;\r
+ }\r
\r
- queueWindow.Show();\r
+ // Make sure we don't have a duplciate on the queue.\r
+ if (encodeQueue.CheckForDestinationDuplicate(jobDestination))\r
+ {\r
+ DialogResult result =\r
+ MessageBox.Show(\r
+ "There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?",\r
+ "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
+ if (result == DialogResult.Yes)\r
+ encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
}\r
+ else\r
+ encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
+\r
+ lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
+\r
+ queueWindow.Show();\r
}\r
+\r
+ /// <summary>\r
+ /// Toolbar - Show the Queue\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_showQueue_Click(object sender, EventArgs e)\r
{\r
queueWindow.Show();\r
queueWindow.Activate();\r
}\r
+\r
+ /// <summary>\r
+ /// Toolbar - Show the Preview Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void tb_preview_Click(object sender, EventArgs e)\r
{\r
if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
- MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK,\r
+ MessageBoxIcon.Warning);\r
else\r
{\r
if (qtpreview == null)\r
qtpreview.Show();\r
}\r
else\r
- MessageBox.Show(qtpreview, "The preview window is already open!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show(qtpreview, "The preview window is already open!", "Warning", MessageBoxButtons.OK,\r
+ MessageBoxIcon.Warning);\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Toolbar - Show the Activity log Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
{\r
- if (ActivityWindow == null || !ActivityWindow.IsHandleCreated)\r
- ActivityWindow = new frmActivityWindow(lastAction);\r
-\r
- switch (lastAction)\r
- {\r
- case "scan":\r
- ActivityWindow.SetScanMode();\r
- break;\r
- case "encode":\r
- ActivityWindow.SetEncodeMode();\r
- break;\r
- default:\r
- ActivityWindow.SetEncodeMode();\r
- break;\r
- }\r
+ if (this.activityWindow == null || !this.activityWindow.IsHandleCreated)\r
+ this.activityWindow = new frmActivityWindow(encodeQueue, SourceScan);\r
\r
- ActivityWindow.Show();\r
- ActivityWindow.Activate();\r
+ this.activityWindow.Show();\r
+ this.activityWindow.Activate();\r
}\r
+\r
#endregion\r
\r
#region System Tray Icon\r
+\r
+ /// <summary>\r
+ /// Handle Resizing of the main window when deaing with the Notify Icon\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void frmMain_Resize(object sender, EventArgs e)\r
{\r
if (FormWindowState.Minimized == this.WindowState)\r
else if (FormWindowState.Normal == this.WindowState)\r
notifyIcon.Visible = false;\r
}\r
+\r
+ /// <summary>\r
+ /// Double Click the Tray Icon\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
{\r
this.Visible = true;\r
this.WindowState = FormWindowState.Normal;\r
notifyIcon.Visible = false;\r
}\r
+\r
+ /// <summary>\r
+ /// Tray Icon - Restore Menu Item - Resture the Window\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
private void btn_restore_Click(object sender, EventArgs e)\r
{\r
this.Visible = true;\r
this.WindowState = FormWindowState.Normal;\r
notifyIcon.Visible = false;\r
}\r
+\r
#endregion\r
\r
- #region Tab Control\r
+ #region Main Window and Tab Control\r
\r
- //Source\r
+ // Source\r
private void btn_dvd_source_Click(object sender, EventArgs e)\r
{\r
if (DVD_Open.ShowDialog() == DialogResult.OK)\r
{\r
this.selectedSourceType = SourceType.Folder;\r
- selectSource(DVD_Open.SelectedPath);\r
+ SelectSource(DVD_Open.SelectedPath);\r
}\r
else\r
UpdateSourceLabel();\r
}\r
+\r
private void btn_file_source_Click(object sender, EventArgs e)\r
{\r
if (ISO_Open.ShowDialog() == DialogResult.OK)\r
{\r
this.selectedSourceType = SourceType.VideoFile;\r
- selectSource(ISO_Open.FileName);\r
+ SelectSource(ISO_Open.FileName);\r
}\r
else\r
UpdateSourceLabel();\r
}\r
+\r
private void mnu_dvd_drive_Click(object sender, EventArgs e)\r
{\r
- if (this.dvdDrivePath == null) return;\r
- this.selectedSourceType = SourceType.DvdDrive;\r
- selectSource(this.dvdDrivePath);\r
+ ToolStripMenuItem item = sender as ToolStripMenuItem;\r
+ if (item != null)\r
+ {\r
+ string driveId = item.Name.Replace("Drive", string.Empty);\r
+ int id;\r
+ if (int.TryParse(driveId, out id))\r
+ {\r
+ this.dvdDrivePath = drives[id].RootDirectory;\r
+ this.dvdDriveLabel = drives[id].VolumeLabel;\r
+\r
+ if (this.dvdDrivePath == null) return;\r
+ this.selectedSourceType = SourceType.DvdDrive;\r
+ SelectSource(this.dvdDrivePath);\r
+ }\r
+ }\r
}\r
- private void selectSource(string file)\r
+\r
+ private void SelectSource(string file)\r
{\r
Check_ChapterMarkers.Enabled = true;\r
- lastAction = "scan";\r
sourcePath = string.Empty;\r
\r
if (file == string.Empty) // Must have a file or path\r
return;\r
}\r
\r
- if (file.StartsWith("\\")) // NO UNC Paths\r
- {\r
- MessageBox.Show(\r
- "Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer",\r
- "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- UpdateSourceLabel();\r
- return;\r
- }\r
-\r
sourcePath = Path.GetFileName(file);\r
- StartScan(file);\r
+ StartScan(file, 0);\r
}\r
+\r
private void drp_dvdtitle_Click(object sender, EventArgs e)\r
{\r
if ((drp_dvdtitle.Items.Count == 1) && (drp_dvdtitle.Items[0].ToString() == "Automatic"))\r
- MessageBox.Show("There are no titles to select. Please load a source file by clicking the 'Source' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ MessageBox.Show(\r
+ "There are no titles to select. Please load a source file by clicking the 'Source' button above before trying to select a title.",\r
+ "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
}\r
+\r
private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
UnRegisterPresetEventHandler();\r
+ drop_mode.SelectedIndex = 0;\r
\r
- PictureSettings.lbl_Aspect.Text = "Select a Title"; // Reset some values on the form\r
drop_chapterStart.Items.Clear();\r
drop_chapterFinish.Items.Clear();\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
+ // Otheriwse if its not, title data has to be loaded from parsing.\r
if (drp_dvdtitle.Text != "Automatic")\r
{\r
selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
lbl_duration.Text = selectedTitle.Duration.ToString();\r
- PictureSettings.Source = selectedTitle; // Setup Picture Settings Tab Control\r
+ PictureSettings.CurrentlySelectedPreset = this.currentlySelectedPreset;\r
+ PictureSettings.Source = selectedTitle; // Setup Picture Settings Tab Control\r
\r
// Populate the Angles dropdown\r
drop_angle.Items.Clear();\r
{\r
drop_angle.Visible = true;\r
lbl_angle.Visible = true;\r
- drop_angle.Items.AddRange(selectedTitle.Angles.ToArray());\r
+\r
+ for (int i = 1; i <= selectedTitle.AngleCount; i++)\r
+ drop_angle.Items.Add(i.ToString());\r
+\r
if (drop_angle.Items.Count != 0)\r
drop_angle.SelectedIndex = 0;\r
}\r
drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
\r
// Populate the Audio Channels Dropdown\r
- AudioSettings.SetTrackList(selectedTitle);\r
+ AudioSettings.SetTrackList(selectedTitle, this.currentlySelectedPreset);\r
\r
// Populate the Subtitles dropdown\r
- Subtitles.drp_subtitleTracks.Items.Clear();\r
- Subtitles.drp_subtitleTracks.Items.Add("Foreign Audio Search (Bitmap)");\r
- Subtitles.drp_subtitleTracks.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
- Subtitles.drp_subtitleTracks.SelectedIndex = 0;\r
- Subtitles.Clear();\r
- Subtitles.SetSubtitleTrackAuto();\r
+ Subtitles.SetSubtitleTrackAuto(selectedTitle.Subtitles.ToArray());\r
}\r
// Update the source label if we have multiple streams\r
if (selectedTitle != null)\r
if (!string.IsNullOrEmpty(selectedTitle.SourceName))\r
labelSource.Text = labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
\r
- // Run the autoName & chapterNaming functions\r
+ // Run the AutoName & ChapterNaming functions\r
if (Properties.Settings.Default.autoNaming)\r
{\r
- string autoPath = Main.autoName(this);\r
+ string autoPath = Main.AutoName(this);\r
if (autoPath != null)\r
text_destination.Text = autoPath;\r
else\r
- MessageBox.Show("You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show(\r
+ "You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')",\r
+ "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
\r
data_chpt.Rows.Clear();\r
if (selectedTitle.Chapters.Count != 1)\r
{\r
- DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+ DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text);\r
if (chapterGridView != null)\r
data_chpt = chapterGridView;\r
}\r
\r
RegisterPresetEventHandler();\r
}\r
+\r
private void chapersChanged(object sender, EventArgs e)\r
{\r
+ if (drop_mode.SelectedIndex != 0) // Function is not used if we are not in chapters mode.\r
+ return;\r
+\r
Control ctl = (Control)sender;\r
int chapterStart, chapterEnd;\r
int.TryParse(drop_chapterStart.Text, out chapterStart);\r
}\r
\r
// Update the Duration\r
- lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
+ lbl_duration.Text =\r
+ Main.CalculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle)\r
+ .ToString();\r
\r
// Run the Autonaming function\r
if (Properties.Settings.Default.autoNaming)\r
- text_destination.Text = Main.autoName(this);\r
+ text_destination.Text = Main.AutoName(this);\r
\r
// Disable chapter markers if only 1 chapter is selected.\r
if (chapterStart == chapterEnd)\r
}\r
}\r
\r
- //Destination\r
+ private void SecondsOrFramesChanged(object sender, EventArgs e)\r
+ {\r
+ int start, end;\r
+ int.TryParse(drop_chapterStart.Text, out start);\r
+ int.TryParse(drop_chapterFinish.Text, out end);\r
+ double duration = end - start;\r
+\r
+ switch (drop_mode.SelectedIndex)\r
+ {\r
+ case 1:\r
+ lbl_duration.Text = TimeSpan.FromSeconds(duration).ToString();\r
+ return;\r
+ case 2:\r
+ if (selectedTitle != null)\r
+ {\r
+ duration = duration / selectedTitle.Fps;\r
+ lbl_duration.Text = TimeSpan.FromSeconds(duration).ToString();\r
+ }\r
+ else\r
+ lbl_duration.Text = "--:--:--";\r
+\r
+ return;\r
+ }\r
+ }\r
+\r
+ private void drop_mode_SelectedIndexChanged(object sender, EventArgs e)\r
+ {\r
+ // Reset\r
+ this.drop_chapterFinish.TextChanged -= new EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterStart.TextChanged -= new EventHandler(this.SecondsOrFramesChanged);\r
+\r
+ // Do Work\r
+ switch (drop_mode.SelectedIndex)\r
+ {\r
+ case 0:\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.DropDownList;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.DropDownList;\r
+ if (drop_chapterStart.Items.Count != 0)\r
+ {\r
+ drop_chapterStart.SelectedIndex = 0;\r
+ drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
+ }\r
+ else\r
+ lbl_duration.Text = "--:--:--";\r
+ return;\r
+ case 1:\r
+ this.drop_chapterStart.TextChanged += new EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterFinish.TextChanged += new EventHandler(this.SecondsOrFramesChanged);\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.Simple;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.Simple;\r
+ if (selectedTitle != null)\r
+ {\r
+ drop_chapterStart.Text = "0";\r
+ drop_chapterFinish.Text = selectedTitle.Duration.TotalSeconds.ToString();\r
+ }\r
+ return;\r
+ case 2:\r
+ this.drop_chapterStart.TextChanged += new EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterFinish.TextChanged += new EventHandler(this.SecondsOrFramesChanged);\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.Simple;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.Simple;\r
+ if (selectedTitle != null)\r
+ {\r
+ drop_chapterStart.Text = "0";\r
+ drop_chapterFinish.Text = (selectedTitle.Fps * selectedTitle.Duration.TotalSeconds).ToString();\r
+ }\r
+ return;\r
+ }\r
+ }\r
+\r
+ // Destination\r
private void btn_destBrowse_Click(object sender, EventArgs e)\r
{\r
// This removes the file extension from the filename box on the save file dialog.\r
\r
if (DVD_Save.ShowDialog() == DialogResult.OK)\r
{\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
+ // Add a file extension manually, as FileDialog.AddExtension has issues with dots in filenames\r
+ switch (DVD_Save.FilterIndex)\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
- if (Properties.Settings.Default.useM4v)\r
- DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".m4v").Replace(".mkv", ".m4v");\r
- else\r
- DVD_Save.FileName = DVD_Save.FileName.Replace(".m4v", ".mp4").Replace(".mkv", ".mp4");\r
- break;\r
- case 2:\r
- if (!Path.GetExtension(DVD_Save.FileName).Equals(".mkv", StringComparison.InvariantCultureIgnoreCase))\r
- DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".mkv").Replace(".m4v", ".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 && DVD_Save.FilterIndex != 2)\r
- SetExtension(".m4v");\r
+ case 1:\r
+ if (\r
+ !Path.GetExtension(DVD_Save.FileName).Equals(".mp4",\r
+ StringComparison.InvariantCultureIgnoreCase))\r
+ if (Properties.Settings.Default.useM4v)\r
+ DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".m4v").Replace(".mkv", ".m4v");\r
+ else\r
+ DVD_Save.FileName = DVD_Save.FileName.Replace(".m4v", ".mp4").Replace(".mkv", ".mp4");\r
+ break;\r
+ case 2:\r
+ if (\r
+ !Path.GetExtension(DVD_Save.FileName).Equals(".mkv", StringComparison.InvariantCultureIgnoreCase))\r
+ DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".mkv").Replace(".m4v", ".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 && DVD_Save.FilterIndex != 2)\r
+ SetExtension(".m4v");\r
}\r
}\r
+\r
private void text_destination_TextChanged(object sender, EventArgs e)\r
{\r
string path = text_destination.Text;\r
switch (drop_format.SelectedIndex)\r
{\r
case 0:\r
- if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
+ if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked ||\r
+ AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
SetExtension(".m4v");\r
else\r
SetExtension(".mp4");\r
}\r
\r
AudioSettings.SetContainer(drop_format.Text);\r
- Subtitles.SetContainer(drop_format.SelectedIndex);\r
\r
if (drop_format.Text.Contains("MP4"))\r
{\r
else if (drop_format.Text.Contains("MKV"))\r
drp_videoEncoder.Items.Add("VP3 (Theora)");\r
}\r
+\r
public void SetExtension(string newExtension)\r
{\r
if (newExtension == ".mp4" || newExtension == ".m4v")\r
- if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
+ if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() ||\r
+ Subtitles.RequiresM4V())\r
newExtension = ".m4v";\r
else\r
newExtension = ".mp4";\r
text_destination.Text = Path.ChangeExtension(text_destination.Text, newExtension);\r
}\r
\r
- //Video Tab\r
+ // Video Tab\r
private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
setContainerOpts();\r
\r
- //Turn off some options which are H.264 only when the user selects a non h.264 encoder\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
{\r
if (check_2PassEncode.CheckState == CheckState.Checked)\r
check_turbo.CheckState = CheckState.Unchecked;\r
check_turbo.Enabled = false;\r
tab_advanced.Enabled = false;\r
- x264Panel.x264Query = "";\r
+ x264Panel.X264Query = string.Empty;\r
check_iPodAtom.Enabled = false;\r
check_iPodAtom.Checked = false;\r
}\r
{\r
case "MPEG-4 (FFmpeg)":\r
if (slider_videoQuality.Value > 31)\r
- slider_videoQuality.Value = 20; // Just reset to 70% QP 10 on encode change.\r
+ slider_videoQuality.Value = 20; // Just reset to 70% QP 10 on encode change.\r
slider_videoQuality.Minimum = 1;\r
slider_videoQuality.Maximum = 31;\r
break;\r
double multiplier = 1.0 / cqStep;\r
double value = slider_videoQuality.Value * multiplier;\r
\r
- switch (Properties.Settings.Default.x264cqstep.ToString(culture))\r
- {\r
- case "0.2":\r
- slider_videoQuality.Maximum = 255;\r
- break;\r
- case "0.25":\r
- slider_videoQuality.Maximum = 204;\r
- break;\r
- case "0.5":\r
- slider_videoQuality.Maximum = 102;\r
- break;\r
- case "1":\r
- slider_videoQuality.Maximum = 51;\r
- break;\r
- default:\r
- slider_videoQuality.Maximum = 51;\r
- break;\r
- }\r
+ slider_videoQuality.Maximum = (int)(51 / Properties.Settings.Default.x264cqstep);\r
+\r
if (value < slider_videoQuality.Maximum)\r
slider_videoQuality.Value = slider_videoQuality.Maximum - (int)value;\r
\r
break;\r
case "VP3 (Theora)":\r
if (slider_videoQuality.Value > 63)\r
- slider_videoQuality.Value = 45; // Just reset to 70% QP 45 on encode change.\r
+ slider_videoQuality.Value = 45; // Just reset to 70% QP 45 on encode change.\r
slider_videoQuality.Minimum = 0;\r
slider_videoQuality.Maximum = 63;\r
break;\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// When the FrameRate is not Same As Source, show the Max/Constant Mode dropdown\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void drp_videoFramerate_SelectedIndexChanged(object sender, EventArgs e)\r
+ {\r
+ if (this.drp_videoFramerate.SelectedIndex == 0)\r
+ {\r
+ this.checkMaximumFramerate.Visible = false;\r
+ this.checkMaximumFramerate.CheckState = CheckState.Unchecked;\r
+ }\r
+ else\r
+ {\r
+ this.checkMaximumFramerate.Visible = true;\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Set the container format options\r
/// </summary>\r
check_iPodAtom.Checked = false;\r
}\r
}\r
- private double _cachedCqStep = Properties.Settings.Default.x264cqstep;\r
+\r
+ private double cachedCqStep = Properties.Settings.Default.x264cqstep;\r
+\r
/// <summary>\r
/// Update the CQ slider for x264 for a new CQ step. This is set from option\r
/// </summary>\r
public void setQualityFromSlider()\r
{\r
// Work out the current RF value.\r
- double cqStep = _cachedCqStep;\r
+ double cqStep = this.cachedCqStep;\r
double rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
\r
// Change the maximum value for the slider\r
- switch (Properties.Settings.Default.x264cqstep.ToString(new CultureInfo("en-US")))\r
- {\r
- case "0.2":\r
- slider_videoQuality.Maximum = 255;\r
- break;\r
- case "0.25":\r
- slider_videoQuality.Maximum = 204;\r
- break;\r
- case "0.5":\r
- slider_videoQuality.Maximum = 102;\r
- break;\r
- case "1":\r
- slider_videoQuality.Maximum = 51;\r
- break;\r
- default:\r
- slider_videoQuality.Maximum = 51;\r
- break;\r
- }\r
+ slider_videoQuality.Maximum = (int)(51 / Properties.Settings.Default.x264cqstep);\r
\r
// Reset the CQ slider to RF0\r
slider_videoQuality.Value = slider_videoQuality.Maximum;\r
}\r
\r
// Cache the CQ step for the next calculation\r
- _cachedCqStep = Properties.Settings.Default.x264cqstep;\r
+ this.cachedCqStep = Properties.Settings.Default.x264cqstep;\r
}\r
+\r
private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
{\r
double cqStep = Properties.Settings.Default.x264cqstep;\r
switch (drp_videoEncoder.Text)\r
{\r
case "MPEG-4 (FFmpeg)":\r
- double rfValue = 31 - (slider_videoQuality.Value - 1);\r
- double max = slider_videoQuality.Maximum;\r
- double min = slider_videoQuality.Minimum;\r
- double val = ((max - min) - (rfValue - min)) / (max - min);\r
lbl_SliderValue.Text = "QP:" + (32 - slider_videoQuality.Value);\r
- lbl_QualityValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
case "H.264 (x264)":\r
- rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
- max = slider_videoQuality.Maximum * cqStep;\r
- min = slider_videoQuality.Minimum;\r
- val = ((max - min) - (rfValue - min)) / (max - min);\r
+ double rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
rfValue = Math.Round(rfValue, 2);\r
lbl_SliderValue.Text = "RF:" + rfValue.ToString(new CultureInfo("en-US"));\r
- lbl_QualityValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
case "VP3 (Theora)":\r
- rfValue = slider_videoQuality.Value;\r
- double value = rfValue / 63;\r
lbl_SliderValue.Text = "QP:" + slider_videoQuality.Value;\r
- lbl_QualityValue.Text = Math.Round((value * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
}\r
}\r
+\r
private void radio_targetFilesize_CheckedChanged(object sender, EventArgs e)\r
{\r
text_bitrate.Enabled = false;\r
\r
check_2PassEncode.Enabled = true;\r
}\r
+\r
private void radio_avgBitrate_CheckedChanged(object sender, EventArgs e)\r
{\r
text_bitrate.Enabled = true;\r
\r
check_2PassEncode.Enabled = true;\r
}\r
+\r
private void radio_cq_CheckedChanged(object sender, EventArgs e)\r
{\r
text_bitrate.Enabled = false;\r
check_2PassEncode.Enabled = false;\r
check_2PassEncode.CheckState = CheckState.Unchecked;\r
}\r
+\r
private void check_2PassEncode_CheckedChanged(object sender, EventArgs e)\r
{\r
if (check_2PassEncode.CheckState.ToString() == "Checked")\r
btn_importChapters.Enabled = false;\r
}\r
}\r
+\r
private void btn_importChapters_Click(object sender, EventArgs e)\r
{\r
if (File_ChapterImport.ShowDialog() == DialogResult.OK)\r
{\r
- String filename = File_ChapterImport.FileName;\r
- DataGridView imported = Main.importChapterNames(data_chpt, filename);\r
+ string filename = File_ChapterImport.FileName;\r
+ DataGridView imported = Main.ImportChapterNames(data_chpt, filename);\r
if (imported != null)\r
data_chpt = imported;\r
}\r
}\r
+\r
+ private void btn_export_Click(object sender, EventArgs e)\r
+ {\r
+ SaveFileDialog saveFileDialog = new SaveFileDialog();\r
+ saveFileDialog.Filter = "Csv File|*.csv";\r
+ saveFileDialog.DefaultExt = "csv";\r
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)\r
+ {\r
+ string filename = saveFileDialog.FileName;\r
+\r
+ Main.SaveChapterMarkersToCsv(this, filename);\r
+ }\r
+ }\r
+\r
private void mnu_resetChapters_Click(object sender, EventArgs e)\r
{\r
data_chpt.Rows.Clear();\r
- DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+ DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text);\r
if (chapterGridView != null)\r
{\r
data_chpt = chapterGridView;\r
// Query Editor Tab\r
private void btn_generate_Query_Click(object sender, EventArgs e)\r
{\r
- rtf_query.Text = queryGen.GenerateCLIQuery(this, 0, null);\r
+ rtf_query.Text = QueryGenerator.GenerateFullQuery(this);\r
}\r
+\r
private void btn_clear_Click(object sender, EventArgs e)\r
{\r
rtf_query.Clear();\r
}\r
+\r
#endregion\r
\r
// MainWindow Components, Actions and Functions ***********************\r
\r
#region Source Scan\r
- public Boolean isScanning { get; set; }\r
- private Scan SourceScan;\r
\r
- private void StartScan(String filename)\r
+ /// <summary>\r
+ /// Start the Scan Process\r
+ /// </summary>\r
+ /// <param name="filename">\r
+ /// The filename.\r
+ /// </param>\r
+ /// <param name="title">\r
+ /// The title.\r
+ /// </param>\r
+ private void StartScan(string filename, int title)\r
{\r
// Setup the GUI components for the scan.\r
sourcePath = filename;\r
- foreach (Control ctrl in Controls)\r
- if (!(ctrl is StatusStrip || ctrl is MenuStrip || ctrl is ToolStrip))\r
- ctrl.Enabled = false;\r
-\r
- lbl_encode.Visible = true;\r
- lbl_encode.Text = "Scanning ...";\r
- btn_source.Enabled = false;\r
- btn_start.Enabled = false;\r
- btn_showQueue.Enabled = false;\r
- btn_add2Queue.Enabled = false;\r
- tb_preview.Enabled = false;\r
- mnu_killCLI.Visible = true;\r
\r
- if (ActivityWindow != null)\r
- ActivityWindow.SetScanMode();\r
+ this.DisableGUI();\r
\r
// Start the Scan\r
try\r
{\r
- // if (ActivityWindow != null)\r
- // ActivityWindow.SetupLogViewer(true);\r
- isScanning = true;\r
- SourceScan = new Scan();\r
- SourceScan.ScanSource(sourcePath);\r
+ SourceScan.Scan(sourcePath, title);\r
SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);\r
SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);\r
}\r
}\r
}\r
\r
- void SourceScan_ScanStatusChanged(object sender, EventArgs e)\r
+ /// <summary>\r
+ /// Update the Status label for the scan\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void SourceScan_ScanStatusChanged(object sender, EventArgs e)\r
{\r
UpdateScanStatusLabel();\r
}\r
- void SourceScan_ScanCompleted(object sender, EventArgs e)\r
+\r
+ /// <summary>\r
+ /// Update the UI after the scan has completed\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void SourceScan_ScanCompleted(object sender, EventArgs e)\r
{\r
UpdateGuiAfterScan();\r
}\r
\r
+ /// <summary>\r
+ /// Update the Scan Status Label\r
+ /// </summary>\r
private void UpdateScanStatusLabel()\r
{\r
if (InvokeRequired)\r
BeginInvoke(new UpdateWindowHandler(UpdateScanStatusLabel));\r
return;\r
}\r
- lbl_encode.Text = SourceScan.ScanStatus();\r
+ lbl_encode.Text = SourceScan.ScanStatus;\r
}\r
+\r
+ /// <summary>\r
+ /// Reset the GUI when the scan has completed\r
+ /// </summary>\r
private void UpdateGuiAfterScan()\r
{\r
if (InvokeRequired)\r
\r
try\r
{\r
- DVD thisDVD = SourceScan.SouceData();\r
+ currentSource = SourceScan.SouceData;\r
\r
// Setup some GUI components\r
drp_dvdtitle.Items.Clear();\r
- if (thisDVD.Titles.Count != 0)\r
- drp_dvdtitle.Items.AddRange(thisDVD.Titles.ToArray());\r
+ if (currentSource.Titles.Count != 0)\r
+ drp_dvdtitle.Items.AddRange(currentSource.Titles.ToArray());\r
+\r
+ foreach (Title title in currentSource.Titles)\r
+ {\r
+ if (title.MainTitle)\r
+ {\r
+ drp_dvdtitle.SelectedItem = title;\r
+ }\r
+ }\r
\r
- // Now select the longest title\r
- if (thisDVD.Titles.Count != 0)\r
- drp_dvdtitle.SelectedItem = Main.selectLongestTitle(thisDVD);\r
+ if (drp_dvdtitle.SelectedItem == null && drp_dvdtitle.Items.Count > 0)\r
+ {\r
+ drp_dvdtitle.SelectedIndex = 0;\r
+ }\r
\r
- // Enable the creation of chapter markers if the file is an image of a dvd.\r
- if (sourcePath.ToLower().Contains(".iso") || sourcePath.Contains("VIDEO_TS"))\r
- Check_ChapterMarkers.Enabled = true;\r
- else\r
+ // Enable the creation of chapter markers if the file is an image of a dvd\r
+ if (drop_chapterStart.Items.Count > 0)\r
{\r
- Check_ChapterMarkers.Enabled = false;\r
- Check_ChapterMarkers.Checked = false;\r
- data_chpt.Rows.Clear();\r
+ int start, end;\r
+ int.TryParse(drop_chapterStart.Items[0].ToString(), out start);\r
+ int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end);\r
+ if (end > start) Check_ChapterMarkers.Enabled = true;\r
+ else\r
+ {\r
+ Check_ChapterMarkers.Enabled = false;\r
+ Check_ChapterMarkers.Checked = false;\r
+ data_chpt.Rows.Clear();\r
+ }\r
}\r
\r
// If no titles were found, Display an error message\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("frmMain.cs - updateUIafterScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ MessageBox.Show("frmMain.cs - updateUIafterScan " + exc, "Error", MessageBoxButtons.OK,\r
+ MessageBoxIcon.Error);\r
EnableGUI();\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Enable the GUI\r
+ /// </summary>\r
private void EnableGUI()\r
{\r
try\r
MessageBox.Show("frmMain.cs - EnableGUI() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Disable the GUI\r
+ /// </summary>\r
+ private void DisableGUI()\r
+ {\r
+ foreach (Control ctrl in Controls)\r
+ if (!(ctrl is StatusStrip || ctrl is MenuStrip || ctrl is ToolStrip))\r
+ ctrl.Enabled = false;\r
+\r
+ lbl_encode.Visible = true;\r
+ lbl_encode.Text = "Scanning ...";\r
+ btn_source.Enabled = false;\r
+ btn_start.Enabled = false;\r
+ btn_showQueue.Enabled = false;\r
+ btn_add2Queue.Enabled = false;\r
+ tb_preview.Enabled = false;\r
+ mnu_killCLI.Visible = true;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Kill the Scan\r
+ /// </summary>\r
private void KillScan()\r
{\r
- try\r
- {\r
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
- EnableGUI();\r
- ResetGUI();\r
+ SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
+ EnableGUI();\r
+ ResetGUI();\r
\r
- if (SourceScan.ScanProcess() != null)\r
- SourceScan.ScanProcess().Kill();\r
+ SourceScan.Stop();\r
\r
- lbl_encode.Text = "Scan Cancelled!";\r
- }\r
- catch (Exception ex)\r
- {\r
- MessageBox.Show("Unable to kill HandBrakeCLI.exe \nYou may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically within the next few minutes. \n\nError Information: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
- }\r
+ lbl_encode.Text = "Scan Cancelled!";\r
}\r
+\r
+ /// <summary>\r
+ /// Reset the GUI\r
+ /// </summary>\r
private void ResetGUI()\r
{\r
drp_dvdtitle.Items.Clear();\r
drop_chapterFinish.Items.Clear();\r
lbl_duration.Text = "Select a Title";\r
PictureSettings.lbl_src_res.Text = "Select a Title";\r
- PictureSettings.lbl_Aspect.Text = "Select a Title";\r
sourcePath = String.Empty;\r
text_destination.Text = String.Empty;\r
selectedTitle = null;\r
- isScanning = false;\r
}\r
+\r
+ /// <summary>\r
+ /// Update the Source Label\r
+ /// </summary>\r
private void UpdateSourceLabel()\r
{\r
labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName;\r
\r
if (selectedTitle != null)\r
- if (!string.IsNullOrEmpty(selectedTitle.SourceName)) // If it's one of multiple source files, make sure we don't use the folder name\r
+ if (!string.IsNullOrEmpty(selectedTitle.SourceName))\r
+ // If it's one of multiple source files, make sure we don't use the folder name\r
labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
}\r
+\r
+ /// <summary>\r
+ /// Take a job from the Queue, rescan it, and reload the GUI for that job.\r
+ /// </summary>\r
+ /// <param name="job">\r
+ /// The job.\r
+ /// </param>\r
+ public void RecievingJob(Job job)\r
+ {\r
+ string query = job.Query;\r
+ StartScan(job.Source, job.Title);\r
+\r
+ if (query != null)\r
+ {\r
+ // Ok, Reset all the H264 widgets before changing the preset\r
+ x264Panel.Reset2Defaults();\r
+\r
+ // Send the query from the file to the Query Parser class\r
+ QueryParser presetQuery = QueryParser.Parse(query);\r
+\r
+ // Now load the preset\r
+ PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue");\r
+\r
+ // The x264 widgets will need updated, so do this now:\r
+ x264Panel.StandardizeOptString();\r
+ x264Panel.SetCurrentSettingsInPanel();\r
+\r
+ // Finally, let this window have a copy of the preset settings.\r
+ this.currentlySelectedPreset = null;\r
+ PictureSettings.SetPresetCropWarningLabel(null);\r
+ }\r
+ }\r
+\r
#endregion\r
\r
- #region GUI\r
+ #region GUI Functions and Actions\r
+\r
/// <summary>\r
/// Set the GUI to it's finished encoding state.\r
/// </summary>\r
- private void setEncodeFinished()\r
+ private void SetEncodeFinished()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
+ BeginInvoke(new UpdateWindowHandler(SetEncodeFinished));\r
return;\r
}\r
\r
lbl_encode.Text = "Encoding Finished";\r
+ ProgressBarStatus.Visible = false;\r
btn_start.Text = "Start";\r
btn_start.ToolTipText = "Start the encoding process";\r
btn_start.Image = Properties.Resources.Play;\r
/// <summary>\r
/// Set the GUI to it's started encoding state.\r
/// </summary>\r
- private void setEncodeStarted()\r
+ private void SetEncodeStarted()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
+ BeginInvoke(new UpdateWindowHandler(SetEncodeStarted));\r
return;\r
}\r
-\r
lbl_encode.Visible = true;\r
+ ProgressBarStatus.Value = 0;\r
+ ProgressBarStatus.Visible = true;\r
lbl_encode.Text = "Encoding with " + encodeQueue.Count + " encode(s) pending";\r
btn_start.Text = "Stop";\r
btn_start.ToolTipText = "Stop the encoding process.";\r
MessageBox.Show(exc.ToString());\r
}\r
}\r
- #endregion\r
\r
- #region DVD Drive Detection\r
- private void getDriveInfoThread()\r
+ /// <summary>\r
+ /// Display the Encode Status\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void EncodeQueue_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e)\r
+ {\r
+ if (this.InvokeRequired)\r
+ {\r
+ this.BeginInvoke(new Encode.EncodeProgessStatus(EncodeQueue_EncodeStatusChanged), new[] { sender, e });\r
+ return;\r
+ }\r
+\r
+ lbl_encode.Text =\r
+ string.Format(\r
+ "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Encode(s) Pending {4}",\r
+ e.PercentComplete,\r
+ e.CurrentFrameRate,\r
+ e.AverageFrameRate,\r
+ e.EstimatedTimeLeft,\r
+ encodeQueue.Count);\r
+\r
+ ProgressBarStatus.Value = (int)Math.Round(e.PercentComplete);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Set the DVD Drive selection in the "Source" Menu\r
+ /// </summary>\r
+ private void SetDriveSelectionMenuItem()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(getDriveInfoThread));\r
+ BeginInvoke(new UpdateWindowHandler(SetDriveSelectionMenuItem));\r
return;\r
}\r
\r
- Boolean foundDrive = false;\r
- DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
- foreach (DriveInfo curDrive in theCollectionOfDrives)\r
+ drives = Main.GetDrives();\r
+\r
+ List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();\r
+ foreach (DriveInformation drive in drives)\r
{\r
- if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)\r
- {\r
- if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
+ ToolStripMenuItem menuItem = new ToolStripMenuItem\r
{\r
- this.dvdDrivePath = curDrive.RootDirectory + "VIDEO_TS";\r
- this.dvdDriveLabel = curDrive.VolumeLabel;\r
- mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")";\r
- foundDrive = true;\r
- break;\r
- }\r
- }\r
+ Name = drive.ToString(),\r
+ Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")",\r
+ Image = Resources.disc_small\r
+ };\r
+ menuItem.Click += new EventHandler(mnu_dvd_drive_Click);\r
+ menuItems.Add(menuItem);\r
}\r
\r
- if (foundDrive == false)\r
- mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
+ foreach (ToolStripMenuItem item in menuItems)\r
+ btn_source.DropDownItems.Add(item);\r
}\r
- catch (Exception)\r
+ catch (Exception exc)\r
{\r
- mnu_dvd_drive.Text = "[No DVD Drive Ready / Found]";\r
+ MessageBox.Show("Error in SetDriveSelectionMenuItem" + exc);\r
}\r
}\r
- #endregion\r
\r
- #region Public Methods\r
/// <summary>\r
/// Access the preset Handler and setup the preset panel.\r
/// </summary>\r
- public void loadPresetPanel()\r
+ private void LoadPresetPanel()\r
{\r
if (presetHandler.CheckIfPresetsAreOutOfDate())\r
- if (!Properties.Settings.Default.presetNotification)\r
- MessageBox.Show(splash,\r
- "HandBrake has determined your built-in presets are out of date... These presets will now be updated.",\r
- "Preset Update", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+ if (!Settings.Default.presetNotification)\r
+ MessageBox.Show(this,\r
+ "HandBrake has determined your built-in presets are out of date... These presets will now be updated.",\r
+ "Preset Update", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
\r
presetHandler.GetPresetPanel(ref treeView_presets);\r
treeView_presets.Update();\r
}\r
- #endregion\r
\r
- #region Overrides\r
/// <summary>\r
- /// If the queue is being processed, prompt the user to confirm application close.\r
+ /// Get the title from the selected item in the title dropdown.\r
/// </summary>\r
- /// <param name="e"></param>\r
- protected override void OnFormClosing(FormClosingEventArgs e)\r
+ /// <returns>\r
+ /// The title.\r
+ /// </returns>\r
+ private int GetTitle()\r
{\r
- // If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
- if ((encodeQueue.isEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))\r
+ int title = 0;\r
+ if (drp_dvdtitle.SelectedItem != null)\r
{\r
- DialogResult result = MessageBox.Show("HandBrake has queue items to process. Closing HandBrake will not stop the current encoding, but will stop processing the queue.\n\nDo you want to close HandBrake?",\r
- "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
- if (result == DialogResult.No)\r
- e.Cancel = true;\r
+ string[] titleInfo = drp_dvdtitle.SelectedItem.ToString().Split(' ');\r
+ int.TryParse(titleInfo[0], out title);\r
}\r
- base.OnFormClosing(e);\r
+\r
+ return title;\r
}\r
- #endregion\r
\r
- #region In-GUI Encode Status (Experimental)\r
- private void encodeMonitorThread()\r
+ /// <summary>\r
+ /// Handle the Update Check Finishing.\r
+ /// </summary>\r
+ /// <param name="result">\r
+ /// The result.\r
+ /// </param>\r
+ private void UpdateCheckDoneMenu(IAsyncResult result)\r
{\r
+ // Make sure it's running on the calling thread\r
+ if (InvokeRequired)\r
+ {\r
+ Invoke(new MethodInvoker(() => this.UpdateCheckDoneMenu(result)));\r
+ return;\r
+ }\r
+ UpdateCheckInformation info;\r
try\r
{\r
- Parser encode = new Parser(encodeQueue.hbProcess.StandardOutput.BaseStream);\r
- encode.OnEncodeProgress += encodeOnEncodeProgress;\r
- while (!encode.EndOfStream)\r
- encode.readEncodeStatus();\r
+ // Get the information about the new build, if any, and close the window\r
+ info = Main.EndCheckForUpdates(result);\r
+\r
+ if (info.NewVersionAvailable && info.BuildInformation != null)\r
+ {\r
+ frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+ updateWindow.ShowDialog();\r
+ }\r
+ else\r
+ MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK,\r
+ MessageBoxIcon.Information);\r
+ lbl_updateCheck.Visible = false;\r
+ return;\r
}\r
- catch (Exception exc)\r
+ catch (Exception ex)\r
{\r
- MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ if ((bool)result.AsyncState)\r
+ MessageBox.Show(\r
+ "Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex,\r
+ "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
- private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
+\r
+ #endregion\r
+\r
+ #region Overrides\r
+\r
+ /// <summary>\r
+ /// Handle GUI shortcuts\r
+ /// </summary>\r
+ /// <param name="msg">Message</param>\r
+ /// <param name="keyData">Keys</param>\r
+ /// <returns>Bool</returns>\r
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\r
{\r
- if (this.InvokeRequired)\r
+ if (keyData == (Keys.Control | Keys.S))\r
{\r
- this.BeginInvoke(new EncodeProgressEventHandler(encodeOnEncodeProgress),\r
- new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
- return;\r
+ btn_start_Click(this, new EventArgs());\r
+ return true;\r
+ }\r
+\r
+ if (keyData == (Keys.Control | Keys.A))\r
+ {\r
+ btn_add2Queue_Click(this, new EventArgs());\r
+ return true;\r
}\r
- lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);\r
+ return base.ProcessCmdKey(ref msg, keyData);\r
}\r
- #endregion\r
\r
- #region enum\r
- private enum SourceType\r
+ /// <summary>\r
+ /// If the queue is being processed, prompt the user to confirm application close.\r
+ /// </summary>\r
+ /// <param name="e">FormClosingEventArgs</param>\r
+ protected override void OnFormClosing(FormClosingEventArgs e)\r
{\r
- None = 0,\r
- Folder,\r
- DvdDrive,\r
- VideoFile\r
+ try\r
+ {\r
+ // If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
+ if (encodeQueue.IsEncoding)\r
+ {\r
+ DialogResult result =\r
+ MessageBox.Show(\r
+ "HandBrake is currently encoding. Closing HandBrake will stop the current encode and will result in an unplayable file.\n\nDo you want to close HandBrake?",\r
+ "Close HandBrake?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question);\r
+\r
+ if (result == DialogResult.No)\r
+ {\r
+ e.Cancel = true;\r
+ return;\r
+ }\r
+\r
+ encodeQueue.Stop();\r
+ }\r
+\r
+ if (SourceScan.IsScanning)\r
+ {\r
+ SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
+ SourceScan.Stop();\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ Main.ShowExceptiowWindow("HandBrake was not able to shutdown properly. You may need to forcefully quit HandBrake CLI from TaskManager if it's still running.", exc.ToString());\r
+ }\r
+ finally\r
+ {\r
+ base.OnFormClosing(e);\r
+ }\r
}\r
+\r
#endregion\r
\r
// This is the END of the road ****************************************\r