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