- Functions.Common hb_common_func = new Functions.Common();\r
-\r
- Boolean already_exists = false;\r
- foreach (TreeNode treenode in frmMainWindow.treeView_presets.Nodes)\r
- {\r
- if (treenode.ToString().Equals("TreeNode: --" + txt_preset_name.Text))\r
- already_exists = true; \r
- }\r
-\r
- if (already_exists == true)\r
- MessageBox.Show("Sorry, a preset with this name already exists", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- else\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
- String query = hb_common_func.GenerateTheQuery(frmMainWindow);\r
- String preset = "+ " + txt_preset_name.Text + ": " + query;\r
- line.WriteLine(preset);\r
-\r
- // close the stream\r
- line.Close();\r
- line.Dispose();\r
- MessageBox.Show("Your profile has been sucessfully added.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\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" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
- }\r
- frmMainWindow.loadPresetPanel();\r
- this.Close();\r
- }\r