Example #1
0
        private void ConfigForm_Load(object sender, EventArgs e)
        {
            try
            {
                splitContainer.Panel2.Controls.Clear();
                listConfigTabs.Items.Clear();

                List <Type> default_ConfigControl_types = (from x in Assembly.GetExecutingAssembly().GetTypes() where x.BaseType == typeof(ConfigControl) select x).ToList();
                List <Type> custom_ConfigControl_types  = (from x in Assembly.GetEntryAssembly().GetExportedTypes() where x.IsSubclassOf(typeof(ConfigControl)) select x).ToList();
                List <Type> ConfigControl_types         = new List <Type>(default_ConfigControl_types);
                ConfigControl_types.AddRange(custom_ConfigControl_types);
                Dictionary <string, ConfigControl> sections2cc = new Dictionary <string, ConfigControl>();
                foreach (Type cct in ConfigControl_types)
                {
                    ConfigControl cc = (ConfigControl)System.Activator.CreateInstance(cct);
                    sections2cc[cc.Section] = cc;
                }

                foreach (string section in GetConfigControlSections())
                {
                    ConfigControl cc = null;
                    if (!sections2cc.TryGetValue(section, out cc))
                    {
                        LogMessage.Error("No ConfigControl found for section '" + section + "'");
                    }
                    add_ConfigControl(cc);
                }

                if (Settings.Gui.ConfigFormSize != System.Drawing.Size.Empty)
                {
                    this.Size = Settings.Gui.ConfigFormSize;
                }
                if (Settings.Gui.LastOpenConfigTabIndex >= 0)
                {
                    listConfigTabs.SelectedIndex = Settings.Gui.LastOpenConfigTabIndex;
                }
            }
            catch (Exception ex)
            {
                LogMessage.Error(ex);
            }

            if (Session.This != null)
            {
                foreach (ConfigControlItem cci in listConfigTabs.Items)
                {
                    cci.CC.Enabled = false;
                }
                this.Save.Enabled = false;
            }
            else
            {
                foreach (ConfigControlItem cci in listConfigTabs.Items)
                {
                    cci.CC.Enabled = true;
                }
                this.Save.Enabled = true;
            }
        }
Example #2
0
 void add_ConfigControl(ConfigControl config_control)
 {
     try
     {
         config_control.AutoSize = true;
         config_control.Dock = System.Windows.Forms.DockStyle.Fill;
         this.splitContainer.Panel2.Controls.Add(config_control);
         listConfigTabs.Items.Add(new ConfigControlItem(config_control));
     }
     catch (Exception e)
     {
         LogMessage.Error(e);
     }
 }
Example #3
0
 void add_ConfigControl(ConfigControl config_control)
 {
     try
     {
         config_control.AutoSize = true;
         config_control.Dock     = System.Windows.Forms.DockStyle.Fill;
         this.splitContainer.Panel2.Controls.Add(config_control);
         listConfigTabs.Items.Add(new ConfigControlItem(config_control));
     }
     catch (Exception e)
     {
         LogMessage.Error(e);
     }
 }
Example #4
0
 public ConfigControlItem(ConfigControl cc)
 {
     Name = cc.Name;
     CC = cc;
 }
Example #5
0
 public ConfigControlItem(ConfigControl cc)
 {
     Name = cc.Name;
     CC   = cc;
 }
Example #6
0
        private void ConfigForm_Load(object sender, EventArgs e)
        {
            try
            {
                Type[] custom_ConfigControl_types          = (from x in Assembly.GetEntryAssembly().GetExportedTypes() where x.IsSubclassOf(typeof(ConfigControl)) select x).ToArray();
                Dictionary <string, ConfigControl> cccn2cc = new Dictionary <string, ConfigControl>();
                foreach (Type cct in custom_ConfigControl_types)
                {
                    ConfigControl cc = (ConfigControl)Activator.CreateInstance(cct);
                    if (cccn2cc.ContainsKey(cc.Name))
                    {
                        throw new Exception("There is one more ConfigControl named '" + cc.Name + "'");
                    }
                    cccn2cc.Add(cc.Name, cc);
                }

                Type[] default_ConfigControl_types         = (from x in Assembly.GetExecutingAssembly().GetTypes() where x.BaseType == typeof(ConfigControl) select x).ToArray();
                Dictionary <string, ConfigControl> dccn2cc = new Dictionary <string, ConfigControl>();
                foreach (Type cct in default_ConfigControl_types)
                {
                    ConfigControl cc = (ConfigControl)Activator.CreateInstance(cct);
                    if (dccn2cc.ContainsKey(cc.Name))
                    {
                        throw new Exception("There is one more ConfigControl named '" + cc.Name + "'");
                    }
                    dccn2cc.Add(cc.Name, cc);
                }

                foreach (string name in CustomizationGuiApi.BotGui.GetConfigControlNames())
                {
                    ConfigControl cc = null;
                    if (!cccn2cc.TryGetValue(name, out cc))
                    {
                        if (!dccn2cc.TryGetValue(name, out cc))
                        {
                            LogMessage.Error("No ConfigControl found for name '" + name + "'");
                        }
                    }
                    add_ConfigControl(cc);
                }

                int last_open_config_tab_index = 0;
                int.TryParse(ConfigurationManager.AppSettings["LastOpenConfigTabIndex"], out last_open_config_tab_index);
                if (listConfigTabs.Items.Count > last_open_config_tab_index)
                {
                    listConfigTabs.SelectedIndex = last_open_config_tab_index;
                }
            }
            catch (Exception ex)
            {
                LogMessage.Error(ex);
            }

            if (Session.This != null)
            {
                foreach (ConfigControlItem cci in listConfigTabs.Items)
                {
                    cci.CC.Enabled = false;
                }
                this.Save.Enabled = false;
            }
        }