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 | |
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')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Model/Preset.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/PresetService.cs | 48 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs | 2 | ||||
-rw-r--r-- | win/CS/UserSettingConstants.cs | 1 | ||||
-rw-r--r-- | win/CS/frmMain.cs | 40 |
5 files changed, 79 insertions, 17 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs index ede38b26f..eedf3f737 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs @@ -46,6 +46,11 @@ namespace HandBrake.ApplicationServices.Model public bool IsBuildIn { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether IsDefault.
+ /// </summary>
+ public bool IsDefault { get; set; }
+
+ /// <summary>
/// Override the ToString Method
/// </summary>
/// <returns>
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);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 30b752d7d..2bbdfffcd 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -547,7 +547,7 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());
// Preset Information
- AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeBuild));
+ AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild).ToString());
AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description");
AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name);
AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in
diff --git a/win/CS/UserSettingConstants.cs b/win/CS/UserSettingConstants.cs index 843e0bc9e..9754bbdc2 100644 --- a/win/CS/UserSettingConstants.cs +++ b/win/CS/UserSettingConstants.cs @@ -12,7 +12,6 @@ namespace Handbrake {
public const string UpdateStatus = "updateStatus";
public const string TooltipEnable = "tooltipEnable";
- public const string DefaultPreset = "defaultPreset";
public const string Skipversion = "skipversion";
public const string AutoNaming = "autoNaming";
public const string AutoNamePath = "autoNamePath";
diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index 6687dd540..072b18b2c 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -182,10 +182,9 @@ namespace Handbrake ToolTip.Active = true;
// Load the user's default settings or Normal Preset
- if (userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset) != string.Empty
- && presetHandler.GetPreset(userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset)) != null)
+ if (this.presetHandler.DefaultPreset != null)
{
- this.loadPreset(userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset));
+ this.loadPreset(this.presetHandler.DefaultPreset.Name);
}
else
loadPreset("Normal");
@@ -569,12 +568,7 @@ namespace Handbrake /// </param>
private void pmnu_delete_click(object sender, EventArgs e)
{
- if (treeView_presets.SelectedNode != null)
- {
- presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);
- treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);
- }
- treeView_presets.Select();
+ BtnRemovePreset_Click(sender, e);
}
/// <summary>
@@ -639,21 +633,41 @@ namespace Handbrake }
else
{
+ Preset preset = treeView_presets.SelectedNode.Tag as Preset;
+ if (preset != null && preset.IsDefault)
+ {
+ MessageBox.Show(
+ "Your default preset can not be deleted. It is a required preset.",
+ "Warning",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+
// Delete the selected item.
presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);
}
- treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);
+
+ this.LoadPresetPanel();
}
treeView_presets.Select();
+ treeView_presets.ExpandAll();
}
private void MnuSetDefaultPreset_Click(object sender, EventArgs e)
{
if (treeView_presets.SelectedNode != null)
{
- this.userSettingService.SetUserSetting(UserSettingConstants.DefaultPreset, treeView_presets.SelectedNode.Text);
- MessageBox.Show("New default preset set: " + treeView_presets.SelectedNode.Text, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ Preset preset = treeView_presets.SelectedNode.Tag as Preset;
+ if (preset != null)
+ {
+ MessageBox.Show(
+ "New default preset set: " + treeView_presets.SelectedNode.Text,
+ "Alert",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ this.presetHandler.SetDefault(preset);
+ }
}
else
MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -1548,7 +1562,7 @@ namespace Handbrake text_destination.Text = autoPath;
else
MessageBox.Show(
- "You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a valid default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')",
+ "You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a valid default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'Output Files' Tab -> 'Default Path')",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
|