Example #1
0
        // MAY return null!

        private TabPage CreateTab(PanelInformation.PanelIDs ptype, string name, int dn, int posindex, bool dotheme)
        {
            UserControls.UserControlCommonBase uccb = PanelInformation.Create(ptype); // must create, since its a ptype.
            if (uccb == null)                                                         // if ptype is crap, it returns null.. catch
            {
                return(null);
            }

            uccb.Dock     = System.Windows.Forms.DockStyle.Fill; // uccb has to be fill, even though the VS designer does not indicate you need to set it.. copied from designer code
            uccb.Location = new System.Drawing.Point(3, 3);

            List <int> idlist = (from TabPage p in TabPages where p.Controls[0].GetType() == uccb.GetType() select(p.Controls[0] as UserControls.UserControlCommonBase).displaynumber).ToList();

            if (dn == -1) // if work out display number
            {
                // not travel grid (due to clash with History control) and not in list, use primary number (0)
                if (ptype != PanelInformation.PanelIDs.TravelGrid && !idlist.Contains(UserControls.UserControlCommonBase.DisplayNumberPrimaryTab))
                {
                    dn = UserControls.UserControlCommonBase.DisplayNumberPrimaryTab;
                }
                else
                {   // search for empty id.
                    for (int i = UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs; i <= UserControls.UserControlCommonBase.DisplayNumberStartExtraTabsMax; i++)
                    {
                        if (!idlist.Contains(i))
                        {
                            dn = i;
                            break;
                        }
                    }
                }
            }

            System.Diagnostics.Debug.WriteLine("Create tab {0} dn {1} at {2}", ptype, dn, posindex);

            uccb.Init(eddiscovery, travelgrid, dn);    // start the uccb up

            string postfix;

            if (ptype != PanelInformation.PanelIDs.TravelGrid)      // given the dn, work out the name
            {
                postfix = (dn == UserControls.UserControlCommonBase.DisplayNumberPrimaryTab) ? "" : "(" + (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs + 1).ToStringInvariant() + ")";
            }
            else
            {
                postfix = (dn == UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs) ? "" : "(" + (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs).ToStringInvariant() + ")";
            }

            string  title = name != null ? name : (PanelInformation.GetPanelInfoByEnum(ptype).WindowTitle + postfix);
            TabPage page  = new TabPage(title);

            page.Location = new System.Drawing.Point(4, 22);    // copied from normal tab creation code
            page.Padding  = new System.Windows.Forms.Padding(3);

            page.Controls.Add(uccb);

            TabPages.Insert(posindex, page);

            if (dotheme)                // only user created ones need themeing
            {
                EDDTheme.Instance.ApplyToControls(page, applytothis: true);
            }

            return(page);
        }
Example #2
0
        public TabPage GetMajorTab(PanelInformation.PanelIDs ptype)
        {
            Type t = PanelInformation.GetPanelInfoByEnum(ptype).PopoutType;

            return((from TabPage x in TabPages where x.Controls[0].GetType() == t select x).FirstOrDefault());
        }