using System.Drawing;\r
using System.Globalization;\r
using System.IO;\r
- using System.Reflection;\r
using System.Threading;\r
using System.Windows.Forms;\r
using Functions;\r
\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 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
private frmQueue queueWindow;\r
private frmPreview qtpreview;\r
private frmActivityWindow activityWindow;\r
- private frmSplashScreen splash = new frmSplashScreen();\r
\r
// Globals: Mainly used for tracking. *********************************\r
public Title selectedTitle;\r
return this.dvdDriveLabel;\r
}\r
\r
+ if (selectedTitle != null && !string.IsNullOrEmpty(selectedTitle.SourceName))\r
+ {\r
+ return Path.GetFileName(selectedTitle.SourceName);\r
+ }\r
+\r
if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
return Path.GetFileNameWithoutExtension(this.sourcePath);\r
\r
/// </param>\r
public frmMain(string[] args)\r
{\r
- // Load and setup the splash screen in this thread\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
-\r
InitializeComponent();\r
\r
// Update the users config file with the CLI version data.\r
- UpdateSplashStatus(lblStatus, "Checking CLI Version Data ...");\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
- UpdateSplashStatus(lblStatus, "Checking for updates ...");\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
- UpdateSplashStatus(lblStatus, "Clearing Old Log Files ..");\r
Thread clearLog = new Thread(Main.ClearOldLogs);\r
clearLog.Start();\r
}\r
\r
// Setup the GUI components\r
- UpdateSplashStatus(lblStatus, "Setting up the GUI ...");\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
+ 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 (Properties.Settings.Default.tooltipEnable)\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 && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
+ if (Settings.Default.defaultPreset != string.Empty && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
{\r
- string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query;\r
+ string query = presetHandler.GetPreset(Settings.Default.defaultPreset).Query;\r
if (query != null)\r
{\r
x264Panel.Reset2Defaults();\r
\r
QueryParser presetQuery = QueryParser.Parse(query);\r
- PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset);\r
+ PresetLoader.LoadPreset(this, presetQuery, Settings.Default.defaultPreset);\r
\r
x264Panel.StandardizeOptString();\r
x264Panel.SetCurrentSettingsInPanel();\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
- UpdateSplashStatus(lblStatus, "Loading Complete.");\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
}\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
}\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
- private void UpdateSplashStatus(Label status, string text)\r
- {\r
- status.Text = text;\r
- Application.DoEvents();\r
- }\r
-\r
#endregion\r
\r
#region Events\r
encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
\r
+ // Scan Started and Completed Events\r
+ SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);\r
+ SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);\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
/// </param>\r
private void mnu_encodeLog_Click(object sender, EventArgs e)\r
{\r
- frmActivityWindow dvdInfoWindow = new frmActivityWindow(encodeQueue, SourceScan);\r
- dvdInfoWindow.Show();\r
+ this.btn_ActivityWindow_Click(this, null);\r
}\r
\r
/// <summary>\r
private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
{\r
lbl_updateCheck.Visible = true;\r
- Main.BeginCheckForUpdates(new AsyncCallback(this.UpdateCheckDoneMenu), false);\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
/// <summary>\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
PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
if (presetHandler.Add(parsed.PresetName + " (Imported)",\r
QueryGenerator.GenerateFullQuery(this),\r
- parsed.UsesPictureSettings))\r
+ parsed.UsesPictureSettings, string.Empty))\r
{\r
TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)")\r
{\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
+ SaveFileDialog savefiledialog = new 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
{\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
\r
- if (Settings.Default.enocdeStatusInGui && !Settings.Default.showCliForInGuiEncodeStatus)\r
- {\r
- encodeQueue.Stop();\r
- }\r
- else\r
- {\r
+ if (Settings.Default.showCliForInGuiEncodeStatus)\r
encodeQueue.SafelyClose();\r
- }\r
+ else\r
+ encodeQueue.Stop();\r
}\r
}\r
else\r
/// </param>\r
private void btn_add2Queue_Click(object sender, EventArgs e)\r
{\r
- // Get the CLI query or use the query editor if it's not empty.\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 bool AddItemToQueue(bool showError)\r
+ {\r
string query = QueryGenerator.GenerateFullQuery(this);\r
if (!string.IsNullOrEmpty(rtf_query.Text))\r
query = 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
+ 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
- MessageBox.Show("Destination Path does not exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- return;\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
// 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
+ if (showError)\r
+ {\r
+ DialogResult result;\r
+ result =\r
+ MessageBox.Show(\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
+ {\r
+ return false;\r
+ }\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
+ // Add the job.\r
+ encodeQueue.Add(query, this.GetTitle(), jobSourcePath, jobDestination, (rtf_query.Text != string.Empty));\r
\r
- queueWindow.Show();\r
+ lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
\r
+ return true;\r
}\r
\r
/// <summary>\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
sourcePath = string.Empty;\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
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, this.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
}\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
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
try\r
{\r
SourceScan.Scan(sourcePath, title);\r
- SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged);\r
- SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted);\r
}\r
catch (Exception exc)\r
{\r
BeginInvoke(new UpdateWindowHandler(UpdateScanStatusLabel));\r
return;\r
}\r
- lbl_encode.Text = SourceScan.ScanStatus;\r
+ labelSource.Text = SourceScan.ScanStatus;\r
}\r
\r
/// <summary>\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
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
\r
SourceScan.Stop();\r
\r
- lbl_encode.Text = "Scan Cancelled!";\r
+ labelSource.Text = "Scan Cancelled";\r
}\r
\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
/// <summary>\r
\r
lbl_encode.Text =\r
string.Format(\r
- "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}",\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
+ e.EstimatedTimeLeft,\r
+ encodeQueue.Count);\r
\r
ProgressBarStatus.Value = (int)Math.Round(e.PercentComplete);\r
}\r
Text = drive.RootDirectory + " (" + drive.VolumeLabel + ")",\r
Image = Resources.disc_small\r
};\r
- menuItem.Click += new EventHandler(mnu_dvd_drive_Click);\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
try\r
{\r
// Get the information about the new build, if any, and close the window\r
- info = Main.EndCheckForUpdates(result);\r
+ info = UpdateService.EndCheckForUpdates(result);\r
\r
if (info.NewVersionAvailable && info.BuildInformation != null)\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
else\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
+ // 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
- e.Cancel = true;\r
- return;\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
- // 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
+ }\r
\r
- if (SourceScan.IsScanning)\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
- SourceScan.ScanCompleted -= new EventHandler(SourceScan_ScanCompleted);\r
- SourceScan.Stop();\r
+ base.OnFormClosing(e);\r
}\r
- base.OnFormClosing(e);\r
}\r
\r
#endregion\r