summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-07-02 19:01:36 +0000
committersr55 <[email protected]>2008-07-02 19:01:36 +0000
commit7dcf52379eb35e0a1553ecb6961b8376833e7603 (patch)
tree1b4a30881079b576f87a4228bde74bd86029182e
parentd4d2fc14259eee2216106049c56f633504de58fc (diff)
WinGui:
- Better implementation of the presets bar. Code moved into it's own class. - Can now Remove Single or delete all built in presets. - User presets are no longer taged with "--" - CLI window no longer appears when grabbing the information for presets.dat from HandBrakeCLI.exe git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1552 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/C#/Functions/CLI.cs13
-rw-r--r--win/C#/Functions/Presets.cs258
-rw-r--r--win/C#/frmAddPreset.cs57
-rw-r--r--win/C#/frmMain.Designer.cs32
-rw-r--r--win/C#/frmMain.cs252
-rw-r--r--win/C#/frmMain.resx6
6 files changed, 359 insertions, 259 deletions
diff --git a/win/C#/Functions/CLI.cs b/win/C#/Functions/CLI.cs
index b0ad57a70..259397af3 100644
--- a/win/C#/Functions/CLI.cs
+++ b/win/C#/Functions/CLI.cs
@@ -116,10 +116,15 @@ namespace Handbrake.Functions
/// </summary>
public void grabCLIPresets()
{
- // Gets the presets from the CLI and stores them in presets.dat
- string appPath = Application.StartupPath.ToString() + "\\";
- string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " --preset-list >" + '"' + appPath + "presets.dat" + '"' + " 2>&1" + '"';
- Process hbproc = Process.Start("CMD.exe", strCmdLine);
+ string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
+ string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");
+
+ string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
+
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);
+ hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;
+
+ Process hbproc = Process.Start(hbGetPresets);
hbproc.WaitForExit();
hbproc.Dispose();
hbproc.Close();
diff --git a/win/C#/Functions/Presets.cs b/win/C#/Functions/Presets.cs
index 213a6ea8b..dda7f12b4 100644
--- a/win/C#/Functions/Presets.cs
+++ b/win/C#/Functions/Presets.cs
@@ -1,15 +1,261 @@
using System;
-using System.Collections.Generic;
+using System.Collections;
using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using System.Text.RegularExpressions;
+
namespace Handbrake.Functions
{
- // This file is going to be used for all the preset stuff, when i get around to switching out to something that works a bit better.
-
- class Presets
+ public class Presets
{
- public void loadPresetPanel(frmMain mainWindow)
+ ArrayList presets = new ArrayList();
+ ArrayList user_presets = new ArrayList();
+
+ /// <summary>
+ /// Add a new preset to the system
+ /// </summary>
+ /// <param name="presetName">String, The name of the new preset</param>
+ /// <param name="query">String, the CLI query for the new preset</param>
+ public Boolean addPreset(string presetName, string query)
+ {
+ if (checkIfPresetExists(presetName) == false)
+ {
+ String preset = "+ " + presetName + ": " + query;
+ user_presets.Add(preset);
+ addPresetToFile(preset);
+ return true;
+ }
+ else
+ {
+ MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Remove a preset with a given name from either the built in or user preset list.
+ /// </summary>
+ /// <param name="name">String, the preset name</param>
+ public void remove(string name)
+ {
+ ArrayList newPresets = new ArrayList();
+ ArrayList newUserPresets = new ArrayList();
+
+ // Built In Presets
+ foreach (string item in presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] != name)
+ newPresets.Add(item);
+ }
+
+ // User Presets
+ foreach (string item in user_presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] != name)
+ newUserPresets.Add(item);
+ }
+
+ // Now, Update the presets.dat and user_presets.dat file with the new items.
+ string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
+ string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";
+
+ // Rebuild the presets.dat file
+ StreamWriter line = new StreamWriter(presetsFile);
+ foreach (string item in newPresets)
+ {
+ line.WriteLine("+ " + item);
+ }
+ line.Close();
+ line.Dispose();
+
+ // Rebuild the user_presets.dat file
+ line = new StreamWriter(userPresets);
+ foreach (string item in newUserPresets)
+ {
+ line.WriteLine("+ " + item);
+ }
+ line.Close();
+ line.Dispose();
+ }
+
+ /// <summary>
+ /// Count the number of presets there are.
+ /// </summary>
+ /// <returns>Integer</returns>
+ public int count()
+ {
+ int c = presets.Count;
+ int d = user_presets.Count;
+
+ return c + d;
+ }
+
+ /// <summary>
+ /// Get an Arraylist of all the preset names.
+ /// Includes both built in and user presets.
+ /// </summary>
+ /// <returns>Arraylist of preset names</returns>
+ public ArrayList getPresetNames()
+ {
+ ArrayList names = new ArrayList();
+
+ // Built In Presets
+ foreach (string item in presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ names.Add(presetName[0]);
+
+ }
+
+ // User Presets
+ foreach (string item in user_presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )");
+ string[] presetName = r.Split(x);
+ names.Add(presetName[0]);
+
+ }
+
+ return names;
+ }
+
+ /// <summary>
+ /// Return the CLI query for a preset name given in name
+ /// </summary>
+ /// <param name="name">String, The preset's name</param>
+ /// <returns>String, the CLI query for the given preset name</returns>
+ public string getCliForPreset(string name)
+ {
+ // Built In Presets
+ foreach (string item in presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] == name)
+ return presetName[2];
+ }
+
+ // User Presets
+ foreach (string item in user_presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] == name)
+ return presetName[2];
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Load in the preset data from presets.dat and user_presets.dat
+ /// Load it into the 2 arraylist's presets and user_presets
+ /// </summary>
+ public void loadPresetFiles()
{
+ // First clear the presets arraylists
+ presets.Clear();
+ user_presets.Clear();
+
+ // Load in the built in presets from presets.dat
+ // We'll store them in the array in the format: presetName: ClI Query
+ string filePath = Application.StartupPath.ToString() + "\\presets.dat";
+ if (File.Exists(filePath))
+ {
+ StreamReader presetInput = new StreamReader(filePath);
+ while (!presetInput.EndOfStream)
+ {
+ if ((char)presetInput.Peek() == '+')
+ presets.Add(presetInput.ReadLine().Replace("+ ", ""));
+ else
+ presetInput.ReadLine();
+ }
+ presetInput.Close();
+ presetInput.Dispose();
+ }
+
+ // Load in the users presets from user_presets.dat
+ filePath = Application.StartupPath.ToString() + "\\user_presets.dat";
+ if (File.Exists(filePath))
+ {
+ StreamReader presetInput = new StreamReader(filePath);
+ while (!presetInput.EndOfStream)
+ {
+ if ((char)presetInput.Peek() == '+')
+ user_presets.Add(presetInput.ReadLine().Replace("+ ", ""));
+ else
+ presetInput.ReadLine();
+ }
+ presetInput.Close();
+ presetInput.Dispose();
+ }
+ }
+
+ // Add a single preset to user_presets.dat
+ private void addPresetToFile(string preset)
+ {
+ string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
+ try
+ {
+ // Create a StreamWriter and open the file
+ StreamWriter line = File.AppendText(userPresets);
+
+ // Generate and write the preset string to the file
+ line.WriteLine(preset);
+
+ // close the stream
+ line.Close();
+ line.Dispose();
+ MessageBox.Show("Your profile has been sucessfully added.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
+ }
+ catch (Exception exc)
+ {
+ 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);
+ }
+
+ }
+
+ // Check if a preset already exists in either the built in or user presets
+ private Boolean checkIfPresetExists(string name)
+ {
+ if (name == "")
+ return true;
+
+ // Built In Presets
+ foreach (string item in presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] == name)
+ return true;
+ }
+
+ // User Presets
+ foreach (string item in user_presets)
+ {
+ string x = item.Replace("+ ", "");
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(x);
+ if (presetName[0] == name)
+ return true;
+ }
+
+ return false;
}
}
-}
+
+} \ No newline at end of file
diff --git a/win/C#/frmAddPreset.cs b/win/C#/frmAddPreset.cs
index 2a24d3331..898b067e7 100644
--- a/win/C#/frmAddPreset.cs
+++ b/win/C#/frmAddPreset.cs
@@ -18,60 +18,25 @@ namespace Handbrake
public partial class frmAddPreset : Form
{
private frmMain frmMainWindow;
- public frmAddPreset(frmMain fmw)
+ Functions.Presets presetCode;
+
+ public frmAddPreset(frmMain fmw, Functions.Presets presetHandler)
{
InitializeComponent();
frmMainWindow = fmw;
+ presetCode = presetHandler;
}
private void btn_add_Click(object sender, EventArgs e)
{
- if (txt_preset_name.Text.Trim() == "")
- MessageBox.Show("You have not entered a name for the preset.","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- else if (txt_preset_name.Text.Trim().Contains("--"))
- MessageBox.Show("The preset name can not contain two dashes '--'","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- else
- {
- Functions.Common hb_common_func = new Functions.Common();
-
- Boolean already_exists = false;
- foreach (TreeNode treenode in frmMainWindow.treeView_presets.Nodes)
- {
- if (treenode.ToString().Equals("TreeNode: --" + txt_preset_name.Text))
- already_exists = true;
- }
-
- if (already_exists == true)
- MessageBox.Show("Sorry, a preset with this name already exists", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- else
- {
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
- try
- {
- // Create a StreamWriter and open the file
- StreamWriter line = File.AppendText(userPresets);
-
- // Generate and write the preset string to the file
- String query = hb_common_func.GenerateTheQuery(frmMainWindow);
- String preset = "+ " + txt_preset_name.Text + ": " + query;
- line.WriteLine(preset);
+ Functions.Common hb_common_func = new Functions.Common();
+ String query = hb_common_func.GenerateTheQuery(frmMainWindow);
- // close the stream
- line.Close();
- line.Dispose();
- MessageBox.Show("Your profile has been sucessfully added.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception exc)
- {
- MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- frmMainWindow.loadPresetPanel();
- this.Close();
- }
+ if (presetCode.addPreset(txt_preset_name.Text.Trim(), query) == true)
+ {
+ frmMainWindow.loadPresetPanel();
+ this.Close();
}
}
}
-}
-
-
-
+} \ No newline at end of file
diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs
index 827114f9e..dcbf40065 100644
--- a/win/C#/frmMain.Designer.cs
+++ b/win/C#/frmMain.Designer.cs
@@ -38,7 +38,7 @@ namespace Handbrake
System.Windows.Forms.Label Label38;
System.Windows.Forms.ContextMenuStrip notifyIconMenu;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.btn_restore = new System.Windows.Forms.ToolStripMenuItem();
this.DVD_Save = new System.Windows.Forms.SaveFileDialog();
this.File_Save = new System.Windows.Forms.SaveFileDialog();
@@ -263,6 +263,8 @@ namespace Handbrake
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.lbl_encode = new System.Windows.Forms.ToolStripLabel();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
+ this.mnu_delete_preset = new System.Windows.Forms.ToolStripMenuItem();
+ this.btn_new_preset = new System.Windows.Forms.ToolStripMenuItem();
Label38 = new System.Windows.Forms.Label();
notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
notifyIconMenu.SuspendLayout();
@@ -647,9 +649,9 @@ namespace Handbrake
//
// number
//
- dataGridViewCellStyle1.Format = "N0";
- dataGridViewCellStyle1.NullValue = null;
- this.number.DefaultCellStyle = dataGridViewCellStyle1;
+ dataGridViewCellStyle2.Format = "N0";
+ dataGridViewCellStyle2.NullValue = null;
+ this.number.DefaultCellStyle = dataGridViewCellStyle2;
this.number.HeaderText = "Chapter Number";
this.number.MaxInputLength = 3;
this.number.Name = "number";
@@ -1092,9 +1094,11 @@ namespace Handbrake
// PresetsToolStripMenuItem
//
this.PresetsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.mnu_SelectDefault,
+ this.mnu_presetReset,
+ this.mnu_delete_preset,
this.toolStripSeparator7,
- this.mnu_presetReset});
+ this.btn_new_preset,
+ this.mnu_SelectDefault});
this.PresetsToolStripMenuItem.Name = "PresetsToolStripMenuItem";
this.PresetsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.PresetsToolStripMenuItem.Text = "&Presets";
@@ -3019,6 +3023,20 @@ namespace Handbrake
this.notifyIcon.Text = "HandBrake";
this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick);
//
+ // mnu_delete_preset
+ //
+ this.mnu_delete_preset.Name = "mnu_delete_preset";
+ this.mnu_delete_preset.Size = new System.Drawing.Size(215, 22);
+ this.mnu_delete_preset.Text = "Delete Built-in Presets";
+ this.mnu_delete_preset.Click += new System.EventHandler(this.mnu_delete_preset_Click);
+ //
+ // btn_new_preset
+ //
+ this.btn_new_preset.Name = "btn_new_preset";
+ this.btn_new_preset.Size = new System.Drawing.Size(215, 22);
+ this.btn_new_preset.Text = "New Preset";
+ this.btn_new_preset.Click += new System.EventHandler(this.btn_new_preset_Click);
+ //
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -3303,6 +3321,8 @@ namespace Handbrake
private System.Windows.Forms.ToolStripMenuItem btn_dvd_source;
private System.Windows.Forms.ToolStripMenuItem btn_file_source;
private System.Windows.Forms.ToolStripLabel lbl_encode;
+ private System.Windows.Forms.ToolStripMenuItem mnu_delete_preset;
+ private System.Windows.Forms.ToolStripMenuItem btn_new_preset;
}
} \ No newline at end of file
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 9f9dcad86..086405df0 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -27,11 +27,12 @@ namespace Handbrake
Functions.CLI cliObj = new Functions.CLI();
Functions.Queue encodeQueue = new Functions.Queue();
Parsing.Title selectedTitle;
+ Functions.Presets presetHandler = new Functions.Presets();
internal Process hbProc;
private Parsing.DVD thisDVD;
private frmQueue queueWindow = new frmQueue();
private delegate void updateStatusChanger();
-
+
// Applicaiton Startup ************************************************
#region Application Startup
@@ -321,7 +322,7 @@ namespace Handbrake
// Close the stream
line.Close();
- Form preset = new frmAddPreset(this);
+ Form preset = new frmAddPreset(this, presetHandler);
preset.ShowDialog();
}
@@ -362,7 +363,6 @@ namespace Handbrake
private void mnu_presetReset_Click(object sender, EventArgs e)
{
- treeView_presets.Nodes.Clear();
cliObj.grabCLIPresets();
loadPresetPanel();
if (treeView_presets.Nodes.Count == 0)
@@ -370,11 +370,27 @@ namespace Handbrake
else
MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
+ private void mnu_delete_preset_Click(object sender, EventArgs e)
+ {
+ // Empty the preset file
+ string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";
+ StreamWriter line = new StreamWriter(presetsFile);
+ line.WriteLine("");
+ line.Close();
+ line.Dispose();
+
+ // Reload the preset panel
+ loadPresetPanel();
+ }
private void mnu_SelectDefault_Click(object sender, EventArgs e)
{
loadNormalPreset();
}
-
+ private void btn_new_preset_Click(object sender, EventArgs e)
+ {
+ Form preset = new frmAddPreset(this, presetHandler);
+ preset.ShowDialog();
+ }
#endregion
#region Help Menu
@@ -519,7 +535,7 @@ namespace Handbrake
}
}
-
+
private void drp_dvdtitle_Click(object sender, EventArgs e)
{
@@ -1427,61 +1443,12 @@ namespace Handbrake
// Presets
private void btn_addPreset_Click(object sender, EventArgs e)
{
- Form preset = new frmAddPreset(this);
+ Form preset = new frmAddPreset(this, presetHandler);
preset.ShowDialog();
}
private void btn_removePreset_Click(object sender, EventArgs e)
{
- ArrayList user_presets = new ArrayList();
- ArrayList modified_presets_list = new ArrayList();
- string selectedPreset = null;
- selectedPreset = treeView_presets.SelectedNode.Text;
-
- if (!selectedPreset.StartsWith("--"))
- MessageBox.Show("Sorry, You can not remove any of the built in presets.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
-
- // Scan through the users presets and dump them all in an arraylist
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
- if (File.Exists(userPresets))
- {
- StreamReader presetInput = new StreamReader(userPresets);
- while (!presetInput.EndOfStream)
- {
- if ((char)presetInput.Peek() == '+')
- {
- string item = presetInput.ReadLine();
- user_presets.Add(item);
- modified_presets_list.Add(item);
- }
- else
- presetInput.ReadLine();
- }
-
- presetInput.Close();
- presetInput.Dispose();
- }
-
- // now lets scan through the arraylist and remove the preset with the
- // same name as the one selected.
- int c = 0;
- foreach (string item in user_presets)
- {
- string preset_name = "+ " + selectedPreset.Replace("--", "").Trim() + ":";
- if (item.Contains(preset_name))
- modified_presets_list.RemoveAt(c);
- c++;
- }
-
- // Now we need to rebuilt the user presets file.
- StreamWriter line = new StreamWriter(userPresets);
- foreach (string item in modified_presets_list)
- {
- line.WriteLine(item);
- }
- line.Close();
- line.Dispose();
-
+ presetHandler.remove(treeView_presets.SelectedNode.Text);
// Now reload the preset panel
loadPresetPanel();
}
@@ -1495,51 +1462,22 @@ namespace Handbrake
}
private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)
{
- //When the user select a preset from the treeview, load it
- try
- {
- // Scan through the built in presets
- string builtInPresets = Application.StartupPath.ToString() + "\\presets.dat";
- if (File.Exists(builtInPresets))
- {
- StreamReader presetInput = new StreamReader(builtInPresets);
- while (!presetInput.EndOfStream)
- {
- if ((char)presetInput.Peek() == '+')
- {
- string preset = presetInput.ReadLine().Replace("+ ", "");
- checkSelectedPreset(preset);
- }
- else
- presetInput.ReadLine();
- }
- presetInput.Close();
- }
+ // Ok, so, we've selected a preset. Now we want to load it.
+ string presetName = treeView_presets.SelectedNode.Text;
+ string query = presetHandler.getCliForPreset(presetName);
- // Scan through the users presets
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
- if (File.Exists(userPresets))
- {
- StreamReader presetInput = new StreamReader(userPresets);
- while (!presetInput.EndOfStream)
- {
- if ((char)presetInput.Peek() == '+')
- {
- string preset = presetInput.ReadLine().Replace("+ ", "");
- checkSelectedPreset(preset);
- }
- else
- presetInput.ReadLine();
- }
+ //Ok, Reset all the H264 widgets before changing the preset
+ x264PanelFunctions.reset2Defaults(this);
- presetInput.Close();
- presetInput.Dispose();
- }
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
+ // Send the query from the file to the Query Parser class
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);
+
+ // Now load the preset
+ hb_common_func.presetLoader(this, presetQuery, presetName);
+
+ // The x264 widgets will need updated, so do this now:
+ x264PanelFunctions.X264_StandardizeOptString(this);
+ x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);
}
#endregion
@@ -1882,116 +1820,37 @@ namespace Handbrake
}
// Preset system functions
- private void addPresetToList(ArrayList presetNameList)
- {
- // Adds a new preset name to the preset list.
- TreeNode preset_treeview = new TreeNode();
- foreach (string[] preset in presetNameList)
- {
- preset_treeview = new TreeNode(preset[0]);
-
- // Now Fill Out List View with Items
- treeView_presets.Nodes.Add(preset_treeview);
- }
- }
private void loadNormalPreset()
{
- //Loads the preset called "normal"
- try
+ // Select the "Normal" preset if it exists.
+ int normal = -1;
+ foreach (TreeNode treenode in treeView_presets.Nodes)
{
- string appPath = Application.StartupPath.ToString() + "\\presets.dat";
- if (File.Exists(appPath))
- {
-
- int normal = 0;
- foreach (TreeNode treenode in treeView_presets.Nodes)
- {
- if (treenode.Text.ToString().Equals("Normal"))
- normal = treenode.Index;
- }
-
- TreeNode np = treeView_presets.Nodes[normal];
-
- treeView_presets.SelectedNode = np;
- }
+ if (treenode.Text.ToString().Equals("Normal"))
+ normal = treenode.Index;
}
- catch (Exception)
+ if (normal != -1)
{
- // Do nothing
+ TreeNode np = treeView_presets.Nodes[normal];
+ treeView_presets.SelectedNode = np;
}
}
public void loadPresetPanel()
{
+ presetHandler.loadPresetFiles();
+
treeView_presets.Nodes.Clear();
ArrayList presetNameList = new ArrayList();
+ presetNameList = presetHandler.getPresetNames();
- // Load in the built in presets from presets.dat
- string filePath = Application.StartupPath.ToString() + "\\presets.dat";
- if (File.Exists(filePath))
- {
- StreamReader presetInput = new StreamReader(filePath);
- while (!presetInput.EndOfStream)
- {
- if ((char)presetInput.Peek() == '+')
- {
- string preset = presetInput.ReadLine().Replace("+ ", "");
- Regex r = new Regex("(: )"); // Split on hyphens.
- presetNameList.Add(r.Split(preset));
- }
- else
- presetInput.ReadLine();
- }
-
- presetInput.Close();
- presetInput.Dispose();
- }
- addPresetToList(presetNameList);
- presetNameList.Clear();
-
- // Load in the users presets from user_presets.dat
- filePath = Application.StartupPath.ToString() + "\\user_presets.dat";
- if (File.Exists(filePath))
- {
- StreamReader presetInput = new StreamReader(filePath);
- while (!presetInput.EndOfStream)
- {
- if ((char)presetInput.Peek() == '+')
- {
- string preset = "--" + presetInput.ReadLine().Replace("+ ", "");
- Regex r = new Regex("(: )"); // Split on hyphens.
- presetNameList.Add(r.Split(preset));
- }
- else
- presetInput.ReadLine();
- }
-
- presetInput.Close();
- presetInput.Dispose();
- }
- addPresetToList(presetNameList);
- }
- private void checkSelectedPreset(string preset)
- {
- string selectedPreset = null;
- selectedPreset = treeView_presets.SelectedNode.Text;
-
- Regex r = new Regex("(: )"); // Split on hyphens.
- string[] presetName = r.Split(preset);
-
- if ((selectedPreset == (presetName[0])) || (selectedPreset == ("--" + presetName[0])))
+ // Adds a new preset name to the preset list.
+ TreeNode preset_treeview = new TreeNode();
+ foreach (string preset in presetNameList)
{
- //Ok, Reset all the H264 widgets before changing the preset
- x264PanelFunctions.reset2Defaults(this);
-
- // Send the query from the file to the Query Parser class
- Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);
-
- // Now load the preset
- hb_common_func.presetLoader(this, presetQuery, selectedPreset);
+ preset_treeview = new TreeNode(preset);
- // The x264 widgets will need updated, so do this now:
- x264PanelFunctions.X264_StandardizeOptString(this);
- x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);
+ // Now Fill Out List View with Items
+ treeView_presets.Nodes.Add(preset_treeview);
}
}
#endregion
@@ -2000,7 +1859,7 @@ namespace Handbrake
// Declarations
private delegate void UpdateUIHandler();
-
+
// Encoding Functions
private void procMonitor(object state)
{
@@ -2084,7 +1943,6 @@ namespace Handbrake
#endregion
-
// This is the END of the road ------------------------------------------------------------------------------
}
} \ No newline at end of file
diff --git a/win/C#/frmMain.resx b/win/C#/frmMain.resx
index bf77a09c5..671471c0b 100644
--- a/win/C#/frmMain.resx
+++ b/win/C#/frmMain.resx
@@ -155,6 +155,12 @@ Make sure you have selected a "Title" from the "Source" box above otherwise
the list will not be populated with the correct amount of chapters.
Note: Do not change any of the chapter numbers!</value>
</data>
+ <metadata name="number.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+ <metadata name="name.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
<metadata name="DVD_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>223, 15</value>
</metadata>