Example #1
0
        public DataCore.Core DataCoreByKey(string key)
        {
            if (pages == null || pages.Count == 0)
            {
                return(null);
            }

            if (!pages.ContainsKey(key))
            {
                return(null);
            }

            DataCore.Core ret = null;
            GUI.Main.Instance.Invoke(new MethodInvoker(delegate { ret = ((Styles.Data)pages[key].Controls[0]).Core; }));

            return(ret);
        }
Example #2
0
 public void SetText(string key, string text)
 {
     if (pages.ContainsKey(key))
     {
         pages[key].Text = text;
     }
     else
     {
         lManager.Enter(Logs.Sender.MANAGER, Logs.Level.ERROR, "Tab Manager could not SetText because tab with key: {0} does not exist!", key);
     }
 }
Example #3
0
        public void Init()
        {
            HashSet <String>      listedModules  = new HashSet <string>();
            List <ProjectSetting> sortedSettings = Settings.List().ToList <ProjectSetting>();

            sortedSettings.Sort();

            // get all modules that have displayed options
            foreach (ProjectSetting setting in sortedSettings)
            {
                if (!(String.IsNullOrWhiteSpace(setting.Display_Type) ||
                      String.IsNullOrWhiteSpace(setting.Module)
                      )
                    )
                {
                    listedModules.Add(setting.Module);   // returns false if already there.  Don't care.
                }
            }


            foreach (String module in listedModules)
            {
                //TabPage page = new TabPage(module);
                String tabText = new CultureInfo("en-US").TextInfo.ToTitleCase(module);
                TabControl.TabPageCollection pages = tabControlSettings.TabPages;
                if (!pages.ContainsKey(module))     // should only happen for general tab
                {
                    pages.Add(module, tabText);
                    //pages[module].BackColor = Color.Transparent;        // for some reason, the general page is a different background color?!
                    // TODO: Fix
                }

                // general tab doesn't currently have these things.
                FlowLayoutPanel flowpanel = new FlowLayoutPanel();
                flowpanel.Name = "flowpanel_" + module;

                flowpanel.FlowDirection = FlowDirection.LeftToRight;
                flowpanel.WrapContents  = true;
                flowpanel.Dock          = DockStyle.Fill;
                //flowpanel.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                flowpanel.AutoScroll = true;


                pages[module].Controls.Add(flowpanel);
            }


            foreach (ProjectSetting setting in sortedSettings)
            {
                CtlSetting control;
                switch (setting.Display_Type)
                {
                case "":
                    continue;

                case "info":
                    control = new CtlSettingInfo(setting.Name);
                    break;

                case "select":
                case "field":
                    control = new CtlSettingSelect(setting.Name);
                    if (setting.Display_Type == "field")
                    {
                        // if it's not required, add in a blank
                        if (!setting.Required)
                        {
                            if (!setting.options.Contains(""))
                            {
                                setting.options.Insert(0, "");
                            }
                        }
                        control.setOptions(setting.options);
                    }
                    break;

                case "bool":
                    control = new CtlSettingBool(setting.Name);
                    break;

                default:
                    control = new CtlSettingText(setting.Name);
                    break;
                }

                // ??? FromSetting would remove the options we addded above?
                control.FromSetting(setting);
                control.Display_Text = setting.Display_Name == "" ? new CultureInfo("en-US").TextInfo.ToTitleCase(setting.Name) : setting.Display_Name;
                control.Visible      = true;
                control.resetStatus();
                control.Anchor = AnchorStyles.Left | AnchorStyles.Right;

                TabPage page = tabControlSettings.TabPages[setting.Module];
                Control.ControlCollection controls = page.Controls;
                FlowLayoutPanel           panel    = (FlowLayoutPanel)controls["flowpanel_" + setting.Module];


                panel.SuspendLayout();
                panel.Controls.Add(control);
                panel.ResumeLayout(true);
                settingControls.Add(control);

                //tabControlSettings.TabPages[setting.Module].Controls.Add(control);

                control.OnFocus += Set_Description;
                //control.LostFocus += new EventHandler(Clear_Description);
            }

            // remove any pages, add any, etc
            foreach (TabPage page in tabControlSettings.TabPages)
            {
                if (page.Controls.Count <= 0)
                {
                    tabControlSettings.TabPages.Remove(page);
                }
            }
        }