diff options
author | sr55 <[email protected]> | 2008-07-02 19:01:36 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-07-02 19:01:36 +0000 |
commit | 7dcf52379eb35e0a1553ecb6961b8376833e7603 (patch) | |
tree | 1b4a30881079b576f87a4228bde74bd86029182e /win/C#/frmAddPreset.cs | |
parent | d4d2fc14259eee2216106049c56f633504de58fc (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
Diffstat (limited to 'win/C#/frmAddPreset.cs')
-rw-r--r-- | win/C#/frmAddPreset.cs | 57 |
1 files changed, 11 insertions, 46 deletions
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 |