2 using System.Collections.Generic;
\r
3 using System.ComponentModel;
\r
5 using System.Drawing;
\r
7 using System.Windows.Forms;
\r
12 public partial class frmAddPreset : Form
\r
14 private frmMain frmMainWindow;
\r
15 public frmAddPreset(frmMain fmw)
\r
17 InitializeComponent();
\r
18 frmMainWindow = fmw;
\r
21 private void btn_add_Click(object sender, EventArgs e)
\r
23 if (txt_preset_name.Text.Trim() == "")
\r
24 MessageBox.Show("You have not entered a name for the preset.","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
25 else if (txt_preset_name.Text.Trim().Contains("--"))
\r
26 MessageBox.Show("The preset name can not contain two dashes '--'","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
29 Functions.Common hb_common_func = new Functions.Common();
\r
31 string userPresets = Application.StartupPath.ToString() + "\\user_presets.dat";
\r
34 // Create a StreamWriter and open the file
\r
35 StreamWriter line = File.AppendText(userPresets);
\r
37 // Generate and write the preset string to the file
\r
38 String query = hb_common_func.GenerateTheQuery(frmMainWindow);
\r
39 String preset = "+ " + txt_preset_name.Text + ": " + query;
\r
40 line.WriteLine(preset);
\r
45 MessageBox.Show("Your profile has been sucessfully added.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
47 catch (Exception exc)
\r
49 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
51 frmMainWindow.loadPresetPanel();
\r