using System.Linq;\r
using System.Text;\r
using System.Text.RegularExpressions;\r
- using System.Windows;\r
using System.Xml.Serialization;\r
\r
using HandBrake.ApplicationServices.Exceptions;\r
}\r
\r
/// <summary>\r
- /// The last preset added.\r
+ /// Gets or sets LastPresetAdded.\r
/// </summary>\r
public Preset LastPresetAdded { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets the DefaultPreset.\r
+ /// </summary>\r
+ public Preset DefaultPreset\r
+ {\r
+ get\r
+ {\r
+ return this.presets.FirstOrDefault(p => p.IsDefault);\r
+ }\r
+ }\r
+\r
#region Public Methods\r
\r
/// <summary>\r
/// </param>\r
public void Remove(Preset preset)\r
{\r
+ if (preset == null || preset.IsDefault)\r
+ {\r
+ return;\r
+ }\r
+\r
this.presets.Remove(preset);\r
this.UpdatePresetFiles();\r
}\r
List<Preset> removeList = this.presets.Where(p => p.Category == category).ToList();\r
foreach (Preset preset in removeList)\r
{\r
+ if (preset.IsDefault)\r
+ {\r
+ // Skip default preset\r
+ continue;\r
+ }\r
+\r
this.presets.Remove(preset);\r
}\r
\r
this.UpdatePresetFiles();\r
}\r
\r
+ /// <summary>\r
+ /// Set Default Preset\r
+ /// </summary>\r
+ /// <param name="name">\r
+ /// The name.\r
+ /// </param>\r
+ public void SetDefault(Preset name)\r
+ {\r
+ foreach (Preset preset in this.presets)\r
+ {\r
+ preset.IsDefault = false;\r
+ }\r
+\r
+ name.IsDefault = true;\r
+ this.UpdatePresetFiles();\r
+ }\r
+\r
+\r
/// <summary>\r
/// Get a Preset\r
/// </summary>\r
IsBuildIn = true\r
};\r
\r
+ if (newPreset.Name == "Normal")\r
+ {\r
+ newPreset.IsDefault = true;\r
+ }\r
+\r
this.presets.Add(newPreset);\r
}\r
}\r
AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());\r
\r
// Preset Information\r
- AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeBuild));\r
+ AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild).ToString());\r
AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description");\r
AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name);\r
AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in\r
ToolTip.Active = true;\r
\r
// Load the user's default settings or Normal Preset\r
- if (userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset) != string.Empty\r
- && presetHandler.GetPreset(userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset)) != null)\r
+ if (this.presetHandler.DefaultPreset != null)\r
{\r
- this.loadPreset(userSettingService.GetUserSetting<string>(UserSettingConstants.DefaultPreset));\r
+ this.loadPreset(this.presetHandler.DefaultPreset.Name);\r
}\r
else\r
loadPreset("Normal");\r
/// </param>\r
private void pmnu_delete_click(object sender, EventArgs e)\r
{\r
- if (treeView_presets.SelectedNode != null)\r
- {\r
- presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);\r
- treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
- }\r
- treeView_presets.Select();\r
+ BtnRemovePreset_Click(sender, e);\r
}\r
\r
/// <summary>\r
}\r
else\r
{\r
+ Preset preset = treeView_presets.SelectedNode.Tag as Preset;\r
+ if (preset != null && preset.IsDefault)\r
+ {\r
+ MessageBox.Show(\r
+ "Your default preset can not be deleted. It is a required preset.",\r
+ "Warning",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Information);\r
+ }\r
+\r
// Delete the selected item.\r
presetHandler.Remove((Preset)treeView_presets.SelectedNode.Tag);\r
}\r
- treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
+\r
+ this.LoadPresetPanel();\r
}\r
\r
treeView_presets.Select();\r
+ treeView_presets.ExpandAll();\r
}\r
\r
private void MnuSetDefaultPreset_Click(object sender, EventArgs e)\r
{\r
if (treeView_presets.SelectedNode != null)\r
{\r
- this.userSettingService.SetUserSetting(UserSettingConstants.DefaultPreset, treeView_presets.SelectedNode.Text);\r
- MessageBox.Show("New default preset set: " + treeView_presets.SelectedNode.Text, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+ Preset preset = treeView_presets.SelectedNode.Tag as Preset;\r
+ if (preset != null)\r
+ {\r
+ MessageBox.Show(\r
+ "New default preset set: " + treeView_presets.SelectedNode.Text,\r
+ "Alert",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Information);\r
+ this.presetHandler.SetDefault(preset);\r
+ }\r
}\r
else\r
MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
text_destination.Text = autoPath;\r
else\r
MessageBox.Show(\r
- "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')",\r
+ "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')",\r
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
\r