using System.Drawing;\r
using System.Globalization;\r
using System.IO;\r
- using System.Reflection;\r
+ using System.Linq;\r
using System.Threading;\r
using System.Windows.Forms;\r
+\r
+ using DevExpress.Utils.Menu;\r
+\r
using Functions;\r
+\r
+ using HandBrake.ApplicationServices.EventArgs;\r
+ using HandBrake.ApplicationServices.Utilities;\r
+ using HandBrake.Framework.Model;\r
+ using HandBrake.Framework.Services;\r
+ using HandBrake.Framework.Views;\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 Handbrake.ToolWindows;\r
+\r
using Model;\r
- using Parsing;\r
- using Presets;\r
using Properties;\r
- using Services;\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
- private Queue encodeQueue = new Queue();\r
- private PresetsHandler presetHandler = new PresetsHandler();\r
+ private IQueueProcessor queueProcessor = new QueueProcessor(Program.InstanceId);\r
+ private PresetService presetHandler = new PresetService();\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 ActivityLogMode lastAction;\r
private SourceType selectedSourceType;\r
private string dvdDrivePath;\r
private string dvdDriveLabel;\r
- private Preset CurrentlySelectedPreset;\r
- private DVD currentSource;\r
- private Scan SourceScan = new Scan();\r
+ private Preset currentlySelectedPreset;\r
+ private Source currentSource;\r
+\r
+ private IScan SourceScan;\r
private List<DriveInformation> drives;\r
+ private QueueTask queueEdit;\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
\r
// Applicaiton Startup ************************************************\r
\r
- #region Application Startup\r
+ #region Properties\r
\r
- public frmMain()\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 (selectedTitle != null && !string.IsNullOrEmpty(selectedTitle.SourceName))\r
+ {\r
+ return Path.GetFileName(selectedTitle.SourceName);\r
+ }\r
+\r
+ // We have a drive, selected as a folder.\r
+ if (this.sourcePath.EndsWith("\\"))\r
+ {\r
+ drives = UtilityService.GetDrives();\r
+ foreach (DriveInformation item in drives)\r
+ {\r
+ if (item.RootDirectory.Contains(this.sourcePath))\r
+ {\r
+ return item.VolumeLabel;\r
+ }\r
+ }\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
+ this.presetsToolStrip.Renderer = new ToolStripRenderOverride();\r
+\r
+ // We can use LibHB, if the library hb.dll exists.\r
+ this.SourceScan = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();\r
\r
// Update the users config file with the CLI version data.\r
- lblStatus.Text = "Checking CLI Version Data ...";\r
- Application.DoEvents();\r
Main.SetCliVersionData();\r
- Main.CheckForValidCliVersion();\r
\r
if (Settings.Default.hb_version.Contains("svn"))\r
{\r
- Version v = Assembly.GetExecutingAssembly().GetName().Version;\r
- this.Text += " " + v.ToString(4);\r
+ this.Text += " " + Settings.Default.hb_version;\r
}\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
-\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
+ // Set when the last update was\r
+ Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
+ Settings.Default.Save();\r
+ string url = Settings.Default.hb_build.ToString().EndsWith("1")\r
+ ? Settings.Default.appcast_unstable\r
+ : Settings.Default.appcast;\r
+ UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, Settings.Default.hb_build, Settings.Default.skipversion, Settings.Default.hb_version);\r
}\r
}\r
\r
// Clear the log files in the background\r
- if (Properties.Settings.Default.clearOldLogs)\r
+ if (Settings.Default.clearOldLogs)\r
{\r
- lblStatus.Text = "Clearing Old Log Files ...";\r
- Application.DoEvents();\r
- Thread clearLog = new Thread(Main.ClearOldLogs);\r
+ Thread clearLog = new Thread(() => UtilityService.ClearLogFiles(30));\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
treeView_presets.ExpandAll();\r
lbl_encode.Text = string.Empty;\r
drop_mode.SelectedIndex = 0;\r
- queueWindow = new frmQueue(encodeQueue, this); // Prepare the Queue\r
- if (!Properties.Settings.Default.QueryEditorTab)\r
+ queueWindow = new frmQueue(this.queueProcessor, 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 != string.Empty)\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
- bool loadPictureSettings =\r
- presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings;\r
-\r
- if (query != null)\r
- {\r
- x264Panel.Reset2Defaults();\r
+ x264Panel.Reset2Defaults();\r
\r
- QueryParser presetQuery = QueryParser.Parse(query);\r
- PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset,\r
- loadPictureSettings);\r
+ EncodeTask presetQuery = QueryParserUtility.Parse(query);\r
+ PresetLoader.LoadPreset(this, presetQuery, Settings.Default.defaultPreset);\r
\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(this.queueProcessor);\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
return;\r
}\r
\r
- UpdateCheckInformation info;\r
-\r
try\r
{\r
- info = Main.EndCheckForUpdates(result);\r
+ UpdateCheckInformation info = UpdateService.EndCheckForUpdates(result);\r
\r
if (info.NewVersionAvailable)\r
{\r
- frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+ UpdateInfo updateWindow = new UpdateInfo(info.BuildInformation, Settings.Default.hb_version, Settings.Default.hb_build.ToString());\r
updateWindow.ShowDialog();\r
}\r
}\r
catch (Exception ex)\r
{\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
-\r
- // Startup Functions \r
- private void queueRecovery()\r
- {\r
- if (Main.CheckQueueRecovery())\r
- {\r
- DialogResult result =\r
- MessageBox.Show(\r
- "HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",\r
- "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
- }\r
- }\r
-\r
- #endregion\r
-\r
- #region Properties\r
-\r
- public string SourceName\r
- {\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
+ Main.ShowExceptiowWindow("Unable to check for updates, Please try again later.", ex.ToString());\r
}\r
}\r
\r
RegisterPresetEventHandler();\r
\r
// Handle Window Resize\r
- if (Properties.Settings.Default.MainWindowMinimize)\r
- this.Resize += new EventHandler(frmMain_Resize);\r
+ if (Settings.Default.MainWindowMinimize)\r
+ this.Resize += this.frmMain_Resize;\r
\r
// Handle Encode Start / Finish / Pause\r
+ this.queueProcessor.EncodeService.EncodeStarted += this.encodeStarted;\r
+ this.queueProcessor.EncodeService.EncodeCompleted += encodeEnded;\r
\r
- encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
- encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
- encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
+ // Scan Started and Completed Events\r
+ SourceScan.ScanStatusChanged += this.SourceScanScanStatusChanged;\r
+ SourceScan.ScanCompleted += this.SourceScanScanCompleted;\r
\r
// Handle a file being draged onto the GUI.\r
- this.DragEnter += new DragEventHandler(frmMain_DragEnter);\r
- this.DragDrop += new DragEventHandler(frmMain_DragDrop);\r
+ this.DragEnter += frmMain_DragEnter;\r
+ this.DragDrop += this.frmMain_DragDrop;\r
}\r
\r
// Change the preset label to custom when a user changes a setting. Don't want to give the impression that users can change settings and still be using a preset\r
private void RegisterPresetEventHandler()\r
{\r
// Output Settings\r
- drop_format.SelectedIndexChanged += new EventHandler(changePresetLabel);\r
- check_largeFile.CheckedChanged += new EventHandler(changePresetLabel);\r
- check_iPodAtom.CheckedChanged += new EventHandler(changePresetLabel);\r
- check_optimiseMP4.CheckedChanged += new EventHandler(changePresetLabel);\r
+ drop_format.SelectedIndexChanged += this.changePresetLabel;\r
+ check_largeFile.CheckedChanged += this.changePresetLabel;\r
+ check_iPodAtom.CheckedChanged += this.changePresetLabel;\r
+ check_optimiseMP4.CheckedChanged += this.changePresetLabel;\r
\r
// Picture Settings\r
- // PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
+ PictureSettings.PictureSettingsChanged += this.changePresetLabel;\r
\r
// Filter Settings\r
- Filters.FilterSettingsChanged += new EventHandler(changePresetLabel);\r
+ Filters.FilterSettingsChanged += this.changePresetLabel;\r
\r
// Video Tab\r
- drp_videoEncoder.SelectedIndexChanged += new EventHandler(changePresetLabel);\r
- check_2PassEncode.CheckedChanged += new EventHandler(changePresetLabel);\r
- check_turbo.CheckedChanged += new EventHandler(changePresetLabel);\r
- text_filesize.TextChanged += new EventHandler(changePresetLabel);\r
- text_bitrate.TextChanged += new EventHandler(changePresetLabel);\r
- slider_videoQuality.ValueChanged += new EventHandler(changePresetLabel);\r
+ drp_videoEncoder.SelectedIndexChanged += this.changePresetLabel;\r
+ check_2PassEncode.CheckedChanged += this.changePresetLabel;\r
+ check_turbo.CheckedChanged += this.changePresetLabel;\r
+ text_bitrate.TextChanged += this.changePresetLabel;\r
+ slider_videoQuality.ValueChanged += this.changePresetLabel;\r
\r
// Audio Panel\r
- AudioSettings.AudioListChanged += new EventHandler(changePresetLabel);\r
+ AudioSettings.AudioListChanged += this.changePresetLabel;\r
\r
// Advanced Tab\r
- x264Panel.rtf_x264Query.TextChanged += new EventHandler(changePresetLabel);\r
+ x264Panel.rtf_x264Query.TextChanged += this.changePresetLabel;\r
}\r
\r
private void UnRegisterPresetEventHandler()\r
{\r
// Output Settings \r
- drop_format.SelectedIndexChanged -= new EventHandler(changePresetLabel);\r
- check_largeFile.CheckedChanged -= new EventHandler(changePresetLabel);\r
- check_iPodAtom.CheckedChanged -= new EventHandler(changePresetLabel);\r
- check_optimiseMP4.CheckedChanged -= new EventHandler(changePresetLabel);\r
+ drop_format.SelectedIndexChanged -= this.changePresetLabel;\r
+ check_largeFile.CheckedChanged -= this.changePresetLabel;\r
+ check_iPodAtom.CheckedChanged -= this.changePresetLabel;\r
+ check_optimiseMP4.CheckedChanged -= this.changePresetLabel;\r
\r
// Picture Settings\r
- // PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
+ PictureSettings.PictureSettingsChanged -= this.changePresetLabel;\r
\r
// Filter Settings\r
- Filters.FilterSettingsChanged -= new EventHandler(changePresetLabel);\r
+ Filters.FilterSettingsChanged -= this.changePresetLabel;\r
\r
// Video Tab\r
- drp_videoEncoder.SelectedIndexChanged -= new EventHandler(changePresetLabel);\r
- check_2PassEncode.CheckedChanged -= new EventHandler(changePresetLabel);\r
- check_turbo.CheckedChanged -= new EventHandler(changePresetLabel);\r
- text_filesize.TextChanged -= new EventHandler(changePresetLabel);\r
- text_bitrate.TextChanged -= new EventHandler(changePresetLabel);\r
- slider_videoQuality.ValueChanged -= new EventHandler(changePresetLabel);\r
+ drp_videoEncoder.SelectedIndexChanged -= this.changePresetLabel;\r
+ check_2PassEncode.CheckedChanged -= this.changePresetLabel;\r
+ check_turbo.CheckedChanged -= this.changePresetLabel;\r
+ text_bitrate.TextChanged -= this.changePresetLabel;\r
+ slider_videoQuality.ValueChanged -= this.changePresetLabel;\r
\r
// Audio Panel\r
- AudioSettings.AudioListChanged -= new EventHandler(changePresetLabel);\r
+ AudioSettings.AudioListChanged -= this.changePresetLabel;\r
\r
// Advanced Tab\r
- x264Panel.rtf_x264Query.TextChanged -= new EventHandler(changePresetLabel);\r
+ x264Panel.rtf_x264Query.TextChanged -= this.changePresetLabel;\r
}\r
\r
private void changePresetLabel(object sender, EventArgs e)\r
{\r
labelPreset.Text = "Output Settings (Preset: Custom)";\r
- CurrentlySelectedPreset = null;\r
+ this.currentlySelectedPreset = null;\r
}\r
\r
private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
\r
if (fileList != null)\r
{\r
- if (fileList[0] != string.Empty)\r
+ if (!string.IsNullOrEmpty(fileList[0]))\r
{\r
this.selectedSourceType = SourceType.VideoFile;\r
StartScan(fileList[0], 0);\r
\r
private void encodeStarted(object sender, EventArgs e)\r
{\r
- lastAction = ActivityLogMode.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
+ this.queueProcessor.EncodeService.EncodeStatusChanged += EncodeQueue_EncodeStatusChanged;\r
}\r
\r
private void encodeEnded(object sender, EventArgs e)\r
{\r
+ this.queueProcessor.EncodeService.EncodeStatusChanged -= EncodeQueue_EncodeStatusChanged;\r
SetEncodeFinished();\r
}\r
-\r
- private void encodePaused(object sender, EventArgs e)\r
- {\r
- SetEncodeFinished();\r
- }\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
#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, encodeQueue, SourceScan);\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
\r
#endregion\r
\r
- #region Presets Menu\r
+ #region Help Menu (Toolbar)\r
\r
- private void mnu_presetReset_Click(object sender, EventArgs e)\r
- {\r
- presetHandler.UpdateBuiltInPresets();\r
- LoadPresetPanel();\r
- if (treeView_presets.Nodes.Count == 0)\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
- private void mnu_delete_preset_Click(object sender, EventArgs e)\r
- {\r
- presetHandler.RemoveBuiltInPresets();\r
- LoadPresetPanel(); // Reload the preset panel\r
- }\r
-\r
- private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
- {\r
- loadNormalPreset();\r
- }\r
-\r
- private void mnu_importMacPreset_Click(object sender, EventArgs e)\r
- {\r
- ImportPreset();\r
- }\r
-\r
- private void btn_new_preset_Click(object sender, EventArgs e)\r
- {\r
- Form preset = new frmAddPreset(this, QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),\r
- presetHandler);\r
- preset.ShowDialog();\r
- }\r
-\r
- #endregion\r
-\r
- #region Help Menu\r
-\r
- private void mnu_user_guide_Click(object sender, EventArgs e)\r
+ /// <summary>\r
+ /// Menu - Display the User Guide Web Page\r
+ /// </summary>\r
+ /// <param name="sender">The Sender</param>\r
+ /// <param name="e">The EventArgs</param>\r
+ private void MnuUserGuide_Click(object sender, EventArgs e)\r
{\r
Process.Start("http://trac.handbrake.fr/wiki/HandBrakeGuide");\r
}\r
\r
- private void mnu_handbrake_home_Click(object sender, EventArgs e)\r
- {\r
- Process.Start("http://handbrake.fr");\r
- }\r
-\r
- private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
+ /// <summary>\r
+ /// Check for Updates\r
+ /// </summary>\r
+ /// <param name="sender">The Sender</param>\r
+ /// <param name="e">The EventArgs</param>\r
+ private void MnuCheckForUpdates_Click(object sender, EventArgs e)\r
{\r
lbl_updateCheck.Visible = true;\r
- Main.BeginCheckForUpdates(new AsyncCallback(updateCheckDoneMenu), false);\r
- }\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,\r
- MessageBoxIcon.Information);\r
- lbl_updateCheck.Visible = false;\r
- return;\r
- }\r
- catch (Exception ex)\r
- {\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
+ Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
+ Settings.Default.Save();\r
+ string url = Settings.Default.hb_build.ToString().EndsWith("1")\r
+ ? Settings.Default.appcast_unstable\r
+ : Settings.Default.appcast;\r
+ UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDoneMenu), false, url, Settings.Default.hb_build, Settings.Default.skipversion, Settings.Default.hb_version);\r
}\r
\r
- private void mnu_about_Click(object sender, EventArgs e)\r
+ /// <summary>\r
+ /// Menu - Display the About Window\r
+ /// </summary>\r
+ /// <param name="sender">The Sender</param>\r
+ /// <param name="e">The EventArgs</param>\r
+ private void MnuAboutHandBrake_Click(object sender, EventArgs e)\r
{\r
using (frmAbout About = new frmAbout())\r
{\r
\r
#region Preset Bar\r
\r
- // Right Click Menu Code\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
}\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 =\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,\r
- QueryGenerator.GenerateTabbedComponentsQuery(this), true);\r
- else if (result == DialogResult.No)\r
- presetHandler.Update(treeView_presets.SelectedNode.Text,\r
- QueryGenerator.GenerateTabbedComponentsQuery(this), false);\r
+\r
+ Preset preset = new Preset\r
+ {\r
+ Name = this.treeView_presets.SelectedNode.Text,\r
+ Query =\r
+ QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0),\r
+ CropSettings = (result == DialogResult.Yes)\r
+ };\r
+\r
+ presetHandler.Update(preset);\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
- presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
+ presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);\r
treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
}\r
treeView_presets.Select();\r
}\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
\r
// Now enable the save menu if the selected preset is a user preset\r
if (treeView_presets.SelectedNode != null)\r
- if (presetHandler.CheckIfUserPresetExists(treeView_presets.SelectedNode.Text))\r
+ if (presetHandler.CheckIfPresetExists(treeView_presets.SelectedNode.Text))\r
pmnu_saveChanges.Enabled = true;\r
\r
treeView_presets.Select();\r
}\r
\r
// Presets Management\r
- private void btn_addPreset_Click(object sender, EventArgs e)\r
+\r
+ private void BtnAddPreset_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
- private void btn_removePreset_Click(object sender, EventArgs e)\r
+ private void BtnRemovePreset_Click(object sender, EventArgs e)\r
{\r
DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset",\r
MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
{\r
if (treeView_presets.SelectedNode != null)\r
{\r
- presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
+ presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);\r
treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
}\r
}\r
treeView_presets.Select();\r
}\r
\r
- private void btn_setDefault_Click(object sender, EventArgs e)\r
+\r
+ private void MnuSetDefaultPreset_Click(object sender, EventArgs e)\r
{\r
if (treeView_presets.SelectedNode != null)\r
{\r
MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
\r
+ private void MnuImportPreset_Click(object sender, EventArgs e)\r
+ {\r
+ this.ImportPreset();\r
+ }\r
+\r
+ private void MnuExportPreset_Click(object sender, EventArgs e)\r
+ {\r
+ this.ExportPreset();\r
+ }\r
+\r
+ private void MnuResetBuiltInPresets_Click(object sender, EventArgs e)\r
+ {\r
+ presetHandler.UpdateBuiltInPresets(string.Empty);\r
+ LoadPresetPanel();\r
+ if (treeView_presets.Nodes.Count == 0)\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
+ /// 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
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
+ /// When the mouse moves, display a preset\r
+ /// </summary>\r
+ /// <param name="sender">The Sender</param>\r
+ /// <param name="e">the MouseEventArgs</param>\r
+ private void TreeViewPresetsMouseMove(object sender, MouseEventArgs e)\r
+ {\r
+ TreeNode theNode = this.treeView_presets.GetNodeAt(e.X, e.Y);\r
+\r
+ if ((theNode != null))\r
+ {\r
+ // Change the ToolTip only if the pointer moved to a new node.\r
+ if (theNode.ToolTipText != this.ToolTip.GetToolTip(this.treeView_presets))\r
+ {\r
+ this.ToolTip.SetToolTip(this.treeView_presets, theNode.ToolTipText);\r
+ }\r
+ }\r
+ else // Pointer is not over a node so clear the ToolTip.\r
+ {\r
+ this.ToolTip.SetToolTip(this.treeView_presets, string.Empty);\r
+ }\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
if (result == DialogResult.Yes)\r
{\r
if (treeView_presets.SelectedNode != null)\r
- presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
+ presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);\r
\r
// Remember each nodes expanded status so we can reload it\r
List<bool> nodeStatus = new List<bool>();\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
if (preset != null)\r
{\r
string query = presetHandler.GetPreset(presetName).Query;\r
- bool loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
\r
if (query != null)\r
{\r
x264Panel.Reset2Defaults();\r
\r
// Send the query from the file to the Query Parser class\r
- QueryParser presetQuery = QueryParser.Parse(query);\r
+ EncodeTask presetQuery = QueryParserUtility.Parse(query);\r
\r
// Now load the preset\r
- PresetLoader.LoadPreset(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
- CurrentlySelectedPreset = preset;\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
+ /// <summary>\r
+ /// Import a plist preset\r
+ /// </summary>\r
private void ImportPreset()\r
{\r
if (openPreset.ShowDialog() == DialogResult.OK)\r
{\r
- QueryParser parsed = PlistPresetHandler.Import(openPreset.FileName);\r
- if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
+ EncodeTask parsed = PlistPresetHandler.Import(openPreset.FileName);\r
+ if (presetHandler.CheckIfPresetExists(parsed.PresetName + " (Imported)"))\r
{\r
DialogResult result =\r
MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?",\r
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
{\r
- PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Update(parsed.PresetName + " (Imported)",\r
- QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),\r
- parsed.UsesPictureSettings);\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
+\r
+ Preset preset = new Preset\r
+ {\r
+ Name = parsed.PresetName + " (Imported)",\r
+ Query = QueryGenerator.GenerateFullQuery(this),\r
+ CropSettings = parsed.UsesPictureSettings\r
+ };\r
+\r
+ presetHandler.Update(preset);\r
}\r
}\r
else\r
{\r
- PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- if (presetHandler.Add(parsed.PresetName + " (Imported)",\r
- QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),\r
- parsed.UsesPictureSettings))\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
+\r
+ Preset preset = new Preset\r
+ {\r
+ Name = parsed.PresetName + " (Imported)",\r
+ Query = QueryGenerator.GenerateFullQuery(this),\r
+ CropSettings = parsed.UsesPictureSettings\r
+ };\r
+\r
+ if (presetHandler.Add(preset))\r
{\r
TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)")\r
{\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Export a plist Preset\r
+ /// </summary>\r
+ private void ExportPreset()\r
+ {\r
+ SaveFileDialog savefiledialog = new SaveFileDialog { Filter = "plist|*.plist" };\r
+\r
+ if (treeView_presets.SelectedNode != null)\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
// Remove old Drive Menu Items.\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;\r
- if (Properties.Settings.Default.enocdeStatusInGui &&\r
- !Properties.Settings.Default.showCliForInGuiEncodeStatus)\r
- {\r
- result = MessageBox.Show(\r
- "Are you sure you wish to cancel the encode?\n\nPlease note, when 'Enable in-GUI encode status' is enabled, stopping this encode will render the file unplayable. ",\r
- "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
- }\r
- else\r
- {\r
- result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?",\r
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
- }\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.Pause();\r
+ this.queueProcessor.Pause();\r
\r
- if (Properties.Settings.Default.enocdeStatusInGui &&\r
- !Properties.Settings.Default.showCliForInGuiEncodeStatus)\r
- {\r
- encodeQueue.Stop();\r
- if (encodeQueue.HbProcess != null)\r
- encodeQueue.HbProcess.WaitForExit();\r
- }\r
+ if (Settings.Default.showCliForInGuiEncodeStatus)\r
+ this.queueProcessor.EncodeService.SafelyStop();\r
else\r
- {\r
- encodeQueue.SafelyClose();\r
- }\r
-\r
- // Update the GUI\r
- SetEncodeFinished();\r
+ this.queueProcessor.EncodeService.Stop();\r
}\r
}\r
else\r
{\r
- if (encodeQueue.Count != 0 ||\r
- (!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 (this.queueProcessor.QueueManager.Count != 0 || (!string.IsNullOrEmpty(jobSourcePath) && !string.IsNullOrEmpty(jobDestination)))\r
{\r
- string generatedQuery = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ string generatedQuery = QueryGenerator.GenerateFullQuery(this);\r
string specifiedQuery = rtf_query.Text != string.Empty\r
? rtf_query.Text\r
- : QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ : QueryGenerator.GenerateFullQuery(this);\r
string query = string.Empty;\r
\r
// Check to make sure the generated query matches the GUI settings\r
}\r
\r
DialogResult overwrite = DialogResult.Yes;\r
- if (text_destination.Text != string.Empty)\r
- if (File.Exists(text_destination.Text))\r
- overwrite =\r
- MessageBox.Show(\r
- "The destination file already exists. Are you sure you want to overwrite it?",\r
- "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.Add(query, getTitle(), sourcePath, text_destination.Text, (rtf_query.Text != string.Empty));\r
+ QueueTask task = new QueueTask(query)\r
+ {\r
+ Title = this.GetTitle(),\r
+ Source = jobSourcePath,\r
+ Destination = jobDestination,\r
+ CustomQuery = (this.rtf_query.Text != string.Empty)\r
+ };\r
+\r
+ if (this.queueProcessor.QueueManager.Count == 0)\r
+ this.queueProcessor.QueueManager.Add(task);\r
\r
queueWindow.SetQueue();\r
- if (encodeQueue.Count > 1)\r
+ if (this.queueProcessor.QueueManager.Count > 1)\r
queueWindow.Show(false);\r
\r
SetEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
- encodeQueue.Start(); // Start The Queue Encoding Process\r
- lastAction = ActivityLogMode.Encode; // Set the last action to encode - Used for activity window.\r
+ this.queueProcessor.Start(); // Start The Queue Encoding Process\r
}\r
- if (ActivityWindow != null)\r
- ActivityWindow.SetMode(ActivityLogMode.Encode);\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,\r
- MessageBoxIcon.Warning);\r
+ else if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\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
+ // Add the item to the queue.\r
+ AddItemToQueue(true);\r
+ queueWindow.Show();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add Multiple Items to the Queue at once.\r
+ /// </summary>\r
+ /// <param name="sender">The Sender</param>\r
+ /// <param name="e">The EventArgs</param>\r
+ private void MnuAddMultiToQueueClick(object sender, EventArgs e)\r
+ {\r
+ if (!Settings.Default.autoNaming)\r
+ {\r
+ MessageBox.Show("Destination Auto Naming must be enabled in preferences for this feature to work.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+\r
+ if (this.SourceScan.SouceData == null)\r
+ {\r
+ MessageBox.Show("You must first scan a source or collection of source to use this feature.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+\r
+ BatchAdd batchAdd = new BatchAdd();\r
+ if (batchAdd.ShowDialog() == DialogResult.OK)\r
+ {\r
+ int min = batchAdd.Min;\r
+ int max = batchAdd.Max;\r
+ bool errors = false;\r
+\r
+ foreach (Title title in this.SourceScan.SouceData.Titles)\r
+ {\r
+ if (title.Duration.TotalMinutes > min && title.Duration.TotalMinutes < max)\r
+ {\r
+ // Add to Queue\r
+ this.drp_dvdtitle.SelectedItem = title;\r
+\r
+ if (!this.AddItemToQueue(false))\r
+ {\r
+ errors = true;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (errors)\r
+ {\r
+ MessageBox.Show(\r
+ "One or more items could not be added to the queue. You should check your queue and manually add any missing jobs.",\r
+ "Warning",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Warning);\r
+ }\r
}\r
}\r
\r
- private void btn_add2Queue_Click(object sender, EventArgs e)\r
+ private bool AddItemToQueue(bool showError)\r
{\r
- if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
- MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK,\r
- MessageBoxIcon.Warning);\r
- else\r
+ string query = QueryGenerator.GenerateFullQuery(this);\r
+ if (!string.IsNullOrEmpty(rtf_query.Text))\r
+ query = rtf_query.Text;\r
+\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
+ // Make sure we have a Source and Destination.\r
+ if (string.IsNullOrEmpty(jobSourcePath) || string.IsNullOrEmpty(jobDestination))\r
+ {\r
+ if (showError)\r
+ MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return false;\r
+ }\r
+\r
+ // Make sure the destination path exists.\r
+ if (!Directory.Exists(Path.GetDirectoryName(jobDestination)))\r
{\r
- string query = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
- if (rtf_query.Text != string.Empty)\r
- query = rtf_query.Text;\r
+ if (showError)\r
+ MessageBox.Show(string.Format("Destination Path does not exist.\nPath: {0}\n\nThis item was not added to the Queue.", Path.GetDirectoryName(jobDestination)), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return false;\r
+ }\r
\r
- if (encodeQueue.CheckForDestinationDuplicate(text_destination.Text))\r
+ // Make sure we don't have a duplciate on the queue.\r
+ if (this.queueProcessor.QueueManager.CheckForDestinationPathDuplicates(jobDestination))\r
+ {\r
+ if (showError)\r
{\r
- DialogResult result =\r
+ DialogResult result;\r
+ 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, getTitle(), sourcePath, text_destination.Text, (rtf_query.Text != string.Empty));\r
+ string.Format(\r
+ "There is already a queue item for this destination path.\nDestination Path: {0} \n\nIf you continue, the encode will be overwritten. Do you wish to continue?",\r
+ jobDestination),\r
+ "Warning",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Warning);\r
+\r
+ if (result != DialogResult.Yes) return false;\r
}\r
else\r
- encodeQueue.Add(query, getTitle(), sourcePath, text_destination.Text, (rtf_query.Text != string.Empty));\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ // Add the job.\r
+ QueueTask task = new QueueTask(query)\r
+ {\r
+ Title = this.GetTitle(),\r
+ Source = jobSourcePath,\r
+ Destination = jobDestination,\r
+ CustomQuery = (this.rtf_query.Text != string.Empty)\r
+ };\r
+ this.queueProcessor.QueueManager.Add(task);\r
\r
- lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
+ lbl_encode.Text = this.queueProcessor.QueueManager.Count + " encode(s) pending in the queue";\r
\r
- queueWindow.Show();\r
- }\r
+ return true;\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
}\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, encodeQueue, SourceScan);\r
- else\r
- switch (lastAction)\r
- {\r
- case ActivityLogMode.Scan:\r
- ActivityWindow.SetMode(ActivityLogMode.Scan);\r
- break;\r
- case ActivityLogMode.Encode:\r
- ActivityWindow.SetMode(ActivityLogMode.Encode);\r
- break;\r
- default:\r
- ActivityWindow.SetMode(ActivityLogMode.Encode);\r
- break;\r
- }\r
+ if (this.activityWindow == null || !this.activityWindow.IsHandleCreated)\r
+ this.activityWindow = new frmActivityWindow(this.queueProcessor.EncodeService, 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
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
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.Activate();\r
this.WindowState = FormWindowState.Normal;\r
notifyIcon.Visible = false;\r
-\r
- this.StartScan(null, 2);\r
}\r
\r
#endregion\r
\r
- #region Tab Control\r
+ #region Main Window and Tab Control\r
\r
// Source\r
- private void btn_dvd_source_Click(object sender, EventArgs e)\r
+ private void BtnFolderScanClicked(object sender, EventArgs e)\r
{\r
+ this.btn_source.HideDropDown();\r
if (DVD_Open.ShowDialog() == DialogResult.OK)\r
{\r
this.selectedSourceType = SourceType.Folder;\r
- SelectSource(DVD_Open.SelectedPath);\r
+ SelectSource(DVD_Open.SelectedPath, 0);\r
}\r
else\r
UpdateSourceLabel();\r
}\r
\r
- private void btn_file_source_Click(object sender, EventArgs e)\r
+ private void BtnFileScanClicked(object sender, EventArgs e)\r
{\r
+ this.btn_source.HideDropDown();\r
if (ISO_Open.ShowDialog() == DialogResult.OK)\r
{\r
this.selectedSourceType = SourceType.VideoFile;\r
- SelectSource(ISO_Open.FileName);\r
+ SelectSource(ISO_Open.FileName, 0);\r
}\r
else\r
UpdateSourceLabel();\r
}\r
\r
- private void mnu_dvd_drive_Click(object sender, EventArgs e)\r
+ private void MnuDvdDriveClick(object sender, EventArgs e)\r
{\r
ToolStripMenuItem item = sender as ToolStripMenuItem;\r
if (item != null)\r
int id;\r
if (int.TryParse(driveId, out id))\r
{\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
+ SelectSource(this.dvdDrivePath, 0);\r
+ }\r
+ }\r
+ }\r
+\r
+ private void VideoTitleSpecificScanClick(object sender, EventArgs e)\r
+ {\r
+ this.btn_source.HideDropDown();\r
+ if (ISO_Open.ShowDialog() == DialogResult.OK)\r
+ {\r
+ this.selectedSourceType = SourceType.VideoFile;\r
+\r
+ int sourceTitle = 0;\r
+ TitleSpecificScan title = new TitleSpecificScan();\r
+ if (title.ShowDialog() == DialogResult.OK)\r
+ {\r
+ sourceTitle = title.Title;\r
+ SelectSource(ISO_Open.FileName, sourceTitle);\r
+ }\r
+ }\r
+ else\r
+ UpdateSourceLabel();\r
+ }\r
+\r
+ private void FolderTitleSpecificScanClick(object sender, EventArgs e)\r
+ {\r
+ this.btn_source.HideDropDown();\r
+ if (DVD_Open.ShowDialog() == DialogResult.OK)\r
+ {\r
+ this.selectedSourceType = SourceType.Folder;\r
+\r
+ int sourceTitle = 0;\r
+ TitleSpecificScan title = new TitleSpecificScan();\r
+ if (title.ShowDialog() == DialogResult.OK)\r
+ {\r
+ sourceTitle = title.Title;\r
+ SelectSource(DVD_Open.SelectedPath, sourceTitle);\r
}\r
}\r
+ else\r
+ UpdateSourceLabel();\r
}\r
\r
- private void SelectSource(string file)\r
+ private void SelectSource(string file, int titleSpecific)\r
{\r
Check_ChapterMarkers.Enabled = true;\r
- lastAction = ActivityLogMode.Scan;\r
sourcePath = string.Empty;\r
\r
if (file == string.Empty) // Must have a file or path\r
}\r
\r
sourcePath = Path.GetFileName(file);\r
- StartScan(file, 0);\r
+ StartScan(file, titleSpecific);\r
}\r
\r
private void drp_dvdtitle_Click(object sender, EventArgs e)\r
{\r
selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
lbl_duration.Text = selectedTitle.Duration.ToString();\r
- PictureSettings.CurrentlySelectedPreset = CurrentlySelectedPreset;\r
+ PictureSettings.CurrentlySelectedPreset = this.currentlySelectedPreset;\r
PictureSettings.Source = selectedTitle; // Setup Picture Settings Tab Control\r
\r
// Populate the Angles dropdown\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
+ {\r
+ drop_angle.Visible = false;\r
+ lbl_angle.Visible = false;\r
+ }\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, CurrentlySelectedPreset);\r
+ AudioSettings.SetTrackListFromPreset(selectedTitle, this.currentlySelectedPreset);\r
\r
// Populate the Subtitles dropdown\r
Subtitles.SetSubtitleTrackAuto(selectedTitle.Subtitles.ToArray());\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
+ labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
\r
// Run the AutoName & ChapterNaming functions\r
if (Properties.Settings.Default.autoNaming)\r
text_destination.Text = autoPath;\r
else\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
+ "You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a valid 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(selectedTitle, data_chpt, drop_chapterFinish.Text);\r
if (chapterGridView != null)\r
data_chpt = chapterGridView;\r
}\r
switch (DVD_Save.FilterIndex)\r
{\r
case 1:\r
- if (\r
- !Path.GetExtension(DVD_Save.FileName).Equals(".mp4",\r
- StringComparison.InvariantCultureIgnoreCase))\r
- if (Properties.Settings.Default.useM4v)\r
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".mp4", StringComparison.InvariantCultureIgnoreCase))\r
+ if (Properties.Settings.Default.useM4v == 2 || Properties.Settings.Default.useM4v == 0)\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
+ 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
switch (drop_format.SelectedIndex)\r
{\r
case 0:\r
- if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked ||\r
- AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
- SetExtension(".m4v");\r
- else\r
- SetExtension(".mp4");\r
+ SetExtension(".mp4");\r
break;\r
case 1:\r
SetExtension(".mkv");\r
}\r
\r
AudioSettings.SetContainer(drop_format.Text);\r
- Subtitles.SetContainer(drop_format.SelectedIndex);\r
\r
if (drop_format.Text.Contains("MP4"))\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() ||\r
- Subtitles.RequiresM4V())\r
- newExtension = ".m4v";\r
+ if (Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V() || Properties.Settings.Default.useM4v == 2) \r
+ newExtension = Properties.Settings.Default.useM4v == 1 ? ".mp4" : ".m4v";\r
else\r
newExtension = ".mp4";\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
public void setContainerOpts()\r
}\r
}\r
\r
- private double _cachedCqStep = Properties.Settings.Default.x264cqstep;\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
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
}\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
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
+ this.lbl_rfwarn.Visible = rfValue == 0;\r
break;\r
case "VP3 (Theora)":\r
lbl_SliderValue.Text = "QP:" + slider_videoQuality.Value;\r
}\r
}\r
\r
- private void radio_targetFilesize_CheckedChanged(object sender, EventArgs e)\r
- {\r
- text_bitrate.Enabled = false;\r
- text_filesize.Enabled = true;\r
- slider_videoQuality.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
- text_filesize.Enabled = false;\r
slider_videoQuality.Enabled = false;\r
\r
check_2PassEncode.Enabled = true;\r
private void radio_cq_CheckedChanged(object sender, EventArgs e)\r
{\r
text_bitrate.Enabled = false;\r
- text_filesize.Enabled = false;\r
slider_videoQuality.Enabled = true;\r
\r
check_2PassEncode.Enabled = false;\r
}\r
else\r
{\r
- if (drop_format.SelectedIndex != 1 && !Properties.Settings.Default.useM4v)\r
+ if (drop_format.SelectedIndex != 1)\r
SetExtension(".mp4");\r
data_chpt.Enabled = false;\r
btn_importChapters.Enabled = false;\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(selectedTitle, 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 = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ rtf_query.Text = QueryGenerator.GenerateFullQuery(this);\r
}\r
\r
private void btn_clear_Click(object sender, EventArgs e)\r
\r
#region Source Scan\r
\r
- public bool isScanning { get; set; }\r
-\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
\r
this.DisableGUI();\r
\r
- if (ActivityWindow != null)\r
- ActivityWindow.SetMode(ActivityLogMode.Scan);\r
-\r
// Start the Scan\r
try\r
{\r
- isScanning = true;\r
- SourceScan = new Scan();\r
- SourceScan.ScanSource(sourcePath, title);\r
- SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);\r
- SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);\r
+ SourceScan.Scan(sourcePath, title);\r
}\r
catch (Exception exc)\r
{\r
}\r
}\r
\r
- private void SourceScan_ScanStatusChanged(object sender, EventArgs e)\r
- {\r
- UpdateScanStatusLabel();\r
- }\r
-\r
- private void SourceScan_ScanCompleted(object sender, EventArgs e)\r
- {\r
- UpdateGuiAfterScan();\r
- }\r
-\r
- private void UpdateScanStatusLabel()\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 SourceScanScanStatusChanged(object sender, ScanProgressEventArgs e)\r
{\r
- if (InvokeRequired)\r
+ if (this.InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(UpdateScanStatusLabel));\r
+ this.BeginInvoke(new ScanProgessStatus(this.SourceScanScanStatusChanged), new[] { sender, e });\r
return;\r
}\r
- lbl_encode.Text = SourceScan.ScanStatus();\r
+\r
+ labelSource.Text = string.Format("Processing Title: {0} of {1}", e.CurrentTitle, e.Titles);\r
}\r
\r
- private void UpdateGuiAfterScan()\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 SourceScanScanCompleted(object sender, EventArgs e)\r
{\r
- if (InvokeRequired)\r
+ if (this.InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(UpdateGuiAfterScan));\r
+ this.BeginInvoke(new ScanCompletedStatus(this.SourceScanScanCompleted), new[] { sender, e });\r
return;\r
}\r
\r
try\r
{\r
- currentSource = SourceScan.SouceData();\r
+ currentSource = SourceScan.SouceData;\r
\r
// Setup some GUI components\r
drp_dvdtitle.Items.Clear();\r
drp_dvdtitle.SelectedIndex = 0;\r
}\r
\r
- // Enable the creation of chapter markers if the file is an image of a dvd.\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)\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
UpdateSourceLabel();\r
\r
+ // This is a bit of a hack to fix the queue editing.\r
+ // If afte the scan, we find a job sitting in queueEdit, then the user has rescaned the source from the queue by clicking edit.\r
+ // When this occures, we want to repopulate their old settings.\r
+ if (queueEdit != null)\r
+ {\r
+ // Setup UI\r
+ if (queueEdit.Query != null)\r
+ {\r
+ // Send the query from the file to the Query Parser class\r
+ EncodeTask presetQuery = QueryParserUtility.Parse(queueEdit.Query);\r
+\r
+ // Now load the preset\r
+ PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue");\r
+\r
+ // Set the destination path\r
+ this.text_destination.Text = queueEdit.Destination;\r
+\r
+ // The x264 widgets will need updated, so do this now:\r
+ x264Panel.StandardizeOptString();\r
+ x264Panel.SetCurrentSettingsInPanel();\r
+\r
+ // Set the crop label\r
+ PictureSettings.SetPresetCropWarningLabel(null);\r
+ }\r
+\r
+ queueEdit = null;\r
+ }\r
+\r
// Enable the GUI components and enable any disabled components\r
EnableGUI();\r
}\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Enable the GUI\r
+ /// </summary>\r
private void EnableGUI()\r
{\r
try\r
{\r
if (InvokeRequired)\r
BeginInvoke(new UpdateWindowHandler(EnableGUI));\r
- lbl_encode.Text = "Scan Completed";\r
foreach (Control ctrl in Controls)\r
ctrl.Enabled = true;\r
btn_start.Enabled = true;\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
+ labelSource.Enabled = true;\r
+ labelStaticSource.Enabled = true;\r
+ SourceLayoutPanel.Enabled = true;\r
btn_source.Enabled = false;\r
btn_start.Enabled = false;\r
btn_showQueue.Enabled = false;\r
mnu_killCLI.Visible = true;\r
}\r
\r
+ /// <summary>\r
+ /// Kill the Scan\r
+ /// </summary>\r
private void KillScan()\r
{\r
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
+ SourceScan.ScanCompleted -= this.SourceScanScanCompleted;\r
EnableGUI();\r
ResetGUI();\r
\r
- SourceScan.KillScan();\r
+ SourceScan.Stop();\r
\r
- lbl_encode.Text = "Scan Cancelled!";\r
+ labelSource.Text = "Scan Cancelled";\r
}\r
\r
+ /// <summary>\r
+ /// Reset the GUI\r
+ /// </summary>\r
private void ResetGUI()\r
{\r
drp_dvdtitle.Items.Clear();\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))\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
- public void RecievingJob(Job job)\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(QueueTask 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", true);\r
-\r
- // The x264 widgets will need updated, so do this now:\r
- x264Panel.X264_StandardizeOptString();\r
- x264Panel.X264_SetCurrentSettingsInPanel();\r
+ // Reset\r
+ this.currentlySelectedPreset = null;\r
+ x264Panel.Reset2Defaults();\r
\r
- // Finally, let this window have a copy of the preset settings.\r
- CurrentlySelectedPreset = null;\r
- PictureSettings.SetPresetCropWarningLabel(null);\r
- }\r
+ // Scan\r
+ queueEdit = job; // Nasty but will do for now. TODO\r
+ StartScan(job.Source, job.Title);\r
}\r
\r
#endregion\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
BeginInvoke(new UpdateWindowHandler(SetEncodeStarted));\r
return;\r
}\r
-\r
lbl_encode.Visible = true;\r
- lbl_encode.Text = "Encoding with " + encodeQueue.Count + " encode(s) pending";\r
+ ProgressBarStatus.Value = 0;\r
+ ProgressBarStatus.Visible = true;\r
+ lbl_encode.Text = "Encoding with " + this.queueProcessor.QueueManager.Count + " encode(s) pending";\r
btn_start.Text = "Stop";\r
btn_start.ToolTipText = "Stop the encoding process.";\r
btn_start.Image = Properties.Resources.stop;\r
}\r
\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, EncodeProgressEventArgs e)\r
+ {\r
+ if (this.InvokeRequired)\r
+ {\r
+ this.BeginInvoke(new 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
+ this.queueProcessor.QueueManager.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
return;\r
}\r
\r
- drives = Main.GetDrives();\r
+ drives = UtilityService.GetDrives();\r
\r
List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();\r
foreach (DriveInformation drive in drives)\r
{\r
- ToolStripMenuItem menuItem = new ToolStripMenuItem();\r
- menuItem.Name = drive.ToString();\r
- menuItem.Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")";\r
- menuItem.Image = Resources.disc_small;\r
- menuItem.Click += new EventHandler(mnu_dvd_drive_Click);\r
+ ToolStripMenuItem menuItem = new ToolStripMenuItem\r
+ {\r
+ Name = drive.ToString(),\r
+ Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")",\r
+ Image = Resources.disc_small\r
+ };\r
+ menuItem.Click += new EventHandler(MnuDvdDriveClick);\r
menuItems.Add(menuItem);\r
}\r
\r
private void LoadPresetPanel()\r
{\r
if (presetHandler.CheckIfPresetsAreOutOfDate())\r
- if (!Properties.Settings.Default.presetNotification)\r
- MessageBox.Show(splash,\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
+ // Clear the old presets\r
+ treeView_presets.Nodes.Clear();\r
+\r
+\r
+ string category = string.Empty; // The category we are currnetly processing\r
+ TreeNode rootNode = null;\r
+ foreach (Preset preset in this.presetHandler.Presets.Where(p => p.IsBuildIn))\r
+ {\r
+ // If the category of this preset doesn't match the current category we are processing\r
+ // Then we need to create a new root node.\r
+ if (preset.Category != category)\r
+ {\r
+ rootNode = new TreeNode(preset.Category) { ForeColor = Color.DarkBlue };\r
+ treeView_presets.Nodes.Add(rootNode);\r
+ category = preset.Category;\r
+ }\r
+\r
+ if (preset.Category == category && rootNode != null)\r
+ rootNode.Nodes.Add(new TreeNode(preset.Name) { ToolTipText = preset.Description, ForeColor = Color.DarkBlue });\r
+ }\r
+\r
+ rootNode = null;\r
+ category = null;\r
+ foreach (Preset preset in this.presetHandler.Presets.Where(p => !p.IsBuildIn)) // User Presets\r
+ {\r
+ if (preset.Category != category && preset.Category != string.Empty)\r
+ {\r
+ rootNode = new TreeNode(preset.Category) { ForeColor = Color.Black };\r
+ treeView_presets.Nodes.Add(rootNode);\r
+ category = preset.Category;\r
+ }\r
+\r
+ if (preset.Category == category && rootNode != null)\r
+ rootNode.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description });\r
+ else\r
+ treeView_presets.Nodes.Add(new TreeNode(preset.Name) { ForeColor = Color.Black, ToolTipText = preset.Description });\r
+ }\r
+\r
treeView_presets.Update();\r
}\r
\r
/// <returns>\r
/// The title.\r
/// </returns>\r
- private int getTitle()\r
+ private int GetTitle()\r
{\r
int title = 0;\r
if (drp_dvdtitle.SelectedItem != null)\r
return title;\r
}\r
\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
+ // Get the information about the new build, if any, and close the window\r
+ info = UpdateService.EndCheckForUpdates(result);\r
+\r
+ if (info.NewVersionAvailable && info.BuildInformation != null)\r
+ {\r
+ UpdateInfo updateWindow = new UpdateInfo(info.BuildInformation, Settings.Default.hb_version, Settings.Default.hb_build.ToString());\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 ex)\r
+ {\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
+\r
#endregion\r
\r
#region Overrides\r
return true;\r
}\r
\r
- if (keyData == (Keys.Control | Keys.A))\r
+ if (keyData == (Keys.Control | Keys.Shift | Keys.A))\r
{\r
btn_add2Queue_Click(this, new EventArgs());\r
return true;\r
/// <param name="e">FormClosingEventArgs</param>\r
protected override void OnFormClosing(FormClosingEventArgs e)\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
+ try\r
{\r
- DialogResult result =\r
- MessageBox.Show(\r
- "HandBrake has queue items to process. Closing HandBrake will stop the current encoding.\n\nDo you want to close HandBrake?",\r
- "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-\r
- if (result == DialogResult.No)\r
- e.Cancel = true;\r
-\r
- // Try to safely close out if we can, or kill the cli if using in-gui status\r
- if (Settings.Default.enocdeStatusInGui)\r
- encodeQueue.Stop();\r
- else\r
- encodeQueue.SafelyClose();\r
- }\r
+ // If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
+ if (this.queueProcessor.EncodeService.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 (SourceScan.IsScanning)\r
- {\r
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
- SourceScan.KillScan();\r
- }\r
- base.OnFormClosing(e);\r
- }\r
+ if (result == DialogResult.No)\r
+ {\r
+ e.Cancel = true;\r
+ return;\r
+ }\r
\r
- #endregion\r
+ this.queueProcessor.Pause();\r
+ this.queueProcessor.EncodeService.Stop();\r
+ }\r
\r
- #region In-GUI Encode Status (Experimental)\r
+ if (SourceScan.IsScanning)\r
+ {\r
+ SourceScan.Stop();\r
+ }\r
\r
- /// <summary>\r
- /// Starts a new thread to monitor and process the CLI encode status\r
- /// </summary>\r
- private void EncodeMonitorThread()\r
- {\r
- try\r
- {\r
- Parser encode = new Parser(encodeQueue.HbProcess.StandardOutput.BaseStream);\r
- encode.OnEncodeProgress += EncodeOnEncodeProgress;\r
- while (!encode.EndOfStream)\r
- encode.ReadEncodeStatus();\r
+ SourceScan.ScanCompleted -= this.SourceScanScanCompleted;\r
+ SourceScan.ScanStatusChanged -= this.SourceScanScanStatusChanged;\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\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
- }\r
-\r
- /// <summary>\r
- /// Displays the Encode status in the GUI\r
- /// </summary>\r
- /// <param name="Sender"></param>\r
- /// <param name="CurrentTask"></param>\r
- /// <param name="TaskCount"></param>\r
- /// <param name="PercentComplete"></param>\r
- /// <param name="CurrentFps"></param>\r
- /// <param name="AverageFps"></param>\r
- /// <param name="TimeRemaining"></param>\r
- private void EncodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
- {\r
- if (this.InvokeRequired)\r
+ finally\r
{\r
- this.BeginInvoke(\r
- new EncodeProgressEventHandler(EncodeOnEncodeProgress),\r
- new[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
- return;\r
+ base.OnFormClosing(e);\r
}\r
- lbl_encode.Text =\r
- string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);\r
}\r
\r
#endregion\r