From 6619723bda6ac183322dbc7ee908edcd013b9e7d Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 25 Oct 2011 21:31:15 +0000 Subject: WinGui: (WPF) Further work on the options screen. Initial rough styling and Load method. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4319 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 323 ++++++++++++++++++--- 1 file changed, 289 insertions(+), 34 deletions(-) (limited to 'win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs') diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 2e945a008..be2ed51e8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -9,11 +9,19 @@ namespace HandBrakeWPF.ViewModels { + using System.Collections.Generic; + using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Composition; + using System.Globalization; + using System.IO; using Caliburn.Micro; + using HandBrake.ApplicationServices; + using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrake.ApplicationServices.Utilities; + using HandBrakeWPF.ViewModels.Interfaces; /// @@ -24,10 +32,20 @@ namespace HandBrakeWPF.ViewModels { #region Constants and Fields + /// + /// Backing field for the user setting service. + /// + private readonly IUserSettingService userSettingService; + + /// + /// A Property to block Saving while the screen is loading. + /// + private bool isLoading = true; + /// /// The add audio mode options. /// - private BindingList addAudioModeOptions; + private BindingList addAudioModeOptions = new BindingList(); /// /// The add closed captions. @@ -42,7 +60,7 @@ namespace HandBrakeWPF.ViewModels /// /// The add subtitle mode options. /// - private BindingList addSubtitleModeOptions; + private BindingList addSubtitleModeOptions = new BindingList(); /// /// The arguments. @@ -67,7 +85,7 @@ namespace HandBrakeWPF.ViewModels /// /// The available languages. /// - private BindingList availableLanguages; + private BindingList availableLanguages = new BindingList(); /// /// The change to title case. @@ -82,12 +100,12 @@ namespace HandBrakeWPF.ViewModels /// /// The check for updates frequencies. /// - private BindingList checkForUpdatesFrequencies; + private BindingList checkForUpdatesFrequencies = new BindingList(); /// /// The check for updates frequency. /// - private bool checkForUpdatesFrequency; + private int checkForUpdatesFrequency; /// /// The clear old olgs. @@ -97,7 +115,7 @@ namespace HandBrakeWPF.ViewModels /// /// The constant quality granularity. /// - private BindingList constantQualityGranularity; + private BindingList constantQualityGranularity = new BindingList(); /// /// The copy log to encode directory. @@ -117,7 +135,7 @@ namespace HandBrakeWPF.ViewModels /// /// The disable p reset update check notification. /// - private bool disablePResetUpdateCheckNotification; + private bool disablePresetUpdateCheckNotification; /// /// The display status messages tray icon. @@ -152,7 +170,7 @@ namespace HandBrakeWPF.ViewModels /// /// The log verbosity options. /// - private BindingList logVerbosityOptions; + private BindingList logVerbosityOptions = new BindingList(); /// /// The min length. @@ -167,7 +185,7 @@ namespace HandBrakeWPF.ViewModels /// /// The mp 4 extension options. /// - private BindingList mp4ExtensionOptions; + private BindingList mp4ExtensionOptions = new BindingList(); /// /// The prevent sleep. @@ -177,12 +195,12 @@ namespace HandBrakeWPF.ViewModels /// /// The preview pictures to scan. /// - private BindingList previewPicturesToScan; + private BindingList previewPicturesToScan = new BindingList(); /// /// The priority level options. /// - private BindingList priorityLevelOptions; + private BindingList priorityLevelOptions = new BindingList(); /// /// The prompt on different query. @@ -197,27 +215,27 @@ namespace HandBrakeWPF.ViewModels /// /// The selected add audio mode. /// - private string selectedAddAudioMode; + private int selectedAddAudioMode; /// /// The selected add subtitle mode. /// - private string selectedAddSubtitleMode; + private int selectedAddSubtitleMode; /// /// The selected granulairty. /// - private bool selectedGranulairty; + private string selectedGranulairty; /// /// The selected mp 4 extension. /// - private string selectedMp4Extension; + private int selectedMp4Extension; /// /// The selected preferred languages. /// - private BindingList selectedPreferredLanguages; + private BindingList selectedPreferredLanguages = new BindingList(); /// /// The selected preferreed langauge. @@ -237,7 +255,7 @@ namespace HandBrakeWPF.ViewModels /// /// The selected verbosity. /// - private string selectedVerbosity; + private int selectedVerbosity; /// /// The send file after encode. @@ -267,7 +285,7 @@ namespace HandBrakeWPF.ViewModels /// /// The when done options. /// - private BindingList whenDoneOptions; + private BindingList whenDoneOptions = new BindingList(); #endregion @@ -279,15 +297,19 @@ namespace HandBrakeWPF.ViewModels /// /// The window manager. /// - public OptionsViewModel(IWindowManager windowManager) + /// + /// The user Setting Service. + /// + public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService) : base(windowManager) { + this.userSettingService = userSettingService; + this.Load(); } #endregion #region Properties - /* General */ /// /// Gets or sets AddAudioModeOptions. @@ -374,8 +396,6 @@ namespace HandBrakeWPF.ViewModels } } - /* Output Files */ - /// /// Gets or sets AutoNameDefaultPath. /// @@ -498,7 +518,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets a value indicating whether CheckForUpdatesFrequency. /// - public bool CheckForUpdatesFrequency + public int CheckForUpdatesFrequency { get { @@ -598,19 +618,19 @@ namespace HandBrakeWPF.ViewModels } /// - /// Gets or sets a value indicating whether DisablePResetUpdateCheckNotification. + /// Gets or sets a value indicating whether disablePresetUpdateCheckNotification. /// - public bool DisablePResetUpdateCheckNotification + public bool DisablePresetUpdateCheckNotification { get { - return this.disablePResetUpdateCheckNotification; + return this.disablePresetUpdateCheckNotification; } set { - this.disablePResetUpdateCheckNotification = value; - this.NotifyOfPropertyChange("DisablePResetUpdateCheckNotification"); + this.disablePresetUpdateCheckNotification = value; + this.NotifyOfPropertyChange("DisablePresetUpdateCheckNotification"); } } @@ -719,7 +739,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets LogVerbosityOptions. /// - public BindingList LogVerbosityOptions + public BindingList LogVerbosityOptions { get { @@ -872,7 +892,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets SelectedAddAudioMode. /// - public string SelectedAddAudioMode + public int SelectedAddAudioMode { get { @@ -889,7 +909,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets SelectedAddSubtitleMode. /// - public string SelectedAddSubtitleMode + public int SelectedAddSubtitleMode { get { @@ -906,7 +926,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets a value indicating whether SelectedGranulairty. /// - public bool SelectedGranulairty + public string SelectedGranulairty { get { @@ -923,7 +943,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets SelectedMp4Extension. /// - public string SelectedMp4Extension + public int SelectedMp4Extension { get { @@ -1008,7 +1028,7 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets SelectedVerbosity. /// - public string SelectedVerbosity + public int SelectedVerbosity { get { @@ -1128,6 +1148,241 @@ namespace HandBrakeWPF.ViewModels #region Public Methods + /// + /// Load User Settings + /// + public void Load() + { + // ############################# + // Screen Setup + // ############################# + + IDictionary langList = LanguageUtilities.MapLanguages(); + + foreach (string selectedItem in this.userSettingService.GetUserSetting(UserSettingConstants.SelectedLanguages)) + { + // removing wrong keys when a new Language list comes out. + if (langList.ContainsKey(selectedItem)) + { + this.selectedPreferredLanguages.Add(selectedItem); + } + } + + foreach (string item in langList.Keys) + { + this.selectedPreferredLanguages.Add(item); + + // In the available languages should be no "Any" and no selected language. + if ((item != "Any") && (!this.userSettingService.GetUserSetting(UserSettingConstants.SelectedLanguages).Contains(item))) + { + this.availableLanguages.Add(item); + } + } + + // ############################# + // General + // ############################# + + // Enable Tooltips. + if (this.userSettingService.GetUserSetting(UserSettingConstants.TooltipEnable)) + { + this.enableGuiTooltips = true; + } + + // Update Check + if (this.userSettingService.GetUserSetting(UserSettingConstants.UpdateStatus)) + { + this.checkForUpdates = true; + } + + // Days between update checks + this.checkForUpdatesFrequency = + this.userSettingService.GetUserSetting(UserSettingConstants.DaysBetweenUpdateCheck); + + // On Encode Completeion Action + this.whenDoneOptions.Add("Do nothing"); + this.whenDoneOptions.Add("Shutdown"); + this.whenDoneOptions.Add("Suspend"); + this.whenDoneOptions.Add("Hibernate"); + this.whenDoneOptions.Add("Lock system"); + this.whenDoneOptions.Add("Log off"); + this.whenDoneOptions.Add("Quit HandBrake"); + this.whenDone = userSettingService.GetUserSetting("WhenCompleteAction"); + + // Growl. + if (userSettingService.GetUserSetting(ASUserSettingConstants.GrowlEncode)) + { + this.growlAfterEncode = true; + } + + if (userSettingService.GetUserSetting(ASUserSettingConstants.GrowlQueue)) + { + this.growlAfterQueue = true; + } + + this.SendFileAfterEncode = this.userSettingService.GetUserSetting(ASUserSettingConstants.SendFile); + this.sendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting(ASUserSettingConstants.SendFileTo)); + this.arguments = this.userSettingService.GetUserSetting(ASUserSettingConstants.SendFileToArgs); + + // ############################# + // Output Settings + // ############################# + + // Enable auto naming feature.) + if (this.userSettingService.GetUserSetting(UserSettingConstants.AutoNaming)) + { + this.AutomaticallyNameFiles = true; + } + + // Store the auto name path + this.autoNameDefaultPath = this.userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath); + if (string.IsNullOrEmpty(this.autoNameDefaultPath)) + this.autoNameDefaultPath = "Click 'Browse' to set the default location"; + + // Store auto name format + this.autonameFormat = this.userSettingService.GetUserSetting(UserSettingConstants.AutoNameFormat); + + // Use iPod/iTunes friendly .m4v extension for MP4 files. + this.mp4ExtensionOptions.Add("Automatic"); + this.mp4ExtensionOptions.Add("Always use MP4"); + this.mp4ExtensionOptions.Add("Always use M4V"); + this.selectedMp4Extension = this.userSettingService.GetUserSetting(UserSettingConstants.UseM4v); + + // Remove Underscores + this.removeUnderscores = this.userSettingService.GetUserSetting(UserSettingConstants.AutoNameRemoveUnderscore); + + // Title case + this.changeToTitleCase = this.userSettingService.GetUserSetting(UserSettingConstants.AutoNameTitleCase); + + // ############################# + // Picture Tab + // ############################# + + // VLC Path + this.vlcPath = this.userSettingService.GetUserSetting(UserSettingConstants.VLC_Path); + + // ############################# + // Audio and Subtitles Tab + // ############################# + + this.selectedPreferreedLangauge = this.userSettingService.GetUserSetting(UserSettingConstants.NativeLanguage); + + this.AddAudioModeOptions.Add("None"); + this.AddAudioModeOptions.Add("All Remaining Tracks"); + this.AddAudioModeOptions.Add("All for Selected Languages"); + + this.AddSubtitleModeOptions.Add("None"); + this.AddSubtitleModeOptions.Add("All"); + this.AddSubtitleModeOptions.Add("First"); + this.AddSubtitleModeOptions.Add("Selected"); + this.AddSubtitleModeOptions.Add("Preferred Only"); + + this.selectedAddAudioMode = this.userSettingService.GetUserSetting(UserSettingConstants.DubModeAudio); + this.selectedAddSubtitleMode = this.userSettingService.GetUserSetting(UserSettingConstants.DubModeSubtitle); + + this.addOnlyOneAudioTrackPerLanguage = this.userSettingService.GetUserSetting(UserSettingConstants.AddOnlyOneAudioPerLanguage); + + this.addClosedCaptions = this.userSettingService.GetUserSetting(UserSettingConstants.UseClosedCaption); + + // ############################# + // CLI + // ############################# + + // Priority level for encodes + 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(ASUserSettingConstants.ProcessPriority); + + this.preventSleep = userSettingService.GetUserSetting(ASUserSettingConstants.PreventSleep); + + // Log Verbosity Level + this.logVerbosityOptions.Add(0); + this.logVerbosityOptions.Add(1); + this.logVerbosityOptions.Add(2); + this.selectedVerbosity = userSettingService.GetUserSetting(ASUserSettingConstants.Verbosity); + + // Save logs in the same directory as encoded files + if (userSettingService.GetUserSetting(ASUserSettingConstants.SaveLogWithVideo)) + { + this.copyLogToEncodeDirectory = true; + } + + // Save Logs in a specified path + if (userSettingService.GetUserSetting(ASUserSettingConstants.SaveLogToCopyDirectory)) + { + this.copyLogToSepcficedLocation = true; + } + + // The saved log path + this.logDirectory = userSettingService.GetUserSetting(ASUserSettingConstants.SaveLogCopyDirectory); + + this.clearOldOlgs = this.userSettingService.GetUserSetting(UserSettingConstants.ClearOldLogs); + + // ############################# + // Advanced + // ############################# + + // Minimise to Tray + if (this.userSettingService.GetUserSetting(UserSettingConstants.TrayIconAlerts)) + { + this.DisplayStatusMessagesTrayIcon = true; + } + + // Tray Balloon popups + if (this.userSettingService.GetUserSetting(UserSettingConstants.MainWindowMinimize)) + { + this.minimiseToTray = true; + } + + // Enable / Disable Query editor tab + if (this.userSettingService.GetUserSetting(UserSettingConstants.QueryEditorTab)) + { + this.enableQueryEditor = true; + } + + // Prompt on inconsistant queries + this.promptOnDifferentQuery = this.userSettingService.GetUserSetting(UserSettingConstants.PromptOnUnmatchingQueries); + + // Preset update notification + if (this.userSettingService.GetUserSetting(UserSettingConstants.PresetNotification)) + { + this.disablePresetUpdateCheckNotification = true; + } + + // Show CLI Window + this.showCliWindow = userSettingService.GetUserSetting(ASUserSettingConstants.ShowCLI); + + // Set the preview count + 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(UserSettingConstants.PreviewScanCount); + + // x264 step + this.ConstantQualityGranularity.Add("1.0"); + this.ConstantQualityGranularity.Add("0.50"); + this.ConstantQualityGranularity.Add("0.25"); + this.ConstantQualityGranularity.Add("0.20"); + this.SelectedGranulairty = userSettingService.GetUserSetting(ASUserSettingConstants.X264Step).ToString(new CultureInfo("en-US")); + + // Min Title Length + this.minLength = this.userSettingService.GetUserSetting(ASUserSettingConstants.MinScanDuration); + + // Use Experimental dvdnav + if (userSettingService.GetUserSetting(ASUserSettingConstants.DisableLibDvdNav)) + { + this.disableLibdvdNav = true; + } + + this.isLoading = false; + } + /// /// Close this window. /// -- cgit v1.2.3