1 /* frmAddPreset.cs $
\r
3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
8 using System.Collections.Generic;
\r
9 using System.ComponentModel;
\r
11 using System.Drawing;
\r
13 using System.Windows.Forms;
\r
18 public partial class frmAddPreset : Form
\r
20 private frmMain frmMainWindow;
\r
21 public frmAddPreset(frmMain fmw)
\r
23 InitializeComponent();
\r
24 frmMainWindow = fmw;
\r
27 private void btn_add_Click(object sender, EventArgs e)
\r
29 if (txt_preset_name.Text.Trim() == "")
\r
30 MessageBox.Show("You have not entered a name for the preset.","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
31 else if (txt_preset_name.Text.Trim().Contains("--"))
\r
32 MessageBox.Show("The preset name can not contain two dashes '--'","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
35 Functions.Common hb_common_func = new Functions.Common();
\r
37 string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
\r
40 // Create a StreamWriter and open the file
\r
41 StreamWriter line = File.AppendText(userPresets);
\r
43 // Generate and write the preset string to the file
\r
44 String query = hb_common_func.GenerateTheQuery(frmMainWindow);
\r
45 String preset = "+ " + txt_preset_name.Text + ": " + query;
\r
46 line.WriteLine(preset);
\r
51 MessageBox.Show("Your profile has been sucessfully added.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
53 catch (Exception exc)
\r
55 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);
\r
57 frmMainWindow.loadPresetPanel();
\r