Пример #1
0
        private void comboBoxCommand_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.labelNames.Clear();
            this.textboxContents.Clear();
            this.groupBoxParameters.Controls.Clear();
            for (int i = 0; i < command.content.Count; i++)
            {
                ParameterModule parameter      = command.content[i];
                Label           labelName      = new Label();
                TextBox         textboxContent = new TextBox();

                this.groupBoxParameters.Controls.Add(labelName);
                labelName.Text     = command.content[i].name;
                labelName.Location = new Point(20, 20 + i * (textboxContent.Height + 5));
                labelName.Show();

                this.labelNames.Add(labelName);



                this.groupBoxParameters.Controls.Add(textboxContent);
                textboxContent.TextChanged += (object senderT, EventArgs eT) =>
                {
                    parameter.content = (senderT as TextBox).Text;
                };
                textboxContent.Location = new Point(20 + labelName.Width + 5, 20 + i * (textboxContent.Height + 5));
                textboxContent.Show();

                this.textboxContents.Add(textboxContent);
            }
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string        path = System.AppDomain.CurrentDomain.BaseDirectory;
            DirectoryInfo dir  = new DirectoryInfo(path);

            FileInfo[] inf = dir.GetFiles();
            foreach (FileInfo finf in inf)
            {
                if (finf.Extension.Equals(".xml"))
                {
                    XElement xe = XElement.Load(finf.FullName);
                    IEnumerable <XElement> plugins = from ele in xe.Elements("plugin") select ele;

                    foreach (XElement pe in plugins)
                    {
                        PluginModule p = new PluginModule();
                        p.name = pe.Attribute("name").Value;
                        p.note = pe.Attribute("note").Value;
                        p.text = pe.Attribute("text").Value;

                        IEnumerable <XElement> commands = from ele in pe.Elements("command") select ele;
                        foreach (XElement ce in commands)
                        {
                            CommandModule c = new CommandModule();
                            c.name = ce.Attribute("name").Value;
                            c.note = ce.Attribute("note").Value;
                            c.text = ce.Attribute("text").Value;

                            IEnumerable <XElement> parameters = from ele in ce.Elements("parameter") select ele;
                            foreach (XElement pae in parameters)
                            {
                                ParameterModule pa = new ParameterModule();
                                pa.name = pae.Attribute("name").Value;
                                pa.note = pae.Attribute("note").Value;

                                c.content.Add(pa);
                            }

                            p.content.Add(c);
                        }

                        this.pluginsM.Add(p);
                    }
                }
            }

            List <string> splugins = new List <string>();

            this.comboBoxPlugin.Items.Clear();
            this.pluginsM.ForEach(p => this.comboBoxPlugin.Items.Add(p.name));
        }