+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
-using System.Windows.Forms;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
-using System.Diagnostics;\r
-\r
-namespace Handbrake.Functions\r
-{\r
- public class Presets\r
- {\r
- List<string> presets = new List<string>();\r
- List<string> user_presets = new List<string>();\r
-\r
- /// <summary>\r
- /// Add a new preset to the system\r
- /// </summary>\r
- /// <param name="presetName">String, The name of the new preset</param>\r
- /// <param name="query">String, the CLI query for the new preset</param>\r
- public Boolean addPreset(string presetName, string query)\r
- {\r
- if (checkIfPresetExists(presetName) == false)\r
- {\r
- String preset = "+ " + presetName + ": " + query;\r
- user_presets.Add(preset);\r
- addPresetToFile(preset);\r
- return true;\r
- }\r
- else\r
- {\r
- MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- return false;\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Remove a preset with a given name from either the built in or user preset list.\r
- /// </summary>\r
- /// <param name="name">String, the preset name</param>\r
- public void remove(string name)\r
- {\r
- List<string> newPresets = new List<string>();\r
- List<string> newUserPresets = new List<string>();\r
-\r
- // Built In Presets\r
- foreach (string item in presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] != name)\r
- newPresets.Add(item);\r
- }\r
-\r
- // User Presets\r
- foreach (string item in user_presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] != name)\r
- newUserPresets.Add(item);\r
- }\r
-\r
- // Now, Update the presets.dat and user_presets.dat file with the new items.\r
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";\r
- string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";\r
-\r
- // Rebuild the presets.dat file\r
- StreamWriter line = new StreamWriter(presetsFile);\r
- foreach (string item in newPresets)\r
- {\r
- line.WriteLine("+ " + item);\r
- }\r
- line.Close();\r
- line.Dispose();\r
-\r
- // Rebuild the user_presets.dat file\r
- line = new StreamWriter(userPresets);\r
- foreach (string item in newUserPresets)\r
- {\r
- line.WriteLine("+ " + item);\r
- }\r
- line.Close();\r
- line.Dispose();\r
- }\r
-\r
- /// <summary>\r
- /// Get a List of all the built in preset names.\r
- /// </summary>\r
- /// <returns>List<String> of preset names</returns>\r
- public List<string> getBuildInPresetNames()\r
- {\r
- List<string> names = new List<string>();\r
-\r
- // Built In Presets\r
- foreach (string item in presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- names.Add(presetName[0]);\r
-\r
- }\r
- return names;\r
- }\r
-\r
- /// <summary>\r
- /// Get a List of all the User preset names.\r
- /// </summary>\r
- /// <returns>List<String> of preset names</returns>\r
- public List<string> getUserPresetNames()\r
- {\r
- List<string> names = new List<string>();\r
-\r
- // User Presets\r
- foreach (string item in user_presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )");\r
- string[] presetName = r.Split(x);\r
- names.Add(presetName[0]);\r
-\r
- }\r
-\r
- return names;\r
- }\r
-\r
- /// <summary>\r
- /// Return the CLI query for a preset name given in name\r
- /// </summary>\r
- /// <param name="name">String, The preset's name</param>\r
- /// <returns>String, the CLI query for the given preset name</returns>\r
- public string getCliForPreset(string name)\r
- {\r
- // Built In Presets\r
- foreach (string item in presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] == name)\r
- return presetName[2];\r
- }\r
-\r
- // User Presets\r
- foreach (string item in user_presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] == name)\r
- return presetName[2];\r
- }\r
-\r
- return null;\r
- }\r
-\r
- /// <summary>\r
- /// Update the presets.dat file with the latest version of HandBrake's presets from the CLI\r
- /// </summary>\r
- public void grabCLIPresets()\r
- {\r
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
- string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");\r
-\r
- string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
-\r
- ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
- hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
-\r
- Process hbproc = Process.Start(hbGetPresets);\r
- hbproc.WaitForExit();\r
- hbproc.Dispose();\r
- hbproc.Close();\r
- }\r
-\r
- /// <summary>\r
- /// Load in the preset data from presets.dat and user_presets.dat\r
- /// Load it into the 2 arraylist's presets and user_presets\r
- /// </summary>\r
- public void loadPresetFiles()\r
- {\r
- // First clear the presets arraylists\r
- presets.Clear();\r
- user_presets.Clear();\r
-\r
- // Load in the built in presets from presets.dat\r
- // We'll store them in the array in the format: presetName: ClI Query\r
- string filePath = Application.StartupPath.ToString() + "\\presets.dat";\r
- if (File.Exists(filePath))\r
- {\r
- StreamReader presetInput = new StreamReader(filePath);\r
- while (!presetInput.EndOfStream)\r
- {\r
- string line = presetInput.ReadLine();\r
-\r
- if (line.Contains("+"))\r
- presets.Add(line.Replace("+ ", "").Trim());\r
- }\r
- presetInput.Close();\r
- presetInput.Dispose();\r
- }\r
-\r
- // Load in the users presets from user_presets.dat\r
- filePath = Application.StartupPath.ToString() + "\\user_presets.dat";\r
- if (File.Exists(filePath))\r
- {\r
- StreamReader presetInput = new StreamReader(filePath);\r
- while (!presetInput.EndOfStream)\r
- {\r
- if ((char)presetInput.Peek() == '+')\r
- user_presets.Add(presetInput.ReadLine().Replace("+ ", ""));\r
- else\r
- presetInput.ReadLine();\r
- }\r
- presetInput.Close();\r
- presetInput.Dispose();\r
- }\r
- }\r
-\r
- // Add a single preset to user_presets.dat\r
- private void addPresetToFile(string preset)\r
- {\r
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";\r
- try\r
- {\r
- // Create a StreamWriter and open the file\r
- StreamWriter line = File.AppendText(userPresets);\r
-\r
- // Generate and write the preset string to the file\r
- line.WriteLine(preset);\r
-\r
- // close the stream\r
- line.Close();\r
- line.Dispose();\r
- }\r
- catch (Exception exc)\r
- {\r
- MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
- }\r
- }\r
-\r
- // Check if a preset already exists in either the built in or user presets\r
- private Boolean checkIfPresetExists(string name)\r
- {\r
- if (name == string.Empty)\r
- return true;\r
-\r
- // Built In Presets\r
- foreach (string item in presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] == name)\r
- return true;\r
- }\r
-\r
- // User Presets\r
- foreach (string item in user_presets)\r
- {\r
- string x = item.Replace("+ ", "");\r
- Regex r = new Regex("(: )"); // Split on hyphens. \r
- string[] presetName = r.Split(x);\r
- if (presetName[0] == name)\r
- return true;\r
- }\r
-\r
- return false;\r
- }\r
- }\r
-\r
-}
\ No newline at end of file
<Compile Include="frmMain\QueryGenerator.cs" />\r
<Compile Include="Functions\SystemInfo.cs" />\r
<Compile Include="Functions\Main.cs" />\r
- <Compile Include="Functions\Presets.cs" />\r
+ <Compile Include="Presets\preset.cs" />\r
+ <Compile Include="Presets\PresetsHandler.cs" />\r
<Compile Include="Functions\Queue.cs" />\r
<Compile Include="Functions\AppcastReader.cs" />\r
<Compile Include="Functions\Encode.cs" />\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+using System.IO;\r
+using System.Text.RegularExpressions;\r
+using System.Diagnostics;\r
+using System.Xml.Serialization;\r
+\r
+namespace Handbrake.Presets\r
+{\r
+ public class PresetsHandler\r
+ {\r
+ List<Preset> presets = new List<Preset>(); // Category+Level+Preset Name: Query\r
+ List<Preset> user_presets = new List<Preset>(); // Preset Name: Query\r
+ private static XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));\r
+\r
+ /// <summary>\r
+ /// Add a new preset to the system\r
+ /// </summary>\r
+ /// <param name="presetName">String, The name of the new preset</param>\r
+ /// <param name="query">String, the CLI query for the new preset</param>\r
+ public Boolean addPreset(string presetName, string query)\r
+ {\r
+ if (checkIfPresetExists(presetName) == false)\r
+ {\r
+ Preset newPreset = new Preset();\r
+ newPreset.Name = presetName;\r
+ newPreset.Query = query;\r
+ user_presets.Add(newPreset);\r
+ updateUserPresetsFile();\r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ return false;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Remove a preset with a given name from either the built in or user preset list.\r
+ /// </summary>\r
+ /// <param name="name">String, the preset name</param>\r
+ public void remove(string name)\r
+ {\r
+ List<Preset> newPresets = new List<Preset>();\r
+ List<Preset> newUserPresets = new List<Preset>();\r
+\r
+ // Built In Presets\r
+ foreach (Preset item in presets)\r
+ {\r
+ if (item.Name != name)\r
+ {\r
+ newPresets.Add(item);\r
+ }\r
+ }\r
+ presets = newPresets;\r
+\r
+ // User Presets\r
+ foreach (Preset item in user_presets)\r
+ {\r
+ if (item.Name != name)\r
+ {\r
+ newUserPresets.Add(item);\r
+ }\r
+ }\r
+ user_presets = newUserPresets;\r
+\r
+ // Now, Update the presets.xml and user_presets.xml file with the new items.\r
+ string userPresets = Application.StartupPath.ToString() + "\\user_presets.xml";\r
+ string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";\r
+\r
+ // Rebuild the user_presets.xml file\r
+ updateUserPresetsFile();\r
+ updatePresetsFile();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get a List of all the built in preset names.\r
+ /// </summary>\r
+ /// <returns>List<String> of preset names</returns>\r
+ public List<Preset> getBuildInPresets()\r
+ {\r
+ return presets;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get a List of all the User preset names.\r
+ /// </summary>\r
+ /// <returns>List<String> of preset names</returns>\r
+ public List<string> getUserPresetNames()\r
+ {\r
+ List<string> names = new List<string>();\r
+\r
+ // User Presets\r
+ foreach (Preset item in user_presets)\r
+ {\r
+ names.Add(item.Name);\r
+ }\r
+\r
+ return names;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Return the CLI query for a preset name given in name\r
+ /// </summary>\r
+ /// <param name="name">String, The preset's name</param>\r
+ /// <returns>String, the CLI query for the given preset name</returns>\r
+ public string getCliForPreset(string name)\r
+ {\r
+ // Built In Presets\r
+ foreach (Preset item in presets)\r
+ {\r
+ if (item.Name == name)\r
+ return item.Query;\r
+ }\r
+\r
+ // User Presets\r
+ foreach (Preset item in user_presets)\r
+ {\r
+ if (item.Name == name)\r
+ return item.Query;\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Reads the CLI's CLI output format and load's them into the preset List<Preset>\r
+ /// </summary>\r
+ public void updateBuiltInPresets()\r
+ {\r
+ // Create a new tempory file and execute the CLI to get the built in presets.\r
+ string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
+ string presetsPath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");\r
+\r
+ string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
+\r
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
+ hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
+\r
+ Process hbproc = Process.Start(hbGetPresets);\r
+ hbproc.WaitForExit();\r
+ hbproc.Dispose();\r
+ hbproc.Close();\r
+\r
+ // Clear the current built in presets and now parse the tempory presets file.\r
+ presets.Clear();\r
+ string filePath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");\r
+ if (File.Exists(filePath))\r
+ {\r
+ StreamReader presetInput = new StreamReader(filePath);\r
+ int level = 1;\r
+ string category = String.Empty;\r
+ string level_1_category = String.Empty;\r
+\r
+ while (!presetInput.EndOfStream)\r
+ {\r
+ string line = presetInput.ReadLine();\r
+ if (line.Contains("<") && !line.Contains("<<"))\r
+ {\r
+ level = 1;\r
+ category = line.Replace("<", "").Trim();\r
+ level_1_category = category;\r
+ }\r
+\r
+ if (line.Contains("<<"))\r
+ {\r
+ level = 2;\r
+ category = line.Replace("<<", "").Trim();\r
+ }\r
+\r
+ if (line.Trim().Contains(">>"))\r
+ {\r
+ level = 1;\r
+ category = level_1_category;\r
+ }\r
+\r
+ if (line.Contains("+"))\r
+ {\r
+ Regex r = new Regex("(: )"); // Split on hyphens. \r
+ string[] presetName = r.Split(line);\r
+\r
+ Preset newPreset = new Preset();\r
+ newPreset.Level = level;\r
+ newPreset.Category = category;\r
+ newPreset.Name = presetName[0].Replace("+", "").Trim();\r
+ newPreset.Query = presetName[2];\r
+ presets.Add(newPreset);\r
+ }\r
+ }\r
+ presetInput.Close();\r
+ presetInput.Dispose();\r
+ }\r
+\r
+ // Finally, Create a new or update the current presets.xml file\r
+ updatePresetsFile();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Load in the preset data from presets.xml and user_presets.xml\r
+ /// Load it into the 2 arraylist's presets and user_presets\r
+ /// </summary>\r
+ public void loadPresetData()\r
+ {\r
+ // First clear the presets arraylists\r
+ presets.Clear();\r
+ user_presets.Clear();\r
+\r
+ string filePath = string.Empty;\r
+\r
+ // Load in the users presets from user_presets.xml\r
+ filePath = Application.StartupPath.ToString() + "\\presets.xml";\r
+ if (File.Exists(filePath))\r
+ {\r
+ using (FileStream strm = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r
+ {\r
+ if (strm.Length != 0)\r
+ {\r
+ List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
+\r
+ foreach (Preset preset in list)\r
+ presets.Add(preset);\r
+ }\r
+ }\r
+ }\r
+\r
+ // Load in the users presets from user_presets.xml\r
+ filePath = Application.StartupPath.ToString() + "\\user_presets.xml";\r
+ if (File.Exists(filePath))\r
+ {\r
+ using (FileStream strm = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r
+ {\r
+ if (strm.Length != 0)\r
+ {\r
+ List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
+\r
+ foreach (Preset preset in list)\r
+ user_presets.Add(preset);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Updates the presets.xml file which contains the built in presets\r
+ /// It takes the List of Presets and converts them into XML which is stored in presets.xml\r
+ /// </summary>\r
+ private void updatePresetsFile()\r
+ {\r
+ string userPresets = Application.StartupPath.ToString() + "\\presets.xml";\r
+ try\r
+ {\r
+ using (FileStream strm = new FileStream(userPresets, FileMode.Create, FileAccess.Write))\r
+ {\r
+ ser.Serialize(strm, presets);\r
+ strm.Close();\r
+ strm.Dispose();\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Updates the user_presets.xml file which contains the built in presets\r
+ /// It takes the List of Presets and converts them into XML which is stored in user_presets.xml\r
+ /// </summary>\r
+ private void updateUserPresetsFile()\r
+ {\r
+ string userPresets = Application.StartupPath.ToString() + "\\user_presets.xml";\r
+ try\r
+ {\r
+ using (FileStream strm = new FileStream(userPresets, FileMode.Create, FileAccess.Write))\r
+ {\r
+ ser.Serialize(strm, user_presets);\r
+ strm.Close();\r
+ strm.Dispose();\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Check if the preset "name" exists in either presets or user_presets lists.\r
+ /// </summary>\r
+ /// <param name="name"></param>\r
+ /// <returns></returns>\r
+ private Boolean checkIfPresetExists(string name)\r
+ {\r
+ if (name == string.Empty)\r
+ return true;\r
+\r
+ // Built In Presets\r
+ foreach (Preset item in presets)\r
+ {\r
+ if (item.Name == name)\r
+ return true;\r
+ }\r
+\r
+ // User Presets\r
+ foreach (Preset item in user_presets)\r
+ {\r
+ if (item.Name == name)\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+using System.IO;\r
+using System.Text.RegularExpressions;\r
+using System.Diagnostics;\r
+\r
+namespace Handbrake.Presets\r
+{\r
+ public class Preset\r
+ {\r
+\r
+ private int level = 0;\r
+ private string category = null;\r
+ private string name;\r
+ private string query;\r
+\r
+ public Preset()\r
+ {\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get or Set the preset's level. This indicated if it is a root or child node\r
+ /// </summary>\r
+ public int Level\r
+ {\r
+ get { return level; }\r
+ set { this.level = value; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get or Set the category which the preset resides under\r
+ /// </summary>\r
+ public string Category\r
+ {\r
+ get { return category; }\r
+ set { this.category = value; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get or Set the preset name\r
+ /// </summary>\r
+ public string Name\r
+ {\r
+ get { return name; }\r
+ set { this.name = value; }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get or set the preset query\r
+ /// </summary>\r
+ public string Query\r
+ {\r
+ get { return query; }\r
+ set { this.query = value; }\r
+ }\r
+\r
+ }\r
+}
\ No newline at end of file
public partial class frmAddPreset : Form\r
{\r
private frmMain frmMainWindow;\r
- Functions.Presets presetCode;\r
+ Presets.PresetsHandler presetCode;\r
private string query = "";\r
- \r
- public frmAddPreset(frmMain fmw, string query_string, Functions.Presets presetHandler)\r
+\r
+ public frmAddPreset(frmMain fmw, string query_string, Presets.PresetsHandler presetHandler)\r
{\r
InitializeComponent();\r
frmMainWindow = fmw;\r
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);\r
this.StatusStrip = new System.Windows.Forms.StatusStrip();\r
this.lbl_encode = new System.Windows.Forms.ToolStripStatusLabel();\r
+ this.presets_menu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+ this.pmnu_delete = new System.Windows.Forms.ToolStripMenuItem();\r
+ this.pmnu_expandAll = new System.Windows.Forms.ToolStripMenuItem();\r
+ this.sep1 = new System.Windows.Forms.ToolStripSeparator();\r
+ this.pmnu_collapse = new System.Windows.Forms.ToolStripMenuItem();\r
Label38 = new System.Windows.Forms.Label();\r
notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
notifyIconMenu.SuspendLayout();\r
this.groupBox2.SuspendLayout();\r
this.toolStrip1.SuspendLayout();\r
this.StatusStrip.SuspendLayout();\r
+ this.presets_menu.SuspendLayout();\r
this.SuspendLayout();\r
// \r
// Label38\r
this.btn_restore});\r
notifyIconMenu.Name = "notifyIconMenu";\r
notifyIconMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
- notifyIconMenu.Size = new System.Drawing.Size(129, 26);\r
+ notifyIconMenu.Size = new System.Drawing.Size(153, 48);\r
// \r
// btn_restore\r
// \r
this.btn_restore.Name = "btn_restore";\r
- this.btn_restore.Size = new System.Drawing.Size(128, 22);\r
+ this.btn_restore.Size = new System.Drawing.Size(152, 22);\r
this.btn_restore.Text = "Restore";\r
this.btn_restore.Click += new System.EventHandler(this.btn_restore_Click);\r
// \r
this.btn_setDefault.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
this.btn_setDefault.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.btn_setDefault.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
- this.btn_setDefault.Location = new System.Drawing.Point(115, 508);\r
+ this.btn_setDefault.Location = new System.Drawing.Point(873, 584);\r
this.btn_setDefault.Name = "btn_setDefault";\r
this.btn_setDefault.Size = new System.Drawing.Size(72, 22);\r
this.btn_setDefault.TabIndex = 1;\r
this.btn_addPreset.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
this.btn_addPreset.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.btn_addPreset.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
- this.btn_addPreset.Location = new System.Drawing.Point(10, 508);\r
+ this.btn_addPreset.Location = new System.Drawing.Point(768, 584);\r
this.btn_addPreset.Name = "btn_addPreset";\r
this.btn_addPreset.Size = new System.Drawing.Size(35, 22);\r
this.btn_addPreset.TabIndex = 3;\r
this.btn_removePreset.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
this.btn_removePreset.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.btn_removePreset.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
- this.btn_removePreset.Location = new System.Drawing.Point(51, 508);\r
+ this.btn_removePreset.Location = new System.Drawing.Point(809, 584);\r
this.btn_removePreset.Name = "btn_removePreset";\r
this.btn_removePreset.Size = new System.Drawing.Size(58, 22);\r
this.btn_removePreset.TabIndex = 4;\r
this.HelpToolStripMenuItem});\r
this.frmMainMenu.Location = new System.Drawing.Point(0, 0);\r
this.frmMainMenu.Name = "frmMainMenu";\r
- this.frmMainMenu.Size = new System.Drawing.Size(958, 24);\r
+ this.frmMainMenu.Size = new System.Drawing.Size(985, 24);\r
this.frmMainMenu.TabIndex = 0;\r
this.frmMainMenu.Text = "MenuStrip1";\r
// \r
// \r
// groupBox2\r
// \r
- this.groupBox2.Controls.Add(this.btn_removePreset);\r
- this.groupBox2.Controls.Add(this.btn_addPreset);\r
this.groupBox2.Controls.Add(this.treeView_presets);\r
- this.groupBox2.Controls.Add(this.btn_setDefault);\r
this.groupBox2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.groupBox2.ForeColor = System.Drawing.Color.Black;\r
this.groupBox2.Location = new System.Drawing.Point(728, 70);\r
this.groupBox2.Name = "groupBox2";\r
- this.groupBox2.Size = new System.Drawing.Size(218, 546);\r
+ this.groupBox2.Size = new System.Drawing.Size(245, 508);\r
this.groupBox2.TabIndex = 6;\r
this.groupBox2.TabStop = false;\r
this.groupBox2.Text = "Presets";\r
// \r
// treeView_presets\r
// \r
+ this.treeView_presets.ContextMenuStrip = this.presets_menu;\r
+ this.treeView_presets.Dock = System.Windows.Forms.DockStyle.Fill;\r
this.treeView_presets.ForeColor = System.Drawing.Color.DarkBlue;\r
this.treeView_presets.FullRowSelect = true;\r
this.treeView_presets.HideSelection = false;\r
this.treeView_presets.ItemHeight = 21;\r
- this.treeView_presets.Location = new System.Drawing.Point(10, 23);\r
+ this.treeView_presets.Location = new System.Drawing.Point(3, 17);\r
this.treeView_presets.Name = "treeView_presets";\r
this.treeView_presets.ShowLines = false;\r
- this.treeView_presets.Size = new System.Drawing.Size(198, 473);\r
+ this.treeView_presets.Size = new System.Drawing.Size(239, 488);\r
this.treeView_presets.TabIndex = 0;\r
this.treeView_presets.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_presets_AfterSelect);\r
this.treeView_presets.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeView_presets_deleteKey);\r
this.toolStrip1.Location = new System.Drawing.Point(0, 24);\r
this.toolStrip1.Name = "toolStrip1";\r
this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;\r
- this.toolStrip1.Size = new System.Drawing.Size(958, 39);\r
+ this.toolStrip1.Size = new System.Drawing.Size(985, 39);\r
this.toolStrip1.TabIndex = 1;\r
this.toolStrip1.Text = "toolStrip1";\r
// \r
this.lbl_encode});\r
this.StatusStrip.Location = new System.Drawing.Point(0, 629);\r
this.StatusStrip.Name = "StatusStrip";\r
- this.StatusStrip.Size = new System.Drawing.Size(958, 22);\r
+ this.StatusStrip.Size = new System.Drawing.Size(985, 22);\r
this.StatusStrip.TabIndex = 7;\r
this.StatusStrip.Text = "statusStrip1";\r
// \r
this.lbl_encode.Size = new System.Drawing.Size(31, 17);\r
this.lbl_encode.Text = "{0}";\r
// \r
+ // presets_menu\r
+ // \r
+ this.presets_menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+ this.pmnu_expandAll,\r
+ this.pmnu_collapse,\r
+ this.sep1,\r
+ this.pmnu_delete});\r
+ this.presets_menu.Name = "presets_menu";\r
+ this.presets_menu.Size = new System.Drawing.Size(146, 76);\r
+ // \r
+ // pmnu_delete\r
+ // \r
+ this.pmnu_delete.Name = "pmnu_delete";\r
+ this.pmnu_delete.Size = new System.Drawing.Size(145, 22);\r
+ this.pmnu_delete.Text = "Delete";\r
+ this.pmnu_delete.Click += new System.EventHandler(this.pmnu_delete_Click);\r
+ // \r
+ // pmnu_expandAll\r
+ // \r
+ this.pmnu_expandAll.Name = "pmnu_expandAll";\r
+ this.pmnu_expandAll.Size = new System.Drawing.Size(145, 22);\r
+ this.pmnu_expandAll.Text = "Expand All";\r
+ this.pmnu_expandAll.Click += new System.EventHandler(this.pmnu_expandAll_Click);\r
+ // \r
+ // sep1\r
+ // \r
+ this.sep1.Name = "sep1";\r
+ this.sep1.Size = new System.Drawing.Size(142, 6);\r
+ // \r
+ // pmnu_collapse\r
+ // \r
+ this.pmnu_collapse.Name = "pmnu_collapse";\r
+ this.pmnu_collapse.Size = new System.Drawing.Size(145, 22);\r
+ this.pmnu_collapse.Text = "Collapse All";\r
+ this.pmnu_collapse.Click += new System.EventHandler(this.pmnu_collapse_Click);\r
+ // \r
// frmMain\r
// \r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
- this.ClientSize = new System.Drawing.Size(958, 651);\r
+ this.ClientSize = new System.Drawing.Size(985, 651);\r
+ this.Controls.Add(this.btn_setDefault);\r
this.Controls.Add(this.GroupBox1);\r
+ this.Controls.Add(this.btn_removePreset);\r
this.Controls.Add(this.groupBox_dest);\r
+ this.Controls.Add(this.btn_addPreset);\r
this.Controls.Add(this.groupBox_output);\r
this.Controls.Add(this.groupBox2);\r
this.Controls.Add(this.toolStrip1);\r
this.toolStrip1.PerformLayout();\r
this.StatusStrip.ResumeLayout(false);\r
this.StatusStrip.PerformLayout();\r
+ this.presets_menu.ResumeLayout(false);\r
this.ResumeLayout(false);\r
this.PerformLayout();\r
\r
internal System.Windows.Forms.OpenFileDialog ISO_Open;\r
internal System.Windows.Forms.FolderBrowserDialog DVD_Open;\r
internal System.Windows.Forms.ToolStripMenuItem mnu_dvd_drive;\r
+ private System.Windows.Forms.ContextMenuStrip presets_menu;\r
+ private System.Windows.Forms.ToolStripMenuItem pmnu_expandAll;\r
+ private System.Windows.Forms.ToolStripMenuItem pmnu_collapse;\r
+ private System.Windows.Forms.ToolStripSeparator sep1;\r
+ private System.Windows.Forms.ToolStripMenuItem pmnu_delete;\r
\r
}\r
}
\ No newline at end of file
Functions.Main hb_common_func = new Functions.Main();\r
Functions.Encode cliObj = new Functions.Encode();\r
Functions.Queue encodeQueue = new Functions.Queue();\r
- Functions.Presets presetHandler = new Functions.Presets();\r
+ Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();\r
Parsing.Title selectedTitle;\r
\r
// Objects belonging to this window only\r
\r
#endregion\r
\r
- // The Applications Main Menu *****************************************\r
+ // The Applications Main Menu and Menus *******************************\r
\r
#region File Menu\r
private void mnu_exit_Click(object sender, EventArgs e)\r
#region Presets Menu\r
private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
- presetHandler.grabCLIPresets();\r
+ presetHandler.updateBuiltInPresets();\r
loadPresetPanel();\r
if (treeView_presets.Nodes.Count == 0)\r
MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
{\r
// Empty the preset file\r
string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";\r
- StreamWriter line = new StreamWriter(presetsFile);\r
- line.WriteLine("");\r
- line.Close();\r
- line.Dispose();\r
+ if (File.Exists(presetsFile))\r
+ File.Delete(presetsFile);\r
+\r
+ try\r
+ {\r
+ FileStream strm = new FileStream(presetsFile, FileMode.Create, FileAccess.Write);\r
+ strm.Close();\r
+ strm.Dispose();\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc.ToString());\r
+ }\r
\r
// Reload the preset panel\r
loadPresetPanel();\r
}\r
#endregion\r
\r
+ #region Preset Menu\r
+ private void pmnu_expandAll_Click(object sender, EventArgs e)\r
+ {\r
+ treeView_presets.ExpandAll();\r
+ }\r
+ private void pmnu_collapse_Click(object sender, EventArgs e)\r
+ {\r
+ treeView_presets.CollapseAll();\r
+ }\r
+ private void pmnu_delete_Click(object sender, EventArgs e)\r
+ {\r
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ if (result == DialogResult.Yes)\r
+ {\r
+ if (treeView_presets.SelectedNode != null)\r
+ presetHandler.remove(treeView_presets.SelectedNode.Text);\r
+ // Now reload the preset panel\r
+ loadPresetPanel();\r
+ }\r
+ treeView_presets.Select();\r
+ }\r
+ #endregion\r
+\r
+\r
// MainWindow Components, Actions and Functions ***********************\r
\r
#region Actions\r
\r
// Run the Autonaming function\r
if (Properties.Settings.Default.autoNaming == "Checked")\r
- text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+ text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
}\r
\r
//Destination\r
{\r
if (drp_anamorphic.Text == "None")\r
{\r
- int height = hb_common_func.cacluateNonAnamorphicHeight(width, text_top.Value, text_bottom.Value,text_left.Value, text_right.Value, selectedTitle);\r
+ int height = hb_common_func.cacluateNonAnamorphicHeight(width, text_top.Value, text_bottom.Value, text_left.Value, text_right.Value, selectedTitle);\r
text_height.Text = height.ToString();\r
}\r
}\r
string presetName = treeView_presets.SelectedNode.Text;\r
string query = presetHandler.getCliForPreset(presetName);\r
\r
- //Ok, Reset all the H264 widgets before changing the preset\r
- x264PanelFunctions.reset2Defaults(this);\r
+ if (query != null)\r
+ {\r
+ //Ok, Reset all the H264 widgets before changing the preset\r
+ x264PanelFunctions.reset2Defaults(this);\r
\r
- // Send the query from the file to the Query Parser class\r
- Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);\r
+ // Send the query from the file to the Query Parser class\r
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);\r
\r
- // Now load the preset\r
- presetLoader.presetLoader(this, presetQuery, presetName);\r
+ // Now load the preset\r
+ presetLoader.presetLoader(this, presetQuery, presetName);\r
\r
- // The x264 widgets will need updated, so do this now:\r
- x264PanelFunctions.X264_StandardizeOptString(this);\r
- x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
+ // The x264 widgets will need updated, so do this now:\r
+ x264PanelFunctions.X264_StandardizeOptString(this);\r
+ x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
+ }\r
}\r
private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
{\r
}\r
}\r
#endregion\r
- \r
+\r
#region Drive Detection\r
// Source Button Drive Detection\r
private delegate void ProgressUpdateHandler();\r
this.thisDVD = dvd;\r
}\r
\r
-\r
/// <summary>\r
/// Reload the preset panel display\r
/// </summary>\r
public void loadPresetPanel()\r
{\r
- presetHandler.loadPresetFiles();\r
+ presetHandler.loadPresetData();\r
\r
treeView_presets.Nodes.Clear();\r
- List<string> presetNameList = new List<string>();\r
+\r
+ List<Presets.Preset> presetNameList = new List<Presets.Preset>();\r
+ List<string> presetNames = new List<string>();\r
TreeNode preset_treeview = new TreeNode();\r
\r
- presetNameList = presetHandler.getBuildInPresetNames();\r
- foreach (string preset in presetNameList)\r
+ TreeNode rootNode = new TreeNode();\r
+ TreeNode rootNodeTwo = new TreeNode();\r
+ TreeNode childNode = new TreeNode();\r
+ int workingLevel = 0;\r
+ string previousCategory = String.Empty;\r
+ string currentCategory = String.Empty;\r
+\r
+ presetNameList = presetHandler.getBuildInPresets();\r
+ if (presetNameList.Count != 0)\r
{\r
- preset_treeview = new TreeNode(preset);\r
+ foreach (Presets.Preset preset in presetNameList)\r
+ {\r
+ // Handle Root Nodes\r
\r
- // Now Fill Out List View with Items\r
- treeView_presets.Nodes.Add(preset_treeview);\r
+ // First Case - No presets have been read yet so setup the root category\r
+ if (preset.Level == 1 && currentCategory == String.Empty)\r
+ {\r
+ rootNode = new TreeNode(preset.Category);\r
+ workingLevel = preset.Level;\r
+ currentCategory = preset.Category;\r
+ previousCategory = preset.Category;\r
+ }\r
+\r
+ // Second Case - This is the first sub child node.\r
+ if (preset.Level == 2 && workingLevel == 1 && currentCategory != preset.Category)\r
+ {\r
+ rootNodeTwo = new TreeNode(preset.Category);\r
+ workingLevel = preset.Level;\r
+ currentCategory = preset.Category;\r
+ rootNode.Nodes.Add(rootNodeTwo);\r
+ }\r
+\r
+ // Third Case - Any presets the sub presets detected in the above if statment.\r
+ if (preset.Level == 1 && workingLevel == 2 && previousCategory == preset.Category)\r
+ {\r
+ workingLevel = preset.Level;\r
+ currentCategory = preset.Category;\r
+ }\r
+\r
+ // Fourth Case - We've finished this root node and are onto the next root node.\r
+ if (preset.Level == 1 && workingLevel == 1 && previousCategory != preset.Category)\r
+ {\r
+ treeView_presets.Nodes.Add(rootNode); // Add the finished node\r
+\r
+ rootNode = new TreeNode(preset.Category);\r
+ workingLevel = preset.Level;\r
+ currentCategory = preset.Category;\r
+ previousCategory = preset.Category;\r
+ }\r
+\r
+ // Handle Child Nodes\r
+ // Add First level child nodes to the current root node\r
+ if (preset.Level == 1 && workingLevel == 1 && currentCategory == preset.Category)\r
+ {\r
+ childNode = new TreeNode(preset.Name);\r
+ rootNode.Nodes.Add(childNode);\r
+ }\r
+\r
+ // Add Second level child nodes to the current sub root node\r
+ if (preset.Level == 2 && workingLevel == 2 && currentCategory == preset.Category)\r
+ {\r
+ childNode = new TreeNode(preset.Name);\r
+ rootNodeTwo.Nodes.Add(childNode);\r
+ }\r
+ }\r
+\r
+ // Add the final root node which does not get added above.\r
+ treeView_presets.Nodes.Add(rootNode);\r
}\r
\r
- presetNameList = presetHandler.getUserPresetNames();\r
- foreach (string preset in presetNameList)\r
+\r
+ // User Presets\r
+ presetNames = presetHandler.getUserPresetNames();\r
+ foreach (string preset in presetNames)\r
{\r
preset_treeview = new TreeNode(preset);\r
preset_treeview.ForeColor = Color.Black;\r
<value>False</value>\r
</metadata>\r
<metadata name="notifyIconMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>931, 18</value>\r
+ <value>977, 15</value>\r
</metadata>\r
<metadata name="notifyIconMenu.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
<value>False</value>\r
</metadata>\r
<metadata name="DVD_Save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>529, 18</value>\r
+ <value>556, 15</value>\r
</metadata>\r
<metadata name="File_Save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>633, 18</value>\r
+ <value>664, 15</value>\r
</metadata>\r
<metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
<value>18, 15</value>\r
If you're going to choose between spatial and temporal, spatial is usually better. </value>\r
</data>\r
<metadata name="DVD_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>223, 15</value>\r
+ <value>232, 15</value>\r
</metadata>\r
<metadata name="File_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>430, 18</value>\r
+ <value>450, 15</value>\r
</metadata>\r
<metadata name="ISO_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>329, 15</value>\r
+ <value>343, 15</value>\r
</metadata>\r
<metadata name="frmMainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
<value>106, 15</value>\r
</metadata>\r
+ <metadata name="presets_menu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+ <value>1224, 15</value>\r
+ </metadata>\r
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>731, 18</value>\r
+ <value>767, 15</value>\r
</metadata>\r
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
<data name="btn_dvd_source.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
</value>\r
</data>\r
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>830, 18</value>\r
+ <value>871, 15</value>\r
</metadata>\r
<data name="notifyIcon.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
<value>\r
</value>\r
</data>\r
<metadata name="StatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>1060, 18</value>\r
+ <value>1113, 15</value>\r
</metadata>\r
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
<value>56</value>\r