summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs5
-rw-r--r--win/CS/HandBrake.Interop/Interop/Json/Presets/HBPresetCategory.cs (renamed from win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs)4
-rw-r--r--win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs2
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx3
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs115
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs6
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs22
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs42
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs58
-rw-r--r--win/CS/HandBrakeWPF/Views/PresetManagerView.xaml1
11 files changed, 146 insertions, 121 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
index 72352478c..38a5ee3d6 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
@@ -14,7 +14,6 @@ namespace HandBrake.Interop.Interop
using System.IO;
using System.Runtime.InteropServices;
- using HandBrake.Interop.Interop.HbLib;
using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Json.Presets;
@@ -44,11 +43,11 @@ namespace HandBrake.Interop.Interop
/// <returns>
/// The <see cref="string"/>.
/// </returns>
- public static IList<PresetCategory> GetBuiltInPresets()
+ public static IList<HBPresetCategory> GetBuiltInPresets()
{
IntPtr presets = hbFunctions.hb_presets_builtin_get_json();
string presetJson = Marshal.PtrToStringAnsi(presets);
- IList<PresetCategory> presetList = JsonConvert.DeserializeObject<IList<PresetCategory>>(presetJson);
+ IList<HBPresetCategory> presetList = JsonConvert.DeserializeObject<IList<HBPresetCategory>>(presetJson);
return presetList;
}
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPresetCategory.cs
index 21a8b41f7..90f80cd09 100644
--- a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs
+++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPresetCategory.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PresetCategory.cs" company="HandBrake Project (https://handbrake.fr)">
+// <copyright file="HbPresetCategory.cs" company="HandBrake Project (https://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
@@ -14,7 +14,7 @@ namespace HandBrake.Interop.Interop.Json.Presets
/// <summary>
/// The preset category.
/// </summary>
- public class PresetCategory
+ public class HBPresetCategory
{
/// <summary>
/// Gets or sets the children array.
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs
index 4d72e70ff..9f105069b 100644
--- a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs
+++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PresetTransportContainer.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="PresetTransportContainer.cs" company="HandBrake Project (https://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 798ca1c81..d1055c8dd 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -2578,6 +2578,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Export all user presets.
+ /// </summary>
+ public static string ManagePresetView_ExportUserPresets {
+ get {
+ return ResourceManager.GetString("ManagePresetView_ExportUserPresets", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Import Preset(s) from file.
/// </summary>
public static string ManagePresetView_Import {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index 7f55399d7..f460ba1a1 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -2378,4 +2378,7 @@ Fields are limited to:
<data name="ManagePresetView_NoPresetSelected" xml:space="preserve">
<value>There is no preset selected.</value>
</data>
+ <data name="ManagePresetView_ExportUserPresets" xml:space="preserve">
+ <value>Export all user presets</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index 50f257424..41e9fae37 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -9,7 +9,6 @@
namespace HandBrakeWPF.Services.Presets.Factories
{
- using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
@@ -25,38 +24,25 @@ namespace HandBrakeWPF.Services.Presets.Factories
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Model.Filters;
- using HandBrakeWPF.Model.Picture;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Services.Encode.Model.Models;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Utilities;
- using AudioEncoder = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder;
- using AudioTrack = HandBrakeWPF.Services.Encode.Model.Models.AudioTrack;
- using DenoisePreset = HandBrakeWPF.Services.Encode.Model.Models.DenoisePreset;
- using DenoiseTune = HandBrakeWPF.Services.Encode.Model.Models.DenoiseTune;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
- using FramerateMode = HandBrakeWPF.Services.Encode.Model.Models.FramerateMode;
- using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat;
- using VideoLevel = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoLevel;
- using VideoPreset = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoPreset;
- using VideoProfile = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoProfile;
- using VideoTune = HandBrakeWPF.Services.Encode.Model.Models.Video.VideoTune;
-
- /// <summary>
- /// The json preset factory.
- /// </summary>
+ using AudioEncoder = Encode.Model.Models.AudioEncoder;
+ using AudioTrack = Encode.Model.Models.AudioTrack;
+ using DenoisePreset = Encode.Model.Models.DenoisePreset;
+ using DenoiseTune = Encode.Model.Models.DenoiseTune;
+ using EncodeTask = Encode.Model.EncodeTask;
+ using FramerateMode = Encode.Model.Models.FramerateMode;
+ using OutputFormat = Encode.Model.Models.OutputFormat;
+ using VideoLevel = Encode.Model.Models.Video.VideoLevel;
+ using VideoPreset = Encode.Model.Models.Video.VideoPreset;
+ using VideoProfile = Encode.Model.Models.Video.VideoProfile;
+ using VideoTune = Encode.Model.Models.Video.VideoTune;
+
public class JsonPresetFactory
{
- /// <summary>
- /// The create preset.
- /// </summary>
- /// <param name="importedPreset">
- /// The preset.
- /// </param>
- /// <returns>
- /// The <see cref="Preset"/>.
- /// </returns>
public static Preset ImportPreset(HBPreset importedPreset)
{
Preset preset = new Preset();
@@ -477,25 +463,11 @@ namespace HandBrakeWPF.Services.Presets.Factories
// public int PictureForceHeight { get; set; }
// public int PictureForceWidth { get; set; }
// public List<object> ChildrenArray { get; set; }
- // public bool Folder { get; set; }
- // public bool FolderOpen { get; set; }
// public int Type { get; set; }
return preset;
}
- /// <summary>
- /// The export preset.
- /// </summary>
- /// <param name="export">
- /// The export.
- /// </param>
- /// <param name="config">
- /// HandBrakes configuration options.
- /// </param>
- /// <returns>
- /// The <see cref="Preset"/>.
- /// </returns>
public static PresetTransportContainer ExportPreset(Preset export, HBConfiguration config)
{
PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();
@@ -506,12 +478,6 @@ namespace HandBrakeWPF.Services.Presets.Factories
return container;
}
- /// <summary>
- /// Export a list of Presets.
- /// </summary>
- /// <param name="exportList">A list of presets to export</param>
- /// <param name="config">HB's configuration</param>
- /// <returns>A list of JSON object presets.</returns>
public static PresetTransportContainer ExportPresets(IEnumerable<Preset> exportList, HBConfiguration config)
{
PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();
@@ -525,16 +491,38 @@ namespace HandBrakeWPF.Services.Presets.Factories
return container;
}
- /// <summary>
- /// The create hb preset.
- /// </summary>
- /// <param name="export">
- /// The export.
- /// </param>
- /// <param name="config">HandBrakes current configuration</param>
- /// <returns>
- /// The <see cref="HBPreset"/>.
- /// </returns>
+ public static PresetTransportContainer ExportPresetCategories(IList<PresetDisplayCategory> categories, HBConfiguration config)
+ {
+ PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();
+ PresetTransportContainer container = new PresetTransportContainer(presetVersion.Major, presetVersion.Minor, presetVersion.Micro);
+
+ List<object> presets = new List<object>();
+ foreach (var category in categories)
+ {
+ presets.Add(CreatePresetCategory(category, config));
+ }
+
+ container.PresetList = presets;
+
+ return container;
+ }
+
+ public static HBPresetCategory CreatePresetCategory(PresetDisplayCategory category, HBConfiguration config)
+ {
+ HBPresetCategory preset = new HBPresetCategory();
+ preset.Folder = true;
+ preset.PresetName = category.Category;
+ preset.PresetDescription = string.Empty;
+ preset.ChildrenArray = new List<HBPreset>();
+
+ foreach (Preset singlePreset in category.Presets)
+ {
+ preset.ChildrenArray.Add(CreateHbPreset(singlePreset, config));
+ }
+
+ return preset;
+ }
+
public static HBPreset CreateHbPreset(Preset export, HBConfiguration config)
{
HBPreset preset = new HBPreset();
@@ -664,22 +652,13 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.VideoTwoPass = export.Task.TwoPass;
// Unknown
- preset.ChildrenArray = new List<object>(); // We don't support nested presets.
- preset.Folder = false; // TODO
- preset.FolderOpen = false; // TODO
+ preset.ChildrenArray = new List<object>();
+ preset.Folder = false;
+ preset.FolderOpen = false;
return preset;
}
- /// <summary>
- /// Get the OutputFormat Enum for a given string
- /// </summary>
- /// <param name="format">
- /// OutputFormat as a string
- /// </param>
- /// <returns>
- /// An OutputFormat Enum
- /// </returns>
private static OutputFormat GetFileFormat(string format)
{
switch (format.ToLower())
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
index 70d8c2e21..e4e5e4881 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
@@ -44,7 +44,6 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
/// </summary>
void Load();
-
/// <summary>
/// Force save updates to the preset files. Rarely should need to be called. Only used by the preset manager.
/// </summary>
@@ -63,6 +62,9 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
/// <summary>
/// Get a list of preset categories.
/// </summary>
+ /// <param name="userCategoriesOnly">
+ /// The user Categories Only.
+ /// </param>
/// <returns>
/// String list.
/// </returns>
@@ -102,6 +104,8 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
/// </param>
void Export(string filename, Preset preset, HBConfiguration configuration);
+ void ExportCategories(string filename, IList<PresetDisplayCategory> categories, HBConfiguration configuration);
+
/// <summary>
/// Update a preset
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
index 1712f4756..53e19bc62 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
@@ -26,19 +26,23 @@ namespace HandBrakeWPF.Services.Presets.Model
}
public string Category { get; private set; }
+
public BindingList<Preset> Presets { get; private set; }
+
public string Description => this.Category;
+
public bool IsBuiltIn { get; }
public bool IsExpanded
{
- get
- {
- return this.isExpanded;
- }
+ get => this.isExpanded;
set
{
- if (value == this.isExpanded) return;
+ if (value == this.isExpanded)
+ {
+ return;
+ }
+
this.isExpanded = value;
this.NotifyOfPropertyChange(() => this.IsExpanded);
}
@@ -46,10 +50,8 @@ namespace HandBrakeWPF.Services.Presets.Model
public bool IsSelected
{
- get
- {
- return this.isSelected;
- }
+ get => this.isSelected;
+
set
{
if (value == this.isSelected) return;
@@ -68,7 +70,7 @@ namespace HandBrakeWPF.Services.Presets.Model
public override int GetHashCode()
{
- return (this.Category != null ? this.Category.GetHashCode() : 0);
+ return this.Category != null ? this.Category.GetHashCode() : 0;
}
protected bool Equals(PresetDisplayCategory other)
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index 44535ba1c..ab1e76d87 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -50,8 +50,7 @@ namespace HandBrakeWPF.Services.Presets
private readonly List<Preset> flatPresetList = new List<Preset>();
private readonly IErrorService errorService;
private readonly IUserSettingService userSettingService;
- private ILog log = null;
-
+ private ILog log;
public PresetService(IErrorService errorService, IUserSettingService userSettingService, ILog logService)
{
@@ -136,7 +135,7 @@ namespace HandBrakeWPF.Services.Presets
{
if (!string.IsNullOrEmpty(filename))
{
- PresetTransportContainer container = null;
+ PresetTransportContainer container;
try
{
container = HandBrakePresetService.GetPresetsFromFile(filename);
@@ -159,14 +158,15 @@ namespace HandBrakeWPF.Services.Presets
bool containsBuildInPreset = false;
foreach (var objectPreset in container.PresetList)
{
- PresetCategory category = JsonConvert.DeserializeObject<PresetCategory>(objectPreset.ToString());
+ HBPresetCategory category = JsonConvert.DeserializeObject<HBPresetCategory>(objectPreset.ToString());
if (category != null && category.ChildrenArray != null && category.ChildrenArray.Count > 0)
{
foreach (HBPreset hbPreset in category.ChildrenArray)
{
- Preset preset = this.ConvertHbPreset(hbPreset);
+ Preset preset = this.ConvertHbPreset(hbPreset, category.PresetName);
preset.IsPresetDisabled = this.IsPresetDisabled(preset);
- if (preset != null && !preset.IsBuildIn)
+ preset.IsDefault = false; // When importing, force the user to reset default manually. This prevents conflicts.
+ if (!preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
}
@@ -181,9 +181,10 @@ namespace HandBrakeWPF.Services.Presets
HBPreset hbPreset = JsonConvert.DeserializeObject<HBPreset>(objectPreset.ToString());
if (hbPreset != null)
{
- Preset preset = this.ConvertHbPreset(hbPreset);
+ Preset preset = this.ConvertHbPreset(hbPreset, null);
+ preset.IsDefault = false; // When importing, force the user to reset default manually. This prevents conflicts.
preset.IsPresetDisabled = this.IsPresetDisabled(preset);
- if (preset != null && !preset.IsBuildIn)
+ if (!preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
}
@@ -209,11 +210,16 @@ namespace HandBrakeWPF.Services.Presets
public void Export(string filename, Preset preset, HBConfiguration configuration)
{
- // TODO Add support for multiple export
PresetTransportContainer container = JsonPresetFactory.ExportPreset(preset, configuration);
HandBrakePresetService.ExportPreset(filename, container);
}
+ public void ExportCategories(string filename, IList<PresetDisplayCategory> categories, HBConfiguration configuration)
+ {
+ PresetTransportContainer container = JsonPresetFactory.ExportPresetCategories(categories, configuration);
+ HandBrakePresetService.ExportPreset(filename, container);
+ }
+
public void Update(Preset update)
{
Preset preset;
@@ -417,7 +423,7 @@ namespace HandBrakeWPF.Services.Presets
// Clear the current built in Presets and now parse the temporary Presets file.
this.ClearBuiltIn();
- IList<PresetCategory> presetCategories = HandBrakePresetService.GetBuiltInPresets();
+ IList<HBPresetCategory> presetCategories = HandBrakePresetService.GetBuiltInPresets();
foreach (var category in presetCategories)
{
@@ -667,10 +673,10 @@ namespace HandBrakeWPF.Services.Presets
// The presets file loaded was OK, so process it.
foreach (var item in container.PresetList)
{
- object deserialisedItem = JsonConvert.DeserializeObject<PresetCategory>(item.ToString());
+ object deserialisedItem = JsonConvert.DeserializeObject<HBPresetCategory>(item.ToString());
// Handle Categorised Presets.
- PresetCategory category = deserialisedItem as PresetCategory;
+ HBPresetCategory category = deserialisedItem as HBPresetCategory;
if (category != null && category.Folder)
{
foreach (HBPreset hbpreset in category.ChildrenArray)
@@ -713,7 +719,7 @@ namespace HandBrakeWPF.Services.Presets
}
// Organise the Presets list into Json Equivalent objects.
- Dictionary<string, PresetCategory> presetCategories = new Dictionary<string, PresetCategory>();
+ Dictionary<string, HBPresetCategory> presetCategories = new Dictionary<string, HBPresetCategory>();
List<HBPreset> uncategorisedPresets = new List<HBPreset>();
// Handle User Presets.
@@ -753,7 +759,7 @@ namespace HandBrakeWPF.Services.Presets
this.presets.Clear();
}
- private void HandlePresetListsForSave(List<Preset> processList, Dictionary<string, PresetCategory> presetCategories, List<HBPreset> uncategorisedPresets)
+ private void HandlePresetListsForSave(List<Preset> processList, Dictionary<string, HBPresetCategory> presetCategories, List<HBPreset> uncategorisedPresets)
{
foreach (Preset item in processList)
{
@@ -770,8 +776,8 @@ namespace HandBrakeWPF.Services.Presets
}
else
{
- presetCategories[item.Category] = new PresetCategory
- {
+ presetCategories[item.Category] = new HBPresetCategory
+ {
ChildrenArray = new List<HBPreset> { preset },
Folder = true,
PresetName = item.Category,
@@ -782,10 +788,10 @@ namespace HandBrakeWPF.Services.Presets
}
}
- private Preset ConvertHbPreset(HBPreset hbPreset)
+ private Preset ConvertHbPreset(HBPreset hbPreset, string categoryName)
{
Preset preset = JsonPresetFactory.ImportPreset(hbPreset);
- preset.Category = UserPresetCatgoryName; // TODO can we get this from the preset?
+ preset.Category = !string.IsNullOrEmpty(categoryName) ? categoryName : UserPresetCatgoryName;
return preset;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs
index 8b3890f5e..54c99db92 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs
@@ -223,24 +223,6 @@ namespace HandBrakeWPF.ViewModels
this.presetService.PresetCollectionChanged += this.PresetService_PresetCollectionChanged;
}
- private void PresetService_PresetCollectionChanged(object sender, System.EventArgs e)
- {
- string presetName = this.selectedPreset?.Name; // Recording such that we can re-select
-
- this.PresetsCategories = this.presetService.Presets;
- this.UserPresetCategories = presetService.GetPresetCategories(true).ToList(); // .Union(new List<PresetDisplayCategory> { addNewCategory }).ToList();
-
- this.NotifyOfPropertyChange(() => this.PresetsCategories);
- this.NotifyOfPropertyChange(() => this.UserPresetCategories);
- this.NotifyOfPropertyChange(() => this.SelectedUserPresetCategory);
-
- // Reselect the preset as the object has changed due to the reload that occurred.
- if (!string.IsNullOrEmpty(presetName))
- {
- this.SelectedPreset = this.presetService.FlatPresetList.FirstOrDefault(s => s.Name == presetName);
- }
- }
-
public void DeletePreset()
{
if (this.selectedPreset != null)
@@ -330,6 +312,28 @@ namespace HandBrakeWPF.ViewModels
}
}
+ public void ExportUserPresets()
+ {
+ SaveFileDialog savefiledialog = new SaveFileDialog
+ {
+ Filter = "json|*.json",
+ CheckPathExists = true,
+ AddExtension = true,
+ DefaultExt = ".json",
+ OverwritePrompt = true,
+ FilterIndex = 0
+ };
+
+ savefiledialog.ShowDialog();
+ string filename = savefiledialog.FileName;
+
+ if (!string.IsNullOrEmpty(filename))
+ {
+ IList<PresetDisplayCategory> userPresets = this.presetService.GetPresetCategories(true);
+ this.presetService.ExportCategories(savefiledialog.FileName, userPresets, HBConfigurationFactory.Create());
+ }
+ }
+
public void DeleteBuiltInPresets()
{
List<Preset> allPresets = this.presetService.FlatPresetList;
@@ -467,5 +471,23 @@ namespace HandBrakeWPF.ViewModels
this.SelectedPictureSettingsResLimitMode = PictureSettingsResLimitModes.None;
}
}
+
+ private void PresetService_PresetCollectionChanged(object sender, System.EventArgs e)
+ {
+ string presetName = this.selectedPreset?.Name; // Recording such that we can re-select
+
+ this.PresetsCategories = this.presetService.Presets;
+ this.UserPresetCategories = presetService.GetPresetCategories(true).ToList(); // .Union(new List<PresetDisplayCategory> { addNewCategory }).ToList();
+
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ this.NotifyOfPropertyChange(() => this.UserPresetCategories);
+ this.NotifyOfPropertyChange(() => this.SelectedUserPresetCategory);
+
+ // Reselect the preset as the object has changed due to the reload that occurred.
+ if (!string.IsNullOrEmpty(presetName))
+ {
+ this.SelectedPreset = this.presetService.FlatPresetList.FirstOrDefault(s => s.Name == presetName);
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml
index 07186b94d..94a3d377d 100644
--- a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml
+++ b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml
@@ -107,6 +107,7 @@
<MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="{x:Static Properties:Resources.ManagePresetView_Import}" />
<MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="{x:Static Properties:Resources.ManagePresetView_Export}" />
+ <MenuItem cal:Message.Attach="[Event Click] = [Action ExportUserPresets]" Header="{x:Static Properties:Resources.ManagePresetView_ExportUserPresets}" />
<Separator />
<MenuItem cal:Message.Attach="[Event Click] = [Action SetDefault]" Header="{x:Static Properties:Resources.ManagePresetView_SetDefault}" />