Example #1
0
        private void button_add_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == save.ShowDialog())
            {
                XmlTextWriter xml_writer = new XmlTextWriter(save.FileName, null);
                xml_writer.WriteStartElement("scad");
                xml_writer.WriteEndElement();
                xml_writer.Close();

                string name = Path.GetFileNameWithoutExtension(save.FileName);
                Library_control_class.load_functions(name, save.FileName);
            }
            update_listview();
            Library_control_class.Save_librarys();
        }
Example #2
0
        private void button_load_Click(object sender, EventArgs e)
        {
            bool          load          = true;
            List <string> alrady_loaded = new List <string>();

            if (DialogResult.OK == open.ShowDialog())
            {
                for (int i_load = 0; i_load < open.FileNames.Length; i_load++)
                {
                    string name = Path.GetFileNameWithoutExtension(open.FileNames[i_load]);
                    for (int i_library = 0; i_library < librarys_functions.Count; i_library++)
                    {
                        if (open.FileNames[i_load] == librarys_functions[i_library].pfad)
                        {
                            alrady_loaded.Add("The file " + open.FileNames[i_load] + " alrady loaded");
                            load = false;
                        }
                        else if (name == librarys_functions[i_library].name)
                        {
                            alrady_loaded.Add("The name " + name + " alrady exist");
                            load = false;
                        }
                    }
                    if (load)
                    {
                        Library_control_class.load_functions(name, open.FileName);
                    }
                    load = true;
                }
            }
            if (0 < alrady_loaded.Count)
            {
                string error = alrady_loaded.Count + " librarys could not be loaded\r";
                for (int i = 0; i < alrady_loaded.Count && i < 5; i++)
                {
                    error += alrady_loaded[i] + "\r";
                }
                if (5 < alrady_loaded.Count)
                {
                    error += ".....";
                }
                MessageBox.Show(error);
            }
            update_listview();
            Library_control_class.Save_librarys();
        }
Example #3
0
        private DialogResult Save_function()
        {
            DialogResult result = DialogResult.Yes;

            if (!function_saved)
            {
                //result = MessageBox.Show("Do you want to save the last change?", "Warning", MessageBoxButtons.YesNoCancel);
            }
            if (result == DialogResult.Yes)
            {
                if (0 <= index_function)
                {
                    librarys_functions[index_library].functions[index_function].name    = textBox_name.Text;
                    librarys_functions[index_library].functions[index_function].snippet = textBox_name.Text + "_" + librarys_functions[index_library].name + "(^);";
                    librarys_functions[index_library].functions[index_function].tooltip = richTextBox_tooltip.Text;
                    librarys_functions[index_library].functions[index_function].code    = fctb.Text;
                }
                function_saved = true;
                Library_control_class.update_functions();

                int start = fctb.Text.IndexOf('\r');
                if (0 <= start)
                {
                    fctb_control.Save_scad(fctb.Text.Substring(0, start));
                }

                XmlTextWriter xml_writer = new XmlTextWriter(librarys_functions[index_library].pfad, null);
                xml_writer.WriteStartElement("scad");
                xml_writer.WriteString("\r\n");
                foreach (Fctb_data data in librarys_functions[index_library].functions)
                {
                    xml_writer.WriteStartElement("function");
                    xml_writer.WriteString("\r\n");

                    xml_writer.WriteStartElement("name");
                    xml_writer.WriteString(data.name);
                    xml_writer.WriteEndElement();
                    xml_writer.WriteString("\r\n");

                    xml_writer.WriteStartElement("snippet");
                    xml_writer.WriteString(data.snippet);
                    xml_writer.WriteEndElement();
                    xml_writer.WriteString("\r\n");

                    xml_writer.WriteStartElement("tooltip");
                    xml_writer.WriteString(data.tooltip);
                    xml_writer.WriteEndElement();
                    xml_writer.WriteString("\r\n");

                    xml_writer.WriteStartElement("code");
                    xml_writer.WriteString(data.code);
                    xml_writer.WriteEndElement();
                    xml_writer.WriteString("\r\n");

                    xml_writer.WriteEndElement();
                    xml_writer.WriteString("\r\n");
                }
                xml_writer.WriteEndElement();
                xml_writer.Close();
            }
            return(result);
        }
Example #4
0
 private void button_remove_Click(object sender, EventArgs e)
 {
     librarys_functions.RemoveAt(index_library);
     Library_control_class.Save_librarys();
     update_listview();
 }