private void populateTasks()
        {
            List <XElement> elements;

            try
            {
                elements = GetElements("Task");
            }
            catch (MissingElementException)
            {
                return;
            }
            finally
            {
                tasks = new List <Task>();
            }

            foreach (XElement element in elements)
            {
                List <Plugin>   plugins        = new List <Plugin>();
                List <XElement> pluginElements = element.Descendants("Plugin").ToList();
                string          taskName       = element.Attribute("Name").Value;

                foreach (XElement pluginElement in pluginElements)
                {
                    string          name          = pluginElement.Attribute("Name").Value;
                    List <XElement> inputElements = pluginElement.Descendants("Input").ToList();
                    Plugin          plugin        = new Plugin(name);

                    if (pluginElement.Attribute("Imported") != null)
                    {
                        if (pluginElement.Attribute("Imported").Value == "true")
                        {
                            plugin.importedPlugin = true;
                        }
                    }

                    foreach (XElement inputElement in inputElements)
                    {
                        string label = inputElement.Attribute("Label").Value;
                        string value = inputElement.Attribute("Value").Value;
                        InsertionValueHelper.InputType input     = (InsertionValueHelper.InputType)Enum.Parse(typeof(InsertionValueHelper.InputType), inputElement.Attribute("Type").Value);
                        InsertionValueHelper           insertion = new InsertionValueHelper(input, label);

                        plugin.valueDict[insertion] = value;
                    }

                    plugins.Add(plugin);
                }
                Task task = new Task(taskName);
                task.plugins = plugins;
                tasks.Add(task);
            }
        }
Exemple #2
0
        private void browseFileOnClick(object sender, EventArgs e)
        {
            string selectedFile = Dialogs.SelectFile();

            if (String.IsNullOrEmpty(selectedFile))
            {
                return;
            }

            Button button = (Button)sender;

            button.Text = selectedFile;
            int index = Int32.Parse(button.Tag.ToString());
            InsertionValueHelper insertion = this.plugin.insertions[index];

            this.plugin.valueDict[insertion] = selectedFile;
        }
        private void populatPlugin(bool imported)
        {
            List <XElement> elements = GetElements("Plugin");

            if (elements.Count != 1)
            {
                throw new Exception("setup.xml must include exactly one Plugin element");
            }
            XElement pluginElement     = elements[0];
            string   pluginName        = pluginElement.Attribute("name").Value;
            string   pluginDescription = pluginElement.Attribute("description").Value;

            plugin = new Plugin(pluginDescription, pluginName);
            plugin.importedPlugin = imported;
            List <XElement> inputValues = pluginElement.Descendants("InsertionValue").ToList();

            foreach (XElement inputValue in inputValues)
            {
                string label = inputValue.Attribute("Label").Value;
                InsertionValueHelper.InputType inputType      = (InsertionValueHelper.InputType)Enum.Parse(typeof(InsertionValueHelper.InputType), inputValue.Attribute("InputType").Value);
                InsertionValueHelper           insertionValue = new InsertionValueHelper(inputType, label);
                plugin.insertions.Add(insertionValue);
            }
        }