diff options
author | sr55 <[email protected]> | 2017-09-11 19:48:03 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-09-11 19:48:03 +0100 |
commit | 6f5e5ea1703a9a40a54d8d677b1c24e45dff7b32 (patch) | |
tree | da4b3eb7253e9ef0c4eefa62b6b4796b48947367 /win/CS | |
parent | d0abd0c3f6cc67a74c2280e63c86d2aea2d84204 (diff) |
WinGui: Improve selection behaviour of the new preset controls.
Diffstat (limited to 'win/CS')
4 files changed, 95 insertions, 29 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs index 6c6b8ceb6..f75c054c5 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs @@ -36,6 +36,16 @@ namespace HandBrakeWPF.Services.Presets.Interfaces void Load();
/// <summary>
+ /// Save the state of the Preset Treview
+ /// </summary>
+ void SaveCategoryStates();
+
+ /// <summary>
+ /// Load the state of the Preset Treeview.
+ /// </summary>
+ void LoadCategoryStates();
+
+ /// <summary>
/// Add a new preset to the system
/// </summary>
/// <param name="preset">
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index 16db5359a..f4057dbc3 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -472,7 +472,7 @@ namespace HandBrakeWPF.Services.Presets foreach (var hbpreset in category.ChildrenArray)
{
Preset preset = JsonPresetFactory.ImportPreset(hbpreset);
- preset.IsBuildIn = true;
+ preset.IsBuildIn = true;
preset.Category = category.PresetName;
preset.Task.AllowedPassthruOptions = new AllowedPassthru(true); // We don't want to override the built-in preset
@@ -543,6 +543,39 @@ 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<StringCollection>(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
@@ -654,10 +687,10 @@ namespace HandBrakeWPF.Services.Presets {
string filename = this.RecoverFromCorruptedPresetFile(this.presetFile);
this.errorService.ShowMessageBox(
- Resources.PresetService_UnableToLoadPresets + filename,
- Resources.PresetService_UnableToLoad,
- MessageBoxButton.OK,
- MessageBoxImage.Exclamation);
+ Resources.PresetService_UnableToLoadPresets + filename,
+ Resources.PresetService_UnableToLoad,
+ MessageBoxButton.OK,
+ MessageBoxImage.Exclamation);
this.UpdateBuiltInPresets();
return; // Update built-in presets stores the presets locally, so just return.
@@ -707,7 +740,16 @@ namespace HandBrakeWPF.Services.Presets foreach (HBPreset hbpreset in category.ChildrenArray)
{
Preset preset = JsonPresetFactory.ImportPreset(hbpreset);
- preset.Category = category.PresetName;
+
+ // Migration
+ if (category.PresetName == "User Presets")
+ {
+ preset.Category = UserPresetCatgoryName;
+ }
+ else
+ {
+ preset.Category = category.PresetName;
+ }
preset.IsBuildIn = hbpreset.Type == 0;
// IF we are using Source Max, Set the Max Width / Height values.
@@ -797,9 +839,10 @@ namespace HandBrakeWPF.Services.Presets // Wrap the categories in a container.
JsonSerializerSettings settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore };
PresetTransportContainer container = new PresetTransportContainer(
- Constants.PresetVersionMajor,
- Constants.PresetVersionMinor,
- Constants.PresetVersionMicro) { PresetList = new List<object>() };
+ Constants.PresetVersionMajor,
+ Constants.PresetVersionMinor,
+ Constants.PresetVersionMicro)
+ { PresetList = new List<object>() };
container.PresetList.AddRange(presetCategories.Values);
container.PresetList.AddRange(uncategorisedPresets);
@@ -867,4 +910,4 @@ namespace HandBrakeWPF.Services.Presets #endregion
}
-}
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 74c901d2d..cde030c23 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -105,7 +105,7 @@ namespace HandBrakeWPF /// The last preview duration
/// </summary>
public const string LastPreviewDuration = "LastPreviewDuration";
-
+
/// <summary>
/// When Complete Action
/// </summary>
@@ -147,6 +147,11 @@ namespace HandBrakeWPF public const string RemovePunctuation = "RemovePunctuation";
/// <summary>
+ /// The Show Preset Panel
+ /// </summary>
+ public const string ShowPresetPanel = "ShowPresetPanel";
+
+ /// <summary>
/// The reset when done action.
/// </summary>
public const string ResetWhenDoneAction = "ResetWhenDoneAction";
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index de4476367..c8cf354ac 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -418,6 +418,11 @@ namespace HandBrakeWPF.ViewModels {
this.selectedPreset = value;
this.NotifyOfPropertyChange(() => this.SelectedPreset);
+
+ if (value != null)
+ {
+ this.PresetSelect(value);
+ }
}
}
}
@@ -1192,6 +1197,7 @@ namespace HandBrakeWPF.ViewModels this.presetService.Load();
this.PresetsCategories = this.presetService.Presets;
this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ this.presetService.LoadCategoryStates();
this.SummaryViewModel.OutputFormatChanged += this.SummaryViewModel_OutputFormatChanged;
@@ -1249,6 +1255,7 @@ namespace HandBrakeWPF.ViewModels {
// Shutdown Service
this.queueProcessor.Stop();
+ this.presetService.SaveCategoryStates();
// Unsubscribe from Events.
this.scanService.ScanStarted -= this.ScanStared;
@@ -1897,7 +1904,8 @@ namespace HandBrakeWPF.ViewModels Preset preset = presetViewModel.Preset;
this.NotifyOfPropertyChange(() => this.CategoryPresets);
- this.SelectedPreset = preset; // Reselect the preset
+ this.selectedPreset = preset; // Reselect the preset
+ this.NotifyOfPropertyChange(() => this.SelectedPreset);
}
/// <summary>
@@ -2037,23 +2045,24 @@ namespace HandBrakeWPF.ViewModels this.SelectedPresetCategory = this.PresetsCategories.FirstOrDefault(c => c.Category == preset.Category);
}
- this.SelectedPreset = preset;
- }
+ this.selectedPreset = preset;
+ this.NotifyOfPropertyChange(() => this.SelectedPreset);
- 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);
+ 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);
+ }
}
}
@@ -2252,7 +2261,6 @@ namespace HandBrakeWPF.ViewModels this.SelectedPresetCategory = category;
this.SelectedPreset = this.presetService.DefaultPreset;
- this.PresetSelect();
}
}
|