From 1d1cd92bb0a5a4af27be7e67561b96129421aa8a Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 2 Sep 2011 22:40:19 +0000 Subject: WinGui: Initial support for batch queueing. A new option "Add All" which will add all scanned titles using the current settings. Ideally used with batch scanned sources. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4202 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/frmMain.cs | 115 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 21 deletions(-) (limited to 'win/CS/frmMain.cs') diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index efe741522..05515983c 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -14,6 +14,7 @@ namespace Handbrake using System.IO; using System.Linq; using System.Threading; + using System.Windows; using System.Windows.Forms; using Functions; @@ -36,7 +37,12 @@ namespace Handbrake using Properties; + using Application = System.Windows.Forms.Application; + using DataFormats = System.Windows.Forms.DataFormats; + using DragDropEffects = System.Windows.Forms.DragDropEffects; + using DragEventArgs = System.Windows.Forms.DragEventArgs; using Main = Handbrake.Functions.Main; + using MessageBox = System.Windows.Forms.MessageBox; /// /// The Main Window @@ -1074,35 +1080,102 @@ namespace Handbrake queueWindow.Show(); } + /// + /// Add All Scanned Titles + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// + private void mnu_AddAllTitles_Click(object sender, EventArgs e) + { + AddRangeOfTitles(false); + } + + /// + /// Add a range of scanned titles + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// + private void mnu_AddTittleRange_Click(object sender, EventArgs e) + { + AddRangeOfTitles(true); + } + /// /// Add Multiple Items to the Queue at once. /// - /// The Sender - /// The EventArgs - private void MnuAddMultiToQueueClick(object sender, EventArgs e) + /// + /// The add Range. + /// + private void AddRangeOfTitles(bool addRange) { if (!this.userSettingService.GetUserSetting(UserSettingConstants.AutoNaming)) { - MessageBox.Show("Destination Auto Naming must be enabled in preferences for this feature to work.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show( + "You need to enable 'Auto Naming' in options to use this feature.", + "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); return; } if (this.SourceScan.SouceData == null) { - MessageBox.Show("You must first scan a source or collection of source to use this feature.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show( + "You must first scan a source before you can use this feature. Select the 'Source' button on the toolbar.", + "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); return; } - BatchAdd batchAdd = new BatchAdd(); - if (batchAdd.ShowDialog() == DialogResult.OK) + bool errors = false; + if (addRange) // Add Range { - int min = batchAdd.Min; - int max = batchAdd.Max; - bool errors = false; + BatchAdd batchAdd = new BatchAdd(this.SourceScan.SouceData); + if (batchAdd.ShowDialog() == DialogResult.OK) + { + TimeSpan min = batchAdd.Min; + TimeSpan max = batchAdd.Max; + + foreach (Title title in this.SourceScan.SouceData.Titles) + { + if (title.Duration.TotalSeconds > min.TotalSeconds && title.Duration.TotalSeconds < max.TotalSeconds) + { + // Add to Queue + this.drp_dvdtitle.SelectedItem = title; - foreach (Title title in this.SourceScan.SouceData.Titles) + if (!this.AddItemToQueue(false)) + { + errors = true; + } + } + } + } + } + else // Add All + { + + string warning = string.Format( + "You are about to add *ALL* titles to the queue. \nCurrent settings will be applied to *ALL {0} Titles*. \n\nAre you sure you want to do this?", this.SourceScan.SouceData.Titles.Count); + + DialogResult question = + MessageBox.Show( + warning, + "Warning", + MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Warning); + + if (question == DialogResult.Yes) { - if (title.Duration.TotalMinutes > min && title.Duration.TotalMinutes < max) + foreach (Title title in this.SourceScan.SouceData.Titles) { // Add to Queue this.drp_dvdtitle.SelectedItem = title; @@ -1113,16 +1186,17 @@ namespace Handbrake } } } + } - if (errors) - { - MessageBox.Show( - "One or more items could not be added to the queue. You should check your queue and manually add any missing jobs.", - "Warning", - MessageBoxButtons.OK, - MessageBoxIcon.Warning); - } + if (errors) + { + MessageBox.Show( + "One or more items could not be added to the queue. You should check your queue and manually add any missing jobs.", + "Warning", + MessageBoxButtons.OK, + MessageBoxIcon.Warning); } + } private bool AddItemToQueue(bool showError) @@ -2591,7 +2665,6 @@ namespace Handbrake #endregion - // This is the END of the road **************************************** } } \ No newline at end of file -- cgit v1.2.3