示例#1
0
        public void RemoveTab(TabPage page)         // from right click menu
        {
            UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase;

            if (uccb.AllowClose())              // it must allow a close to remove it
            {
                uccb.CloseDown();
                page.Dispose();
            }
        }
示例#2
0
 public bool AllowClose()                 // tabs are closing, does all tabs allow close
 {
     foreach (TabPage p in TabPages)
     {
         UserControls.UserControlCommonBase uccb = p.Controls[0] as UserControls.UserControlCommonBase;
         if (uccb.AllowClose() == false)
         {
             return(false);
         }
     }
     return(true);
 }
 public override bool AllowClose()                         // grid is closing, does the consistuent panels allow close?
 {
     foreach (UserControlContainerResizable r in uccrlist) // save in uccr list
     {
         UserControlCommonBase uc = (UserControlCommonBase)r.control;
         if (uc.AllowClose() == false)
         {
             return(false);
         }
     }
     return(true);
 }
        private void Merge(int panel)                                                                            // Merge a panel, which involves closing one, so we need to check
        {
            SplitContainer insidesplitter = (SplitContainer)currentsplitter.Controls[panel].Controls[0];         // get that split container in the panel

            ExtendedControls.TabStrip tabstrip = insidesplitter.Panel2.Controls[0] as ExtendedControls.TabStrip; // it must contain a tabstrip

            UserControlCommonBase discard = tabstrip.CurrentControl as UserControlCommonBase;                    // we are discarding this UCCB, this can be null, as it may not contain one

            if (discard?.AllowClose() ?? true)                                                                   // check if can close, if null, we can
            {
                currentsplitter.Merge(panel);
                AssignTHC();        // because we may have removed the cursor
            }
        }
示例#5
0
        public void RemoveTab(int tabIndex)         // from right click menu
        {
            if (tabIndex >= 0 && tabIndex < TabPages.Count)
            {
                TabPage page = TabPages[tabIndex];
                UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase;

                if (uccb.AllowClose())              // it must allow a close to remove it
                {
                    uccb.CloseDown();
                    page.Dispose();
                }
            }
        }
        public bool ClosePanel(UserControlContainerResizable uccr)
        {
            UserControlCommonBase uc = (UserControlCommonBase)uccr.control;

            if (uc.AllowClose())
            {
                uc.CloseDown();
                panelPlayfield.Controls.Remove(uccr);
                uccrlist.Remove(uccr);
                Invalidate();
                uc.Dispose();
                uccr.Dispose();
                UpdateButtons();
                AssignTHC();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void Merge(int panel)                                                                    // Merge a panel, which involves closing one, so we need to check
        {
            SplitContainer insidesplitter = (SplitContainer)currentsplitter.Controls[panel].Controls[0]; // get that split container in the panel

            UserControlCommonBase uccb = insidesplitter.Panel2.Controls[0] as UserControlCommonBase;     // the panel may an embedded direct uccb..

            if (uccb == null)
            {
                ExtendedControls.TabStrip tabstrip = insidesplitter.Panel2.Controls[0] as ExtendedControls.TabStrip;    // it may contain a tabstrip...
                if (tabstrip != null)
                {
                    uccb = tabstrip.CurrentControl as UserControlCommonBase;    // if its a tabstrip, it may contain a UCCB, or it may be empty..
                }
                // if its not a uccb, its a split container, so null is fine
            }

            if (uccb?.AllowClose() ?? true)      // check if can close, if null, we can
            {
                currentsplitter.Merge(panel);
                AssignTHC();        // because we may have removed the cursor
            }
        }
        private Control MakeNode(string s)
        {
            BaseUtils.StringParser sp = new BaseUtils.StringParser(s); // ctrl string is tag,panelid enum number
            int tagid = sp.NextInt(",") ?? 0;                          // enum id

            sp.IsCharMoveOn(',');
            int panelid = sp.NextInt(",") ?? NoTabPanelSelected; // if not valid, we get an empty tab control

            if (panelid >= FixedPanelOffset)                     // this range of ids are UCCB directly in the splitter, so are not changeable
            {
                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID((PanelInformation.PanelIDs)(panelid - FixedPanelOffset));
                if (pi == null)
                {
                    pi = PanelInformation.GetPanelInfoByPanelID(PanelInformation.PanelIDs.Log); // make sure we have a valid one - can't return nothing
                }
                UserControlCommonBase uccb = PanelInformation.Create(pi.PopoutID);              // must return as we made sure pi is valid
                uccb.AutoScaleMode = AutoScaleMode.Inherit;                                     // very very important and took 2 days to work out!
                uccb.Dock          = DockStyle.Fill;
                uccb.Tag           = tagid;
                uccb.Name          = "UC-" + tagid.ToStringInvariant();

                return(uccb);
            }
            else                        // positive ones are tab strip with the panel id selected, if valid..
            {
                ExtendedControls.TabStrip tabstrip = new ExtendedControls.TabStrip();
                tabstrip.ImageList = PanelInformation.GetUserSelectablePanelImages(TabListSortAlpha);
                tabstrip.TextList  = PanelInformation.GetUserSelectablePanelDescriptions(TabListSortAlpha);
                tabstrip.TagList   = PanelInformation.GetUserSelectablePanelIDs(TabListSortAlpha).Cast <Object>().ToArray();
                tabstrip.ListSelectionItemSeparators = PanelInformation.GetUserSelectableSeperatorIndex(TabListSortAlpha);

                tabstrip.Dock      = DockStyle.Fill;
                tabstrip.StripMode = ExtendedControls.TabStrip.StripModeType.ListSelection;

                tabstrip.Tag  = tagid;                        // Tag stores the ID index of this view
                tabstrip.Name = Name + "." + tagid.ToStringInvariant();

                //System.Diagnostics.Debug.WriteLine("Make new tab control " + tabstrip.Name + " id "  + tagid + " of " + panelid );

                tabstrip.AllowClose += (tab, index, ctrl) =>
                {
                    UserControlCommonBase uccb = ctrl as UserControlCommonBase;
                    return(uccb.AllowClose());
                };

                tabstrip.OnRemoving += (tab, ctrl) =>
                {
                    UserControlCommonBase uccb = ctrl as UserControlCommonBase;
                    uccb.CloseDown();
                    AssignTHC();        // in case we removed anything
                };

                tabstrip.OnCreateTab += (tab, si) =>                                                                                         // called when the tab strip wants a new control for a tab.
                {
                    PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID((PanelInformation.PanelIDs)tabstrip.TagList[si]); // must be valid, as it came from the taglist
                    Control c    = PanelInformation.Create(pi.PopoutID);
                    var     uccb = (c as UserControlCommonBase);
                    uccb.AutoScaleMode = AutoScaleMode.Inherit;
                    c.Name             = pi.WindowTitle; // tabs uses Name field for display, must set it
                    tab.HelpAction     = (pt) => { EDDHelp.Help(this.FindForm(), pt, uccb); };

                    System.Diagnostics.Trace.WriteLine("SP:Create Tab " + c.Name);
                    return(c);
                };

                tabstrip.OnPostCreateTab += (tab, ctrl, i) =>                       // only called during dynamic creation..
                {
                    int tabstripid           = (int)tab.Tag;                        // tag from tab strip
                    int displaynumber        = DisplayNumberOfSplitter(tabstripid); // tab strip - use tag to remember display id which helps us save context.
                    UserControlCommonBase uc = ctrl as UserControlCommonBase;

                    if (uc != null)
                    {
                        System.Diagnostics.Trace.WriteLine("SP:Make Tab " + tabstripid + " with dno " + displaynumber + " Use THC " + ucursor_inuse.GetHashCode());
                        uc.Init(discoveryform, displaynumber);              // init..

                        uc.Scale(this.FindForm().CurrentAutoScaleFactor()); // keeping to the contract, scale and
                        discoveryform.theme.ApplyStd(uc);                   // theme the uc. between init and set cursor

                        uc.SetCursor(ucursor_inuse);
                        uc.LoadLayout();
                        uc.InitialDisplay();
                    }

                    AssignTHC();        // in case we added one
                };

                tabstrip.OnPopOut += (tab, i) => { discoveryform.PopOuts.PopOut((PanelInformation.PanelIDs)tabstrip.TagList[i]); };

                PanelInformation.PanelIDs[] pids = PanelInformation.GetUserSelectablePanelIDs(TabListSortAlpha); // sort order v.important.. we need the right index, dep

                int indexofentry = Array.FindIndex(pids, x => x == (PanelInformation.PanelIDs)panelid);          // find ID in array..  -1 if not valid ID, it copes with -1

                if (indexofentry >= 0)                                                                           // if we have a panel, open it
                {
                    tabstrip.Create(indexofentry);                                                               // create but not post create during the init phase. Post create is only used during dynamics
                }

                return(tabstrip);
            }
        }
 public bool AllowClose()
 {
     return(UserControl?.AllowClose() ?? true);       // does the UCCB allow close?
 }