\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using System.Collections.Generic;\r
+ using System.Collections.Specialized;\r
using System.ComponentModel;\r
using System.ComponentModel.Composition;\r
+ using System.Globalization;\r
+ using System.IO;\r
\r
using Caliburn.Micro;\r
\r
+ using HandBrake.ApplicationServices;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
+ using HandBrake.ApplicationServices.Utilities;\r
+\r
using HandBrakeWPF.ViewModels.Interfaces;\r
\r
/// <summary>\r
{\r
#region Constants and Fields\r
\r
+ /// <summary>\r
+ /// Backing field for the user setting service.\r
+ /// </summary>\r
+ private readonly IUserSettingService userSettingService;\r
+\r
+ /// <summary>\r
+ /// A Property to block Saving while the screen is loading.\r
+ /// </summary>\r
+ private bool isLoading = true;\r
+\r
/// <summary>\r
/// The add audio mode options.\r
/// </summary>\r
- private BindingList<string> addAudioModeOptions;\r
+ private BindingList<string> addAudioModeOptions = new BindingList<string>();\r
\r
/// <summary>\r
/// The add closed captions.\r
/// <summary>\r
/// The add subtitle mode options.\r
/// </summary>\r
- private BindingList<string> addSubtitleModeOptions;\r
+ private BindingList<string> addSubtitleModeOptions = new BindingList<string>();\r
\r
/// <summary>\r
/// The arguments.\r
/// <summary>\r
/// The available languages.\r
/// </summary>\r
- private BindingList<string> availableLanguages;\r
+ private BindingList<string> availableLanguages = new BindingList<string>();\r
\r
/// <summary>\r
/// The change to title case.\r
/// <summary>\r
/// The check for updates frequencies.\r
/// </summary>\r
- private BindingList<string> checkForUpdatesFrequencies;\r
+ private BindingList<string> checkForUpdatesFrequencies = new BindingList<string>();\r
\r
/// <summary>\r
/// The check for updates frequency.\r
/// </summary>\r
- private bool checkForUpdatesFrequency;\r
+ private int checkForUpdatesFrequency;\r
\r
/// <summary>\r
/// The clear old olgs.\r
/// <summary>\r
/// The constant quality granularity.\r
/// </summary>\r
- private BindingList<string> constantQualityGranularity;\r
+ private BindingList<string> constantQualityGranularity = new BindingList<string>();\r
\r
/// <summary>\r
/// The copy log to encode directory.\r
/// <summary>\r
/// The disable p reset update check notification.\r
/// </summary>\r
- private bool disablePResetUpdateCheckNotification;\r
+ private bool disablePresetUpdateCheckNotification;\r
\r
/// <summary>\r
/// The display status messages tray icon.\r
/// <summary>\r
/// The log verbosity options.\r
/// </summary>\r
- private BindingList<string> logVerbosityOptions;\r
+ private BindingList<int> logVerbosityOptions = new BindingList<int>();\r
\r
/// <summary>\r
/// The min length.\r
/// <summary>\r
/// The mp 4 extension options.\r
/// </summary>\r
- private BindingList<string> mp4ExtensionOptions;\r
+ private BindingList<string> mp4ExtensionOptions = new BindingList<string>();\r
\r
/// <summary>\r
/// The prevent sleep.\r
/// <summary>\r
/// The preview pictures to scan.\r
/// </summary>\r
- private BindingList<int> previewPicturesToScan;\r
+ private BindingList<int> previewPicturesToScan = new BindingList<int>();\r
\r
/// <summary>\r
/// The priority level options.\r
/// </summary>\r
- private BindingList<string> priorityLevelOptions;\r
+ private BindingList<string> priorityLevelOptions = new BindingList<string>();\r
\r
/// <summary>\r
/// The prompt on different query.\r
/// <summary>\r
/// The selected add audio mode.\r
/// </summary>\r
- private string selectedAddAudioMode;\r
+ private int selectedAddAudioMode;\r
\r
/// <summary>\r
/// The selected add subtitle mode.\r
/// </summary>\r
- private string selectedAddSubtitleMode;\r
+ private int selectedAddSubtitleMode;\r
\r
/// <summary>\r
/// The selected granulairty.\r
/// </summary>\r
- private bool selectedGranulairty;\r
+ private string selectedGranulairty;\r
\r
/// <summary>\r
/// The selected mp 4 extension.\r
/// </summary>\r
- private string selectedMp4Extension;\r
+ private int selectedMp4Extension;\r
\r
/// <summary>\r
/// The selected preferred languages.\r
/// </summary>\r
- private BindingList<string> selectedPreferredLanguages;\r
+ private BindingList<string> selectedPreferredLanguages = new BindingList<string>();\r
\r
/// <summary>\r
/// The selected preferreed langauge.\r
/// <summary>\r
/// The selected verbosity.\r
/// </summary>\r
- private string selectedVerbosity;\r
+ private int selectedVerbosity;\r
\r
/// <summary>\r
/// The send file after encode.\r
/// <summary>\r
/// The when done options.\r
/// </summary>\r
- private BindingList<string> whenDoneOptions;\r
+ private BindingList<string> whenDoneOptions = new BindingList<string>();\r
\r
#endregion\r
\r
/// <param name="windowManager">\r
/// The window manager.\r
/// </param>\r
- public OptionsViewModel(IWindowManager windowManager)\r
+ /// <param name="userSettingService">\r
+ /// The user Setting Service.\r
+ /// </param>\r
+ public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)\r
: base(windowManager)\r
{\r
+ this.userSettingService = userSettingService;\r
+ this.Load();\r
}\r
\r
#endregion\r
\r
#region Properties\r
- /* General */\r
\r
/// <summary>\r
/// Gets or sets AddAudioModeOptions.\r
}\r
}\r
\r
- /* Output Files */\r
-\r
/// <summary>\r
/// Gets or sets AutoNameDefaultPath.\r
/// </summary>\r
/// <summary>\r
/// Gets or sets a value indicating whether CheckForUpdatesFrequency.\r
/// </summary>\r
- public bool CheckForUpdatesFrequency\r
+ public int CheckForUpdatesFrequency\r
{\r
get\r
{\r
}\r
\r
/// <summary>\r
- /// Gets or sets a value indicating whether DisablePResetUpdateCheckNotification.\r
+ /// Gets or sets a value indicating whether disablePresetUpdateCheckNotification.\r
/// </summary>\r
- public bool DisablePResetUpdateCheckNotification\r
+ public bool DisablePresetUpdateCheckNotification\r
{\r
get\r
{\r
- return this.disablePResetUpdateCheckNotification;\r
+ return this.disablePresetUpdateCheckNotification;\r
}\r
\r
set\r
{\r
- this.disablePResetUpdateCheckNotification = value;\r
- this.NotifyOfPropertyChange("DisablePResetUpdateCheckNotification");\r
+ this.disablePresetUpdateCheckNotification = value;\r
+ this.NotifyOfPropertyChange("DisablePresetUpdateCheckNotification");\r
}\r
}\r
\r
/// <summary>\r
/// Gets or sets LogVerbosityOptions.\r
/// </summary>\r
- public BindingList<string> LogVerbosityOptions\r
+ public BindingList<int> LogVerbosityOptions\r
{\r
get\r
{\r
/// <summary>\r
/// Gets or sets SelectedAddAudioMode.\r
/// </summary>\r
- public string SelectedAddAudioMode\r
+ public int SelectedAddAudioMode\r
{\r
get\r
{\r
/// <summary>\r
/// Gets or sets SelectedAddSubtitleMode.\r
/// </summary>\r
- public string SelectedAddSubtitleMode\r
+ public int SelectedAddSubtitleMode\r
{\r
get\r
{\r
/// <summary>\r
/// Gets or sets a value indicating whether SelectedGranulairty.\r
/// </summary>\r
- public bool SelectedGranulairty\r
+ public string SelectedGranulairty\r
{\r
get\r
{\r
/// <summary>\r
/// Gets or sets SelectedMp4Extension.\r
/// </summary>\r
- public string SelectedMp4Extension\r
+ public int SelectedMp4Extension\r
{\r
get\r
{\r
/// <summary>\r
/// Gets or sets SelectedVerbosity.\r
/// </summary>\r
- public string SelectedVerbosity\r
+ public int SelectedVerbosity\r
{\r
get\r
{\r
\r
#region Public Methods\r
\r
+ /// <summary>\r
+ /// Load User Settings\r
+ /// </summary>\r
+ public void Load()\r
+ {\r
+ // #############################\r
+ // Screen Setup\r
+ // #############################\r
+\r
+ IDictionary<string, string> langList = LanguageUtilities.MapLanguages();\r
+\r
+ foreach (string selectedItem in this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages))\r
+ {\r
+ // removing wrong keys when a new Language list comes out.\r
+ if (langList.ContainsKey(selectedItem))\r
+ {\r
+ this.selectedPreferredLanguages.Add(selectedItem);\r
+ }\r
+ }\r
+\r
+ foreach (string item in langList.Keys)\r
+ {\r
+ this.selectedPreferredLanguages.Add(item);\r
+\r
+ // In the available languages should be no "Any" and no selected language.\r
+ if ((item != "Any") && (!this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages).Contains(item)))\r
+ {\r
+ this.availableLanguages.Add(item);\r
+ }\r
+ }\r
+\r
+ // #############################\r
+ // General\r
+ // #############################\r
+\r
+ // Enable Tooltips.\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TooltipEnable))\r
+ {\r
+ this.enableGuiTooltips = true;\r
+ }\r
+\r
+ // Update Check\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UpdateStatus))\r
+ {\r
+ this.checkForUpdates = true;\r
+ }\r
+ \r
+ // Days between update checks\r
+ this.checkForUpdatesFrequency =\r
+ this.userSettingService.GetUserSetting<int>(UserSettingConstants.DaysBetweenUpdateCheck);\r
+\r
+ // On Encode Completeion Action\r
+ this.whenDoneOptions.Add("Do nothing");\r
+ this.whenDoneOptions.Add("Shutdown");\r
+ this.whenDoneOptions.Add("Suspend");\r
+ this.whenDoneOptions.Add("Hibernate");\r
+ 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
+ \r
+ // Growl.\r
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlEncode))\r
+ {\r
+ this.growlAfterEncode = true;\r
+ }\r
+\r
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlQueue))\r
+ {\r
+ this.growlAfterQueue = true;\r
+ }\r
+\r
+ this.SendFileAfterEncode = this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile);\r
+ this.sendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo));\r
+ this.arguments = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs);\r
+\r
+ // #############################\r
+ // Output Settings\r
+ // #############################\r
+\r
+ // Enable auto naming feature.)\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming))\r
+ {\r
+ this.AutomaticallyNameFiles = true;\r
+ }\r
+\r
+ // Store the auto name path\r
+ this.autoNameDefaultPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath);\r
+ if (string.IsNullOrEmpty(this.autoNameDefaultPath))\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);\r
+\r
+ // Use iPod/iTunes friendly .m4v extension for MP4 files.\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
+\r
+ // Remove Underscores\r
+ this.removeUnderscores = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore);\r
+\r
+ // Title case\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);\r
+\r
+ // #############################\r
+ // Audio and Subtitles Tab\r
+ // #############################\r
+\r
+ this.selectedPreferreedLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage);\r
+\r
+ this.AddAudioModeOptions.Add("None");\r
+ this.AddAudioModeOptions.Add("All Remaining Tracks");\r
+ this.AddAudioModeOptions.Add("All for Selected Languages");\r
+\r
+ this.AddSubtitleModeOptions.Add("None");\r
+ this.AddSubtitleModeOptions.Add("All");\r
+ this.AddSubtitleModeOptions.Add("First");\r
+ this.AddSubtitleModeOptions.Add("Selected");\r
+ this.AddSubtitleModeOptions.Add("Preferred Only");\r
+\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
+\r
+ this.addClosedCaptions = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption);\r
+\r
+ // #############################\r
+ // CLI\r
+ // #############################\r
+\r
+ // Priority level for encodes\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
+\r
+ this.preventSleep = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep);\r
+\r
+ // Log Verbosity Level\r
+ this.logVerbosityOptions.Add(0);\r
+ this.logVerbosityOptions.Add(1);\r
+ this.logVerbosityOptions.Add(2);\r
+ this.selectedVerbosity = userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);\r
+\r
+ // Save logs in the same directory as encoded files\r
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogWithVideo))\r
+ {\r
+ this.copyLogToEncodeDirectory = true;\r
+ }\r
+\r
+ // Save Logs in a specified path\r
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogToCopyDirectory))\r
+ {\r
+ this.copyLogToSepcficedLocation = true;\r
+ }\r
+\r
+ // The saved log path\r
+ this.logDirectory = userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory);\r
+\r
+ this.clearOldOlgs = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs);\r
+\r
+ // #############################\r
+ // Advanced\r
+ // #############################\r
+\r
+ // Minimise to Tray\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.TrayIconAlerts))\r
+ {\r
+ this.DisplayStatusMessagesTrayIcon = true;\r
+ }\r
+\r
+ // Tray Balloon popups\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize))\r
+ {\r
+ this.minimiseToTray = true;\r
+ }\r
+\r
+ // Enable / Disable Query editor tab\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.QueryEditorTab))\r
+ {\r
+ this.enableQueryEditor = true;\r
+ }\r
+ \r
+ // Prompt on inconsistant queries\r
+ this.promptOnDifferentQuery = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PromptOnUnmatchingQueries);\r
+\r
+ // Preset update notification\r
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PresetNotification))\r
+ {\r
+ this.disablePresetUpdateCheckNotification = true;\r
+ }\r
+\r
+ // Show CLI Window\r
+ this.showCliWindow = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ShowCLI);\r
+\r
+ // Set the preview count\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>(UserSettingConstants.PreviewScanCount);\r
+\r
+ // x264 step\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(new CultureInfo("en-US"));\r
+\r
+ // Min Title Length\r
+ this.minLength = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration);\r
+\r
+ // Use Experimental dvdnav\r
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))\r
+ {\r
+ this.disableLibdvdNav = true;\r
+ }\r
+\r
+ this.isLoading = false;\r
+ }\r
+\r
/// <summary>\r
/// Close this window.\r
/// </summary>\r