private void button2_Click(object sender, EventArgs e) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); XmlNode node = xmlDoc.SelectSingleNode("/bot_settings/global_settings"); node["command_prefix"].InnerText = command_prefix_box.Text; node["keep_logs"].InnerText = keep_logs_box.Checked.ToString(); node["logs_path"].InnerText = log_folder_box.Text; node["start_with_windows"].InnerText = windows_start_box.Checked.ToString(); node["minimize_to_tray"].InnerText = minimize_to_tray.Checked.ToString(); node["spam_count"].InnerText = spam_count_box.Text; node["spam_threshold"].InnerText = spam_threshold_box.Text; node["spam_timeout"].InnerText = spam_timeout_box.Text; node["max_message_length"].InnerText = max_message_length_box.Text; xmlDoc.Save(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE" + Path.DirectorySeparatorChar + "Microsoft" + Path.DirectorySeparatorChar + "Windows" + Path.DirectorySeparatorChar + "CurrentVersion" + Path.DirectorySeparatorChar + "Run", true); if (windows_start_box.Checked.ToString() == "True") { rkApp.SetValue("IRCBot", "\"" + Application.ExecutablePath.ToString() + "\""); } else { rkApp.DeleteValue("IRCBot", false); } m_parent.update_conf(); this.Close(); }
private void save_server_button_Click(object sender, EventArgs e) { if (server_name_box.Text == "") { MessageBox.Show("A Server must be specified"); } else if (port_box.Text == "") { MessageBox.Show("A port number must be specified"); } else if (bot_name_box.Text == "") { MessageBox.Show("A name must be specified"); } else if (bot_nick_box.Text == "") { MessageBox.Show("A nickname must be specified"); } else { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); XmlNodeList ServerxnList = xmlDoc.SelectNodes("/bot_settings/server_list/server"); foreach (XmlNode xn in ServerxnList) { string tmp_server = xn["server_name"].InnerText; if (tmp_server.Equals(server_name)) { xn["name"].InnerText = bot_name_box.Text; xn["nick"].InnerText = bot_nick_box.Text; xn["sec_nicks"].InnerText = sec_nicks.Text; xn["password"].InnerText = password_box.Text; xn["email"].InnerText = email_box.Text; xn["owner"].InnerText = owner_nicks_box.Text; xn["port"].InnerText = port_box.Text; xn["server_name"].InnerText = server_name_box.Text; xn["chan_list"].InnerText = channels_box.Text; xn["chan_blacklist"].InnerText = channel_blacklist_box.Text; xn["ignore_list"].InnerText = ignore_list_box.Text; xn["user_level"].InnerText = user_level_box.Text; xn["voice_level"].InnerText = voice_level_box.Text; xn["hop_level"].InnerText = hop_level_box.Text; xn["op_level"].InnerText = op_level_box.Text; xn["sop_level"].InnerText = sop_level_box.Text; xn["founder_level"].InnerText = founder_level_box.Text; xn["owner_level"].InnerText = owner_level_box.Text; break; } } xmlDoc.Save(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); XmlNodeList xnList = xmlDocModules.SelectNodes("/modules/module"); foreach (XmlNode xn in xnList) { int element_num = 0; String module_name = xn["name"].InnerText; if (module_list.SelectedItem.Equals(module_name)) { CheckBox myCheckboxEnabled = (CheckBox)module_options.Controls.Find("checkBox_" + module_name + "_enabled", true)[0]; xn["enabled"].InnerText = myCheckboxEnabled.Checked.ToString(); element_num++; xn["blacklist"].InnerText = module_options.Controls.Find("textBox_" + module_name + "_blacklist", true)[0].Text; element_num++; XmlNodeList optionList = xn.ChildNodes; foreach (XmlNode option in optionList) { if (option.Name.Equals("options")) { XmlNodeList Options = option.ChildNodes; foreach (XmlNode options in Options) { switch (options["type"].InnerText) { case "textbox": TextBox myTextBox = (TextBox)module_options.Controls.Find("textBox_" + module_name + "_" + options.Name + "_" + element_num.ToString(), true)[0]; options["value"].InnerText = myTextBox.Text; element_num++; break; case "checkbox": CheckBox myCheckbox = (CheckBox)module_options.Controls.Find("checkBox_" + module_name + "_" + options.Name + "_" + element_num.ToString(), true)[0]; options["checked"].InnerText = myCheckbox.Checked.ToString(); element_num++; break; } } } } } } xmlDocModules.Save(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder + Path.DirectorySeparatorChar + "modules.xml"); m_parent.update_conf(); this.Close(); } }