From e17f33293848a5f3a783f09377adc94ffedb0f44 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 8 Sep 2017 22:14:26 +0100 Subject: WinGui: Implementing the new Preset design that does away with the legacy style preset pane and re-arranges parts of the main window for better process flow. --- .../Properties/ResourcesUI.Designer.cs | 2 +- win/CS/HandBrakeWPF/Properties/ResourcesUI.resx | 2 +- .../Services/Presets/Interfaces/IPresetService.cs | 10 - .../HandBrakeWPF/Services/Presets/PresetService.cs | 33 -- win/CS/HandBrakeWPF/UserSettingConstants.cs | 5 - win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 166 ++++---- win/CS/HandBrakeWPF/Views/MainView.xaml | 428 +++++++-------------- win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 62 +-- win/CS/HandBrakeWPF/Views/ShellView.xaml | 4 +- win/CS/HandBrakeWPF/defaultsettings.xml | 8 - 10 files changed, 248 insertions(+), 472 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 9cdce00b9..c132ff043 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -736,7 +736,7 @@ namespace HandBrakeWPF.Properties { } /// - /// Looks up a localized string similar to File. + /// Looks up a localized string similar to Save To. /// public static string MainView_File { get { diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 98b46afe9..11b3727b1 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -151,7 +151,7 @@ Duration - File + Save To Filters diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs index f75c054c5..6c6b8ceb6 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs @@ -35,16 +35,6 @@ namespace HandBrakeWPF.Services.Presets.Interfaces /// void Load(); - /// - /// Save the state of the Preset Treview - /// - void SaveCategoryStates(); - - /// - /// Load the state of the Preset Treeview. - /// - void LoadCategoryStates(); - /// /// Add a new preset to the system /// diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index 14001040e..ea948344b 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -543,39 +543,6 @@ namespace HandBrakeWPF.Services.Presets selectedPreset.IsSelected = true; } - public void SaveCategoryStates() - { - StringCollection expandedPresets = new StringCollection(); - foreach (IPresetObject presetObject in this.presets) - { - PresetDisplayCategory category = presetObject as PresetDisplayCategory; - if (category != null && category.IsExpanded) - { - expandedPresets.Add(category.Category); - } - } - - this.userSettingService.SetUserSetting(UserSettingConstants.PresetExpandedStateList, expandedPresets); - } - - public void LoadCategoryStates() - { - StringCollection expandedPresets = this.userSettingService.GetUserSetting(UserSettingConstants.PresetExpandedStateList); - if (expandedPresets == null || expandedPresets.Count == 0) - { - return; - } - - foreach (IPresetObject presetObject in this.presets) - { - PresetDisplayCategory category = presetObject as PresetDisplayCategory; - if (category != null && expandedPresets.Contains(category.Category)) - { - category.IsExpanded = true; - } - } - } - #endregion #region Private Helpers diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 09bc63d83..74c901d2d 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -146,11 +146,6 @@ namespace HandBrakeWPF /// public const string RemovePunctuation = "RemovePunctuation"; - /// - /// The Show Preset Panel - /// - public const string ShowPresetPanel = "ShowPresetPanel"; - /// /// The reset when done action. /// diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 21b323aff..1c6c0ba34 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -89,7 +89,6 @@ namespace HandBrakeWPF.ViewModels private Preset selectedPreset; private EncodeTask queueEditTask; private int lastEncodePercentage; - private bool isPresetPanelShowing; private bool showSourceSelection; private BindingList drives; private bool canPause; @@ -98,6 +97,8 @@ namespace HandBrakeWPF.ViewModels private string alertWindowText; private bool hasSource; + private IPresetObject selectedPresetCategory; + #endregion /// @@ -206,7 +207,7 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged; this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged; - this.Presets = new BindingList(); + this.PresetsCategories = new BindingList(); this.Drives = new BindingList(); // Set Process Priority @@ -362,12 +363,49 @@ namespace HandBrakeWPF.ViewModels /// /// Gets or sets Presets. /// - public IEnumerable Presets { get; set; } + public IEnumerable PresetsCategories { get; set; } + + public IPresetObject SelectedPresetCategory + { + get + { + return this.selectedPresetCategory; + } + set + { + if (!object.Equals(this.selectedPresetCategory, value)) + { + this.selectedPresetCategory = value; + this.NotifyOfPropertyChange(() => this.SelectedPresetCategory); + this.NotifyOfPropertyChange(() => this.CategoryPresets); + } + } + } + + public IEnumerable CategoryPresets + { + get + { + PresetDisplayCategory category = this.SelectedPresetCategory as PresetDisplayCategory; + if (category != null && category.Presets != null) + { + if (!category.Presets.Contains(this.SelectedPreset)) + { + this.SelectedPreset = category.Presets.FirstOrDefault(); + } + + return new BindingList(category.Presets); + } + + this.SelectedPreset = null; + return new BindingList(); + } + } /// /// Gets or sets SelectedPreset. /// - public object SelectedPreset + public Preset SelectedPreset { get { @@ -376,30 +414,11 @@ namespace HandBrakeWPF.ViewModels set { - if (value == null || value.GetType() != typeof(Preset)) + if (!object.Equals(this.selectedPreset, value)) { - return; + this.selectedPreset = value; + this.NotifyOfPropertyChange(() => this.SelectedPreset); } - - this.selectedPreset = (Preset)value; - - this.presetService.SetSelected(selectedPreset); - - if (this.selectedPreset != null) - { - // Tab Settings - this.PictureSettingsViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.VideoViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.FiltersViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.AudioViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.SubtitleViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.ChaptersViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.AdvancedViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.MetaDataViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - this.SummaryViewModel.SetPreset(this.selectedPreset, this.CurrentTask); - } - - this.NotifyOfPropertyChange(() => this.SelectedPreset); } } @@ -911,31 +930,6 @@ namespace HandBrakeWPF.ViewModels } } - /// - /// Gets or sets a value indicating whether is preset panel showing. - /// - public bool IsPresetPanelShowing - { - get - { - return this.isPresetPanelShowing; - } - set - { - if (!Equals(this.isPresetPanelShowing, value)) - { - this.isPresetPanelShowing = value; - this.NotifyOfPropertyChange(() => this.IsPresetPanelShowing); - - // Save the setting if it has changed. - if (this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel) != value) - { - this.userSettingService.SetUserSetting(UserSettingConstants.ShowPresetPanel, value); - } - } - } - } - /// /// Gets or sets a value indicating progress percentage. /// @@ -1194,14 +1188,10 @@ namespace HandBrakeWPF.ViewModels // Perform an update check if required this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults); - // Show or Hide the Preset Panel. - this.IsPresetPanelShowing = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel); - // Setup the presets. this.presetService.Load(); - this.Presets = this.presetService.Presets; - this.NotifyOfPropertyChange(() => this.Presets); - this.presetService.LoadCategoryStates(); + this.PresetsCategories = this.presetService.Presets; + this.NotifyOfPropertyChange(() => this.PresetsCategories); this.SummaryViewModel.OutputFormatChanged += this.SummaryViewModel_OutputFormatChanged; @@ -1224,7 +1214,8 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.Start(this.userSettingService.GetUserSetting(UserSettingConstants.ClearCompletedFromQueue)); } - this.SelectedPreset = this.presetService.DefaultPreset; + // Preset Selection + this.SetDefaultPreset(); // Reset WhenDone if necessary. if (this.userSettingService.GetUserSetting(UserSettingConstants.ResetWhenDoneAction)) @@ -1258,7 +1249,6 @@ namespace HandBrakeWPF.ViewModels { // Shutdown Service this.queueProcessor.Stop(); - this.presetService.SaveCategoryStates(); // Unsubscribe from Events. this.scanService.ScanStarted -= this.ScanStared; @@ -1843,11 +1833,12 @@ namespace HandBrakeWPF.ViewModels /// public void PresetAdd() { - // TODO select the new preset. IAddPresetViewModel presetViewModel = IoC.Get(); presetViewModel.Setup(this.CurrentTask, this.SelectedTitle, this.AudioViewModel.AudioBehaviours, this.SubtitleViewModel.SubtitleBehaviours); this.windowManager.ShowDialog(presetViewModel); - this.NotifyOfPropertyChange(() => this.Presets); + + this.NotifyOfPropertyChange(() => this.PresetsCategories); + this.NotifyOfPropertyChange(() => this.CategoryPresets); } /// @@ -1939,7 +1930,7 @@ namespace HandBrakeWPF.ViewModels } this.presetService.Remove(this.selectedPreset); - this.NotifyOfPropertyChange(() => this.Presets); + this.NotifyOfPropertyChange(() => this.CategoryPresets); } else { @@ -1973,7 +1964,7 @@ namespace HandBrakeWPF.ViewModels if (dialogResult.HasValue && dialogResult.Value) { this.presetService.Import(dialog.FileName); - this.NotifyOfPropertyChange(() => this.Presets); + this.NotifyOfPropertyChange(() => this.CategoryPresets); } } @@ -2014,11 +2005,20 @@ namespace HandBrakeWPF.ViewModels public void PresetReset() { this.presetService.UpdateBuiltInPresets(); - this.NotifyOfPropertyChange(() => this.Presets); - this.SelectedPreset = this.presetService.DefaultPreset; + + this.NotifyOfPropertyChange(() => this.PresetsCategories); + this.NotifyOfPropertyChange(() => this.CategoryPresets); + + this.SetDefaultPreset(); + this.errorService.ShowMessageBox(Resources.Presets_ResetComplete, Resources.Presets_ResetHeader, MessageBoxButton.OK, MessageBoxImage.Information); } + public void PresetSelect() + { + this.PresetSelect(this.SelectedPreset); + } + /// /// The preset select. /// @@ -2030,8 +2030,29 @@ namespace HandBrakeWPF.ViewModels Preset preset = tag as Preset; if (preset != null) { + if (this.SelectedPresetCategory == null || this.SelectedPresetCategory.Category != preset.Category) + { + this.SelectedPresetCategory = this.PresetsCategories.FirstOrDefault(c => c.Category == preset.Category); + } + this.SelectedPreset = preset; } + + this.presetService.SetSelected(this.selectedPreset); + + if (this.selectedPreset != null) + { + // Tab Settings + this.PictureSettingsViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.VideoViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.FiltersViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.AudioViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.SubtitleViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.ChaptersViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.AdvancedViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.MetaDataViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + this.SummaryViewModel.SetPreset(this.selectedPreset, this.CurrentTask); + } } /// @@ -2218,6 +2239,21 @@ namespace HandBrakeWPF.ViewModels this.AlertWindowText = message; } + private void SetDefaultPreset() + { + // Preset Selection + if (this.presetService.DefaultPreset != null) + { + PresetDisplayCategory category = + (PresetDisplayCategory)this.PresetsCategories.FirstOrDefault( + p => p.Category == this.presetService.DefaultPreset.Category); + + this.SelectedPresetCategory = category; + this.SelectedPreset = this.presetService.DefaultPreset; + this.PresetSelect(); + } + } + #endregion #region Event Handlers diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index cadd5a5ee..20313547d 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -1,25 +1,20 @@  + FontSize="11" + cal:Message.Attach="[Event Loaded] = [Action Load]" + SnapsToDevicePixels="True" + UseLayoutRounding="True" +> - - - @@ -50,12 +40,12 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Vertical" - > + > + > @@ -84,17 +74,13 @@ - + - - - @@ -132,7 +118,7 @@ ToolBar.OverflowMode="Never" ToolBarTray.IsLocked="True" KeyboardNavigation.TabNavigation="Continue" - > + > @@ -155,16 +141,16 @@ Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" - > + > + /> @@ -173,17 +159,17 @@ Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" - > + > + /> @@ -192,17 +178,17 @@ Visibility="{Binding CanPause, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" - > + > + /> @@ -215,10 +201,10 @@ + Data="M 0 0 L 4 4 L 8 0 Z" + Fill="{DynamicResource GlyphBrush}" x:Name="dropdownArrow" /> - + @@ -236,11 +222,11 @@ Height="32" SnapsToDevicePixels="True" Source="Images/Queue_small.png" - /> + />