summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-09-11 19:48:03 +0100
committersr55 <[email protected]>2017-09-11 19:48:03 +0100
commit6f5e5ea1703a9a40a54d8d677b1c24e45dff7b32 (patch)
treeda4b3eb7253e9ef0c4eefa62b6b4796b48947367 /win/CS/HandBrakeWPF/Services
parentd0abd0c3f6cc67a74c2280e63c86d2aea2d84204 (diff)
WinGui: Improve selection behaviour of the new preset controls.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs10
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs63
2 files changed, 63 insertions, 10 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