]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improvements and fixes to the Queue Window. Added WhenDone option. Fixed...
authorsr55 <sr55.hb@outlook.com>
Sat, 26 May 2012 02:29:13 +0000 (02:29 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 26 May 2012 02:29:13 +0000 (02:29 +0000)
Updated the Options Window to keep settings displayed up to date.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4698 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/App.xaml.cs
win/CS/HandBrakeWPF/AttachedProperties/MenuItemExtensions.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
win/CS/HandBrakeWPF/Views/QueueView.xaml

index ff32ba5c96aa3ef83813543bac8d4af326659413..3d6e00748dfbab6b74047df39ceb1d883361750e 100644 (file)
@@ -63,7 +63,7 @@ namespace HandBrakeWPF
             {\r
                 this.ShowError(e.Exception);\r
             }\r
-            else if (e.Exception.InnerException.GetType() == typeof(GeneralApplicationException))\r
+            else if (e.Exception.InnerException != null && e.Exception.InnerException.GetType() == typeof(GeneralApplicationException))\r
             {\r
                 this.ShowError(e.Exception.InnerException);\r
             }\r
diff --git a/win/CS/HandBrakeWPF/AttachedProperties/MenuItemExtensions.cs b/win/CS/HandBrakeWPF/AttachedProperties/MenuItemExtensions.cs
new file mode 100644 (file)
index 0000000..e08cf59
--- /dev/null
@@ -0,0 +1,145 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="MenuItemExtensions.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+//   Defines the MenuItemExtensions type.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.AttachedProperties\r
+{\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Windows;\r
+    using System.Windows.Controls;\r
+\r
+    /// <summary>\r
+    /// The menu item extensions.\r
+    /// </summary>\r
+    public class MenuItemExtensions : DependencyObject\r
+    {\r
+        #region Constants and Fields\r
+\r
+        /// <summary>\r
+        /// The group name property.\r
+        /// </summary>\r
+        public static readonly DependencyProperty GroupNameProperty = DependencyProperty.RegisterAttached(\r
+            "GroupName", \r
+            typeof(string), \r
+            typeof(MenuItemExtensions), \r
+            new PropertyMetadata(String.Empty, OnGroupNameChanged));\r
+\r
+        /// <summary>\r
+        /// The element to group names.\r
+        /// </summary>\r
+        public static Dictionary<MenuItem, String> ElementToGroupNames = new Dictionary<MenuItem, String>();\r
+\r
+        #endregion\r
+\r
+        #region Public Methods\r
+\r
+        /// <summary>\r
+        /// The get group name.\r
+        /// </summary>\r
+        /// <param name="element">\r
+        /// The element.\r
+        /// </param>\r
+        /// <returns>\r
+        /// The group name as a string.\r
+        /// </returns>\r
+        public static string GetGroupName(MenuItem element)\r
+        {\r
+            return element.GetValue(GroupNameProperty).ToString();\r
+        }\r
+\r
+        /// <summary>\r
+        /// The set group name.\r
+        /// </summary>\r
+        /// <param name="element">\r
+        /// The element.\r
+        /// </param>\r
+        /// <param name="value">\r
+        /// The value.\r
+        /// </param>\r
+        public static void SetGroupName(MenuItem element, string value)\r
+        {\r
+            element.SetValue(GroupNameProperty, value);\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region Methods\r
+\r
+        /// <summary>\r
+        /// The menu item checked.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
+        private static void MenuItemChecked(object sender, RoutedEventArgs e)\r
+        {\r
+            var menuItem = e.OriginalSource as MenuItem;\r
+            foreach (var item in ElementToGroupNames)\r
+            {\r
+                if (item.Key != menuItem && item.Value == GetGroupName(menuItem))\r
+                {\r
+                    item.Key.IsChecked = false;\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// The on group name changed.\r
+        /// </summary>\r
+        /// <param name="d">\r
+        /// The d.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The e.\r
+        /// </param>\r
+        private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r
+        {\r
+            MenuItem menuItem = d as MenuItem;\r
+\r
+            if (menuItem != null)\r
+            {\r
+                string newGroupName = e.NewValue.ToString();\r
+                string oldGroupName = e.OldValue.ToString();\r
+                if (string.IsNullOrEmpty(newGroupName))\r
+                {\r
+                    RemoveCheckboxFromGrouping(menuItem);\r
+                }\r
+                else\r
+                {\r
+                    if (newGroupName != oldGroupName)\r
+                    {\r
+                        if (!string.IsNullOrEmpty(oldGroupName))\r
+                        {\r
+                            RemoveCheckboxFromGrouping(menuItem);\r
+                        }\r
+                        ElementToGroupNames.Add(menuItem, e.NewValue.ToString());\r
+                        menuItem.Checked += MenuItemChecked;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// The remove checkbox from grouping.\r
+        /// </summary>\r
+        /// <param name="checkBox">\r
+        /// The check box.\r
+        /// </param>\r
+        private static void RemoveCheckboxFromGrouping(MenuItem checkBox)\r
+        {\r
+            ElementToGroupNames.Remove(checkBox);\r
+            checkBox.Checked -= MenuItemChecked;\r
+        }\r
+\r
+        #endregion\r
+    }\r
+}
\ No newline at end of file
index adeee6d40218bea23b68a1047a1c14bf362221c5..57a135d7948756f4b47cb3379aee76ca87e83c77 100644 (file)
       <Generator>MSBuild:Compile</Generator>\r
       <SubType>Designer</SubType>\r
     </ApplicationDefinition>\r
+    <Compile Include="AttachedProperties\MenuItemExtensions.cs" />\r
     <Compile Include="Controls\Loading.xaml.cs">\r
       <DependentUpon>Loading.xaml</DependentUpon>\r
     </Compile>\r
index 71d2476f1e7270151c5c5eac49018083af8a258f..951d8e3ace438f29da1a0e789368252791adfbd8 100644 (file)
@@ -321,7 +321,7 @@ namespace HandBrakeWPF.ViewModels
         {\r
             this.Title = "Options";\r
             this.userSettingService = userSettingService;\r
-            this.Load();\r
+            this.OnLoad();\r
         }\r
 \r
         #endregion\r
@@ -1243,6 +1243,15 @@ namespace HandBrakeWPF.ViewModels
 \r
         #region Public Methods\r
 \r
+        /// <summary>\r
+        /// Load / Update the user settings.\r
+        /// </summary>\r
+        protected override void OnActivate()\r
+        {\r
+            this.OnLoad();\r
+            base.OnActivate();\r
+        }\r
+\r
         /// <summary>\r
         /// Load User Settings\r
         /// </summary>\r
@@ -1252,10 +1261,11 @@ namespace HandBrakeWPF.ViewModels
             // General\r
             // #############################\r
 \r
-            this.enableGuiTooltips = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TooltipEnable);\r
-            this.checkForUpdates = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UpdateStatus);\r
+            this.EnableGuiTooltips = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TooltipEnable);\r
+            this.CheckForUpdates = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UpdateStatus);\r
 \r
             // Days between update checks\r
+            this.checkForUpdatesFrequencies.Clear();\r
             this.checkForUpdatesFrequencies.Add("Daily");\r
             this.checkForUpdatesFrequencies.Add("Weekly");\r
             this.checkForUpdatesFrequencies.Add("Monthly");\r
@@ -1264,17 +1274,18 @@ namespace HandBrakeWPF.ViewModels
             switch (this.userSettingService.GetUserSetting<int>(UserSettingConstants.DaysBetweenUpdateCheck))\r
             {\r
                 case 1:\r
-                    this.checkForUpdatesFrequency = 1;\r
+                    this.CheckForUpdatesFrequency = 1;\r
                     break;\r
                 case 7:\r
-                    this.checkForUpdatesFrequency = 2;\r
+                    this.CheckForUpdatesFrequency = 2;\r
                     break;\r
                 case 30:\r
-                    this.checkForUpdatesFrequency = 3;\r
+                    this.CheckForUpdatesFrequency = 3;\r
                     break;\r
             }\r
 \r
             // On Encode Completeion Action\r
+            this.whenDoneOptions.Clear();\r
             this.whenDoneOptions.Add("Do nothing");\r
             this.whenDoneOptions.Add("Shutdown");\r
             this.whenDoneOptions.Add("Suspend");\r
@@ -1282,48 +1293,49 @@ namespace HandBrakeWPF.ViewModels
             this.whenDoneOptions.Add("Lock system");\r
             this.whenDoneOptions.Add("Log off");\r
             this.whenDoneOptions.Add("Quit HandBrake");\r
-            this.whenDone = userSettingService.GetUserSetting<string>("WhenCompleteAction");\r
+            this.WhenDone = userSettingService.GetUserSetting<string>("WhenCompleteAction");\r
 \r
-            this.growlAfterEncode = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlEncode);\r
-            this.growlAfterQueue = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlQueue);\r
-            this.sendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile);\r
-            this.sendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)) ?? string.Empty;\r
-            this.sendFileToPath = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo) ?? string.Empty;\r
-            this.arguments = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs) ?? string.Empty;\r
+            this.GrowlAfterEncode = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlEncode);\r
+            this.GrowlAfterQueue = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlQueue);\r
+            this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile);\r
+            this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)) ?? string.Empty;\r
+            this.SendFileToPath = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo) ?? string.Empty;\r
+            this.Arguments = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs) ?? string.Empty;\r
 \r
             // #############################\r
             // Output Settings\r
             // #############################\r
 \r
             // Enable auto naming feature.)\r
-            this.automaticallyNameFiles = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming);\r
+            this.AutomaticallyNameFiles = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming);\r
 \r
             // Store the auto name path\r
-            this.autoNameDefaultPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath) ?? string.Empty;\r
+            this.AutoNameDefaultPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath) ?? string.Empty;\r
             if (string.IsNullOrEmpty(this.autoNameDefaultPath))\r
-                this.autoNameDefaultPath = "Click 'Browse' to set the default location";\r
+                this.AutoNameDefaultPath = "Click 'Browse' to set the default location";\r
 \r
             // Store auto name format\r
-            this.autonameFormat = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) ?? string.Empty;\r
+            this.AutonameFormat = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) ?? string.Empty;\r
 \r
             // Use iPod/iTunes friendly .m4v extension for MP4 files.\r
+            this.mp4ExtensionOptions.Clear();\r
             this.mp4ExtensionOptions.Add("Automatic");\r
             this.mp4ExtensionOptions.Add("Always use MP4");\r
             this.mp4ExtensionOptions.Add("Always use M4V");\r
-            this.selectedMp4Extension = this.userSettingService.GetUserSetting<int>(UserSettingConstants.UseM4v);\r
+            this.SelectedMp4Extension = this.userSettingService.GetUserSetting<int>(UserSettingConstants.UseM4v);\r
 \r
             // Remove Underscores\r
-            this.removeUnderscores = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore);\r
+            this.RemoveUnderscores = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore);\r
 \r
             // Title case\r
-            this.changeToTitleCase = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase);\r
+            this.ChangeToTitleCase = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase);\r
 \r
             // #############################\r
             // Picture Tab\r
             // #############################\r
 \r
             // VLC Path\r
-            this.vlcPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.VLC_Path) ?? string.Empty;\r
+            this.VLCPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.VLC_Path) ?? string.Empty;\r
 \r
             // #############################\r
             // Audio and Subtitles Tab\r
@@ -1334,6 +1346,7 @@ namespace HandBrakeWPF.ViewModels
 \r
             IDictionary<string, string> langList = LanguageUtilities.MapLanguages();\r
 \r
+            this.selectedLangauges.Clear();\r
             foreach (string selectedItem in this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages))\r
             {\r
                 // removing wrong keys when a new Language list comes out.\r
@@ -1343,6 +1356,8 @@ namespace HandBrakeWPF.ViewModels
                 }\r
             }\r
 \r
+            this.preferredLanguages.Clear();\r
+            this.availableLanguages.Clear();\r
             foreach (string item in langList.Keys)\r
             {\r
                 this.preferredLanguages.Add(item);\r
@@ -1354,13 +1369,15 @@ namespace HandBrakeWPF.ViewModels
                 }\r
             }\r
 \r
-            this.selectedPreferredLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) ?? string.Empty;\r
-            this.selectedPreferredSubtitleLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles) ?? string.Empty;\r
+            this.SelectedPreferredLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) ?? string.Empty;\r
+            this.SelectedPreferredSubtitleLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles) ?? string.Empty;\r
 \r
+            this.AddAudioModeOptions.Clear();\r
             this.AddAudioModeOptions.Add("None");\r
             this.AddAudioModeOptions.Add("All Remaining Tracks");\r
             this.AddAudioModeOptions.Add("All for Selected Languages");\r
 \r
+            this.AddSubtitleModeOptions.Clear();\r
             this.AddSubtitleModeOptions.Add("None");\r
             this.AddSubtitleModeOptions.Add("All");\r
             this.AddSubtitleModeOptions.Add("First");\r
@@ -1368,75 +1385,79 @@ namespace HandBrakeWPF.ViewModels
             this.AddSubtitleModeOptions.Add("Prefered Only (First)");\r
             this.AddSubtitleModeOptions.Add("Prefered Only (All)");\r
 \r
-            this.selectedAddAudioMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);\r
-            this.selectedAddSubtitleMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);\r
+            this.SelectedAddAudioMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);\r
+            this.SelectedAddSubtitleMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);\r
 \r
-            this.addOnlyOneAudioTrackPerLanguage = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AddOnlyOneAudioPerLanguage);\r
+            this.AddOnlyOneAudioTrackPerLanguage = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AddOnlyOneAudioPerLanguage);\r
 \r
-            this.addClosedCaptions = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption);\r
-            this.showAdvancedPassthruOpts = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);\r
+            this.AddClosedCaptions = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption);\r
+            this.ShowAdvancedPassthruOpts = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);\r
 \r
             // #############################\r
             // CLI\r
             // #############################\r
 \r
             // Priority level for encodes\r
+            this.priorityLevelOptions.Clear();\r
             this.priorityLevelOptions.Add("Realtime");\r
             this.priorityLevelOptions.Add("High");\r
             this.priorityLevelOptions.Add("Above Normal");\r
             this.priorityLevelOptions.Add("Normal");\r
             this.priorityLevelOptions.Add("Below Normal");\r
             this.priorityLevelOptions.Add("Low");\r
-            this.selectedPriority = userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority);\r
+            this.SelectedPriority = userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority);\r
 \r
-            this.preventSleep = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep);\r
+            this.PreventSleep = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep);\r
 \r
             // Log Verbosity Level\r
+            this.logVerbosityOptions.Clear();\r
             this.logVerbosityOptions.Add(0);\r
             this.logVerbosityOptions.Add(1);\r
             this.logVerbosityOptions.Add(2);\r
-            this.selectedVerbosity = userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);\r
+            this.SelectedVerbosity = userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);\r
 \r
             // Logs\r
-            this.copyLogToEncodeDirectory = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogWithVideo);\r
-            this.copyLogToSepcficedLocation = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogToCopyDirectory);\r
+            this.CopyLogToEncodeDirectory = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogWithVideo);\r
+            this.CopyLogToSepcficedLocation = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogToCopyDirectory);\r
 \r
             // The saved log path\r
-            this.logDirectory = userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory) ?? string.Empty;\r
+            this.LogDirectory = userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory) ?? string.Empty;\r
 \r
-            this.clearOldOlgs = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs);\r
+            this.ClearOldOlgs = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs);\r
 \r
             // #############################\r
             // Advanced\r
             // #############################\r
 \r
             // Minimise to Tray\r
-            this.displayStatusMessagesTrayIcon = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TrayIconAlerts);\r
-            this.minimiseToTray = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize);\r
-            this.disablePresetUpdateCheckNotification = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PresetNotification);\r
-            this.showCliWindow = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ShowCLI);\r
-            this.clearQueueOnEncodeCompleted = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ClearCompletedFromQueue);\r
+            this.DisplayStatusMessagesTrayIcon = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TrayIconAlerts);\r
+            this.MinimiseToTray = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize);\r
+            this.DisablePresetUpdateCheckNotification = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PresetNotification);\r
+            this.ShowCliWindow = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ShowCLI);\r
+            this.ClearQueueOnEncodeCompleted = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ClearCompletedFromQueue);\r
 \r
             // Set the preview count\r
+            this.PreviewPicturesToScan.Clear();\r
             this.PreviewPicturesToScan.Add(10);\r
             this.PreviewPicturesToScan.Add(15);\r
             this.PreviewPicturesToScan.Add(20);\r
             this.PreviewPicturesToScan.Add(25);\r
             this.PreviewPicturesToScan.Add(30);\r
-            this.selectedPreviewCount = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount);\r
+            this.SelectedPreviewCount = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount);\r
 \r
             // x264 step\r
+            this.ConstantQualityGranularity.Clear();\r
             this.ConstantQualityGranularity.Add("1.0");\r
             this.ConstantQualityGranularity.Add("0.50");\r
             this.ConstantQualityGranularity.Add("0.25");\r
             this.ConstantQualityGranularity.Add("0.20");\r
-            this.selectedGranulairty = userSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step).ToString("0.00", CultureInfo.InvariantCulture);\r
+            this.SelectedGranulairty = userSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step).ToString("0.00", CultureInfo.InvariantCulture);\r
 \r
             // Min Title Length\r
-            this.minLength = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration);\r
+            this.MinLength = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration);\r
 \r
             // Use Experimental dvdnav\r
-            this.disableLibdvdNav = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav);\r
+            this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav);\r
         }\r
 \r
         /// <summary>\r
@@ -1445,7 +1466,7 @@ namespace HandBrakeWPF.ViewModels
         public void Close()\r
         {\r
             this.Save();\r
-            this.TryClose();\r
+            this.TryClose(); \r
         }\r
 \r
         /// <summary>\r
index e6e6c8c01e361b44f4e8df8fc758769663443472..33ad3acf2b88dd6ee1f2ec5c94fc460cec296889 100644 (file)
@@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels
 \r
     using Caliburn.Micro;\r
 \r
+    using HandBrake.ApplicationServices;\r
     using HandBrake.ApplicationServices.EventArgs;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
@@ -38,6 +39,11 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         private readonly IErrorService errorService;\r
 \r
+        /// <summary>\r
+        /// The User Setting Service Backing Field.\r
+        /// </summary>\r
+        private readonly IUserSettingService userSettingService;\r
+\r
         /// <summary>\r
         /// Queue Processor Backing field\r
         /// </summary>\r
@@ -58,6 +64,11 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         private string jobsPending;\r
 \r
+        /// <summary>\r
+        /// Backing field for the when done action description\r
+        /// </summary>\r
+        private string whenDoneAction;\r
+\r
         #endregion\r
 \r
         #region Constructors and Destructors\r
@@ -68,19 +79,23 @@ namespace HandBrakeWPF.ViewModels
         /// <param name="windowManager">\r
         /// The window manager.\r
         /// </param>\r
+        /// <param name="userSettingService">\r
+        /// The user Setting Service.\r
+        /// </param>\r
         /// <param name="queueProcessor">\r
         /// The Queue Processor Service \r
         /// </param>\r
         /// <param name="errorService">\r
         /// The Error Service \r
         /// </param>\r
-        public QueueViewModel(IWindowManager windowManager, IQueueProcessor queueProcessor, IErrorService errorService)\r
+        public QueueViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)\r
         {\r
+            this.userSettingService = userSettingService;\r
             this.queueProcessor = queueProcessor;\r
             this.errorService = errorService;\r
             this.Title = "Queue";\r
             this.JobsPending = "No encodes pending";\r
-            this.JobStatus = "There are no jobs currently encoding";\r
+            this.JobStatus = "There are no jobs currently encoding";  \r
         }\r
 \r
         #endregion\r
@@ -149,10 +164,38 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets or sets WhenDoneAction.\r
+        /// </summary>\r
+        public string WhenDoneAction\r
+        {\r
+            get\r
+            {\r
+                return this.whenDoneAction;\r
+            }\r
+            set\r
+            {\r
+                this.whenDoneAction = value;\r
+                this.NotifyOfPropertyChange(() => this.WhenDoneAction);\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Public Methods\r
 \r
+        /// <summary>\r
+        /// Update the When Done Setting\r
+        /// </summary>\r
+        /// <param name="action">\r
+        /// The action.\r
+        /// </param>\r
+        public void WhenDone(string action)\r
+        {\r
+            this.WhenDoneAction = action;\r
+            this.userSettingService.SetUserSetting(ASUserSettingConstants.WhenCompleteAction, action);\r
+        }\r
+\r
         /// <summary>\r
         /// Clear the Queue\r
         /// </summary>\r
@@ -182,11 +225,6 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public override void OnLoad()\r
         {\r
-            this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;\r
-            this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;\r
-            this.queueProcessor.QueuePaused += this.queueProcessor_QueuePaused;\r
-            this.queueProcessor.QueueManager.QueueChanged += this.QueueManager_QueueChanged;\r
-\r
             // Setup the window to the correct state.\r
             this.IsEncoding = this.queueProcessor.EncodeService.IsEncoding;\r
             this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count);\r
@@ -291,9 +329,35 @@ namespace HandBrakeWPF.ViewModels
         protected override void OnActivate()\r
         {\r
             this.Load();\r
+\r
+            this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);    \r
+\r
+            this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;\r
+            this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;\r
+            this.queueProcessor.QueuePaused += this.queueProcessor_QueuePaused;\r
+            this.queueProcessor.QueueManager.QueueChanged += this.QueueManager_QueueChanged;\r
+            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged;\r
+\r
             base.OnActivate();\r
         }\r
 \r
+        /// <summary>\r
+        /// Override the Deactivate\r
+        /// </summary>\r
+        /// <param name="close">\r
+        /// The close.\r
+        /// </param>\r
+        protected override void OnDeactivate(bool close)\r
+        {\r
+            this.queueProcessor.JobProcessingStarted -= this.queueProcessor_JobProcessingStarted;\r
+            this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted;\r
+            this.queueProcessor.QueuePaused -= this.queueProcessor_QueuePaused;\r
+            this.queueProcessor.QueueManager.QueueChanged -= this.QueueManager_QueueChanged;\r
+            this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeService_EncodeStatusChanged;\r
+\r
+            base.OnDeactivate(close);\r
+        }\r
+\r
         /// <summary>\r
         /// Handle the Encode Status Changed Event.\r
         /// </summary>\r
@@ -346,7 +410,6 @@ namespace HandBrakeWPF.ViewModels
         {\r
             this.JobStatus = "Queue Started";\r
             this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count);\r
-            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged;\r
             this.IsEncoding = true;\r
         }\r
 \r
index 1c5d09861880a4ad22c923f7d8c64edf3f1455db..affd2b959517dde22ff59feb0096d1c71652408a 100644 (file)
@@ -6,8 +6,7 @@
              xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"\r
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"\r
         xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"\r
-        xmlns:Model="clr-namespace:HandBrake.ApplicationServices.Model;assembly=HandBrake.ApplicationServices"\r
-        mc:Ignorable="d" Title="{Binding Title}" \r
+        xmlns:YourNamespace="clr-namespace:HandBrakeWPF.AttachedProperties" mc:Ignorable="d" Title="{Binding Title}" \r
              Width="600" Height="400"\r
              Background="#FFF0F0F0">\r
 \r
             <RowDefinition Height="Auto" />\r
             <RowDefinition Height="*" />\r
         </Grid.RowDefinitions>\r
-        <ToolBar Name="mainToolBar" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  SnapsToDevicePixels="False">\r
-\r
-            <Button Name="Start" cal:Message.Attach="[Event Click] = [Action StartEncode]" Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">\r
-                <StackPanel Orientation="Horizontal">\r
-                    <Image Source="Images/Play.png" Height="32" Width="32" />\r
-                    <Label Content="Start"  Margin="8,0,0,0" VerticalAlignment="Center" />\r
-                </StackPanel>\r
-            </Button>\r
-\r
-            <Button Name="Pause" cal:Message.Attach="[Event Click] = [Action PauseEncode]" Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">\r
-                <StackPanel Orientation="Horizontal">\r
-                    <Image Source="Images/Pause.png" Height="32" Width="32" />\r
-                    <Label Content="Pause"  Margin="8,0,0,0" VerticalAlignment="Center" />\r
-                </StackPanel>\r
-            </Button>\r
+        <ToolBar Name="mainToolBar" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  SnapsToDevicePixels="True">\r
+\r
+            <DockPanel Background="Transparent" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type ToolBarPanel}}}">\r
+                <DockPanel.Resources>\r
+                    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />\r
+                    <Style TargetType="{x:Type Menu}" BasedOn="{StaticResource {x:Static ToolBar.MenuStyleKey}}" />\r
+                </DockPanel.Resources>\r
+\r
+                <Button Name="Start" cal:Message.Attach="[Event Click] = [Action StartEncode]" \r
+                    Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">\r
+                    <StackPanel Orientation="Horizontal">\r
+                        <Image Source="Images/Play.png" Height="32" Width="32" />\r
+                        <Label Content="Start"  Margin="8,0,0,0" VerticalAlignment="Center" />\r
+                    </StackPanel>\r
+                </Button>\r
+\r
+                <Button Name="Pause" cal:Message.Attach="[Event Click] = [Action PauseEncode]" \r
+                    Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">\r
+                    <StackPanel Orientation="Horizontal">\r
+                        <Image Source="Images/Pause.png" Height="32" Width="32" />\r
+                        <Label Content="Pause"  Margin="8,0,0,0" VerticalAlignment="Center" />\r
+                    </StackPanel>\r
+                </Button>\r
+\r
+                <Menu Background="Transparent" HorizontalAlignment="Right">\r
+                    <MenuItem>\r
+                        <MenuItem.Header>\r
+                            <StackPanel Orientation="Horizontal" Height="32">\r
+                                <TextBlock FontWeight="Bold" Text="When Done: " VerticalAlignment="Center" />\r
+                                <Label Content="{Binding WhenDoneAction}" Margin="8,0,0,0" VerticalAlignment="Center" />\r
+                                <Path Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"  Height="5" Margin="2,2,2,0"/>\r
+                            </StackPanel>\r
+                        </MenuItem.Header>\r
+                        <MenuItem Header="Do nothing" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone"  \r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(doNothing.Header)]" x:Name="doNothing" />\r
+                        <MenuItem Header="Shutdown" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone" \r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(shutdown.Header)]" x:Name="shutdown" />\r
+                        <MenuItem Header="Suspend" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone"\r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(suspend.Header)]" x:Name="suspend" />\r
+                        <MenuItem Header="Hibernate" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone"\r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(hibernate.Header)]" x:Name="hibernate" />\r
+                        <MenuItem Header="Lock system" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone" \r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(lock.Header)]" x:Name="lock" />            \r
+                        <MenuItem Header="Log off" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone"\r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(logoff.Header)]" x:Name="logoff" />\r
+                        <MenuItem Header="Quit HandBrake" IsCheckable="True" YourNamespace:MenuItemExtensions.GroupName="whenDone"\r
+                              cal:Message.Attach="[Event Click] = [Action WhenDone(quit.Header)]" x:Name="quit" />\r
+                    </MenuItem>\r
+                </Menu>\r
+            </DockPanel>\r
         </ToolBar>\r
 \r
         <StackPanel Grid.Row="1" Margin="10,20,10,20">\r
@@ -50,7 +84,7 @@
         <ListBox Grid.Row="2" ItemsSource="{Binding QueueJobs}" SelectionMode="Extended" Background="LightGray" Margin="10,0,10,10"\r
                  dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"\r
                  dd:DragDrop.DropHandler="{Binding}">\r
-            \r
+\r
             <ListBox.ContextMenu>\r
                 <ContextMenu>\r
                     <MenuItem Header="Import Queue" cal:Message.Attach="[Event Click] = [Action Import]" />\r
@@ -60,7 +94,7 @@
                     <MenuItem Header="Clear Completed" cal:Message.Attach="[Event Click] = [Action ClearCompleted]" />\r
                 </ContextMenu>\r
             </ListBox.ContextMenu>\r
-            \r
+\r
             <ListBox.ItemContainerStyle>\r
                 <Style TargetType="ListBoxItem">\r
                     <Setter Property="HorizontalContentAlignment" Value="Stretch" />\r
                                         </DataTrigger>\r
                                     </Style.Triggers>\r
                                 </Style>\r
-                            </Image.Style>    \r
+                            </Image.Style>\r
                         </Image>\r
 \r
                         <!-- Settings -->\r
                                 </Image>\r
                             </StackPanel>\r
                         </Grid>\r
-                            \r
-                        \r
-                  \r
+\r
+\r
+\r
                     </Grid>\r
 \r
 \r