private void button_add_Click(object sender, EventArgs e) { DialogResult result = Save_function(); if (result == DialogResult.No || result == DialogResult.Yes) { Fctb_data new_function = new Fctb_data(new Guid(), "function", "new_function", "", "", ""); librarys_functions[index_library].functions.Insert(0, new_function); set_list_items(); textBox_name.Text = ""; textBox_name.Focus(); richTextBox_tooltip.Text = ""; fctb.Text = ""; index_function = 0; change_visible(true); for (int i = 0; i < listView_functions.Items.Count; i++) { listView_functions.Items[i].BackColor = Color.Transparent; } listView_functions.Items[index_function].BackColor = Color.Blue; } }
public static void load_functions(string name, string filename) { Library_functions data = null; XmlTextReader reader = null; Fctb_data fctb_data; try { for (int i = 0; i < librarys_functions.Count; i++) { if (librarys_functions[i].pfad == filename) { data = librarys_functions[i]; librarys_functions[i].functions.Clear(); } } if (data == null) { data = new Library_functions(name, filename); } reader = new XmlTextReader(filename); while (reader.Read()) { if (reader.Depth == 2) { fctb_data = new Fctb_data(new Guid()); do { if (reader.Name == "name") { fctb_data.name = reader.ReadElementContentAsString(); } if (reader.Name == "snippet") { fctb_data.snippet = reader.ReadElementContentAsString(); } if (reader.Name == "tooltip") { fctb_data.tooltip = reader.ReadElementContentAsString(); } if (reader.Name == "code") { fctb_data.code = reader.ReadElementContentAsString(); } reader.Read(); }while (reader.Depth > 1); fctb_data.kind = "function"; data.functions.Add(fctb_data); } } librarys_functions.Add(data); } catch (Exception e) { if (reader != null) { MessageBox.Show("Library" + name + "could not be loaded\r" + e.Message); } } finally { reader.Close(); } }