diff options
author | sr55 <[email protected]> | 2011-09-24 21:52:17 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-09-24 21:52:17 +0000 |
commit | f62a6501bae828a835383e6226f3bd86173e36ae (patch) | |
tree | 84a26e33d971999935bb4632ea88b8d6b79f3ead /win/CS/HandBrake.ApplicationServices/Services/PresetService.cs | |
parent | 1d1054492cc183ee7b731cf9d1ce787707c7abf5 (diff) |
WinGui: Some bug fixes and re-factoring of the preset code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4246 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/PresetService.cs')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/PresetService.cs | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 12afaadbc..30487f15c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -13,7 +13,6 @@ namespace HandBrake.ApplicationServices.Services using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
- using System.Windows;
using System.Xml.Serialization;
using HandBrake.ApplicationServices.Exceptions;
@@ -87,10 +86,21 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
- /// The last preset added.
+ /// Gets or sets LastPresetAdded.
/// </summary>
public Preset LastPresetAdded { get; set; }
+ /// <summary>
+ /// Gets the DefaultPreset.
+ /// </summary>
+ public Preset DefaultPreset
+ {
+ get
+ {
+ return this.presets.FirstOrDefault(p => p.IsDefault);
+ }
+ }
+
#region Public Methods
/// <summary>
@@ -148,6 +158,11 @@ namespace HandBrake.ApplicationServices.Services /// </param>
public void Remove(Preset preset)
{
+ if (preset == null || preset.IsDefault)
+ {
+ return;
+ }
+
this.presets.Remove(preset);
this.UpdatePresetFiles();
}
@@ -163,6 +178,12 @@ namespace HandBrake.ApplicationServices.Services List<Preset> removeList = this.presets.Where(p => p.Category == category).ToList();
foreach (Preset preset in removeList)
{
+ if (preset.IsDefault)
+ {
+ // Skip default preset
+ continue;
+ }
+
this.presets.Remove(preset);
}
@@ -170,6 +191,24 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
+ /// Set Default Preset
+ /// </summary>
+ /// <param name="name">
+ /// The name.
+ /// </param>
+ public void SetDefault(Preset name)
+ {
+ foreach (Preset preset in this.presets)
+ {
+ preset.IsDefault = false;
+ }
+
+ name.IsDefault = true;
+ this.UpdatePresetFiles();
+ }
+
+
+ /// <summary>
/// Get a Preset
/// </summary>
/// <param name="name">
@@ -268,6 +307,11 @@ namespace HandBrake.ApplicationServices.Services IsBuildIn = true
};
+ if (newPreset.Name == "Normal")
+ {
+ newPreset.IsDefault = true;
+ }
+
this.presets.Add(newPreset);
}
}
|