Beispiel #1
0
        private void btnControl_Edit_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lvControls.Items.Count > 0 && this.lvControls.SelectedItems.Count > 0)
                {
                    ListViewItem  lvi   = this.lvControls.FocusedItem;
                    ModuleControl admin = (ModuleControl)lvi.Tag;

                    this.FormEditItem      = new frmEditItem(admin);
                    this.FormEditItem.Name = lvi.Text;
                    this.FormEditItem.Type = lvi.SubItems[1].Text;
                    this.FormEditItem.Path = lvi.SubItems[2].Text;

                    if (this.FormEditItem.ShowDialog() == DialogResult.OK)
                    {
                        lvi.Text             = this.FormEditItem.Name;
                        lvi.SubItems[1].Text = this.FormEditItem.Type;
                        lvi.SubItems[2].Text = this.FormEditItem.Path;
                    }
                }
            }
            catch (Exception ex)
            {
                this.HandleException(ex);
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.lvModules.Items.Count > 0 && this.lvModules.SelectedItems.Count > 0)
            {
                ListViewItem lvi    = this.lvModules.FocusedItem;
                Module       module = (Module)lvi.Tag;

                // Set the module values
                module.SetModuleName(txtName.Text);
                module.SetModuleType((ModuleType)Enum.Parse(typeof(ModuleType), cmbType.Text, true));
                lvi.Text = txtName.Text;

                // Based on the module type, set its corresponding values
                if (cmbType.Text == "Service")
                {
                    module.SetServiceName(this.txtServiceName.Text);
                }
                else if (cmbType.Text == "Software")
                {
                    module.SetProgramPath(this.txtFilePath.Text);
                }

                module.ClearConfigs();
                module.ClearControls();

                // If there are any controls, create them and add to the module
                if (this.lvControls.Items.Count > 0)
                {
                    foreach (ListViewItem controlLvi in this.lvControls.Items)
                    {
                        ModuleControl control = (ModuleControl)controlLvi.Tag;
                        control.SetControlName(controlLvi.Text);
                        control.SetControlType((ControlType)Enum.Parse(typeof(ControlType), controlLvi.SubItems[1].Text, true));
                        control.SetControlPath(controlLvi.SubItems[2].Text);
                        module.AddControl(control);
                    }
                }

                // If there are any configs, create them and add to the module
                if (this.lvConfigs.Items.Count > 0)
                {
                    foreach (ListViewItem configLvi in this.lvConfigs.Items)
                    {
                        ModuleConfig config = (ModuleConfig)configLvi.Tag;
                        config.SetConfigName(configLvi.Text);
                        config.SetConfigType((ConfigType)Enum.Parse(typeof(ConfigType), configLvi.SubItems[1].Text, true));
                        config.SetConfigPath(configLvi.SubItems[2].Text);
                        module.AddConfig(config);
                    }
                }
            }
        }
Beispiel #3
0
 private void btnControl_Add_Click(object sender, EventArgs e)
 {
     if (this.lvModules.Items.Count > 0 && this.lvModules.SelectedItems.Count > 0)
     {
         ModuleControl control = new ModuleControl();
         ListViewItem  lvi     = new ListViewItem();
         lvi.Text = control.GetControlName();
         lvi.SubItems.Add(control.GetControlType().ToString());
         lvi.SubItems.Add(control.GetControlPath());
         lvi.Tag = control;
         this.lvControls.Items.Add(lvi);
     }
 }
Beispiel #4
0
        /**
         * <summary>
         * Load a PandaStack configuration file
         * </summary>
         */
        private void LoadJsonFile(string filePath)
        {
            JsonHandler jsonHandler = new JsonHandler(filePath);

            jsonHandler.FetchJson();

            foreach (JsonModule jsonModule in jsonHandler.GetModules())
            {
                Module module = new Module();
                module.SetModuleName(jsonModule.name);
                module.SetModuleType((ModuleType)Enum.Parse(typeof(ModuleType), jsonModule.type, true));

                if (module.GetModuleType() == ModuleType.Service)
                {
                    module.SetServiceName(jsonModule.service);
                }

                if (jsonModule.control != null && jsonModule.control.Count > 0)
                {
                    foreach (JsonControl jsonControl in jsonModule.control)
                    {
                        ModuleControl control = new ModuleControl();
                        control.SetControlName(jsonControl.name);
                        control.SetControlType((ControlType)Enum.Parse(typeof(ControlType), jsonControl.type, true));
                        control.SetControlPath(jsonControl.path);

                        module.AddControl(control);
                    }
                }

                if (jsonModule.config != null && jsonModule.config.Count > 0)
                {
                    foreach (JsonConfig jsonConfig in jsonModule.config)
                    {
                        ModuleConfig config = new ModuleConfig();
                        config.SetConfigName(jsonConfig.name);
                        config.SetConfigType((ConfigType)Enum.Parse(typeof(ConfigType), jsonConfig.type, true));
                        config.SetConfigPath(jsonConfig.path);

                        module.AddConfig(config);
                    }
                }

                this.Modules.Add(module);

                ListViewItem lvi = new ListViewItem();
                lvi.Text = module.GetModuleName();
                lvi.Tag  = module;
                this.lvModules.Items.Add(lvi);
            }
        }
Beispiel #5
0
        public frmEditItem(ModuleControl control)
        {
            InitializeComponent();

            this.Control = control;
            this.Text    = "Editing Module Control";

            var values = Enum.GetValues(typeof(ControlType));

            foreach (ControlType type in values)
            {
                this.cmbType.Items.Add(type.ToString());
            }
        }
Beispiel #6
0
 public void AddControl(ModuleControl control)
 {
     this.Controls.Add(control);
 }