示例#1
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;
         uccb.CloseDown();
         page.Dispose();
     }
 }
示例#2
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();
            }
        }
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (UserControl?.AllowClose() ?? true)          // does the UCCB allow close?
            {
                IsLoaded = false;

                UserControl?.CloseDown();                   // it may be null
            }
            else
            {
                e.Cancel = true;                            // cancel close
            }
            base.OnFormClosing(e);
        }
示例#4
0
        public void CloseTabList()
        {
            List <int> idlist = new List <int>();

            idlist.Add(SelectedIndex);   // first is current index

            string tabnames = "";

            UserControls.UserControlContainerSplitter primary = PrimaryTab;

            foreach (TabPage p in TabPages)      // all main tabs, load/display
            {
                UserControls.UserControlCommonBase uccb = p.Controls[0] as UserControls.UserControlCommonBase;
                uccb.CloseDown();
                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByType(uccb.GetType());
                idlist.Add(Object.ReferenceEquals(uccb, primary) ? -1 : (int)pi.PopoutID);      // primary is marked -1
                idlist.Add(uccb.displaynumber);
                tabnames += p.Text + ";";
            }

            EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(EDDProfiles.Instance.UserControlsPrefix + "MajorTabControlList", string.Join(",", idlist));
            EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(EDDProfiles.Instance.UserControlsPrefix + "MajorTabControlName", tabnames);
        }
示例#5
0
        public override void Closing()
        {
            //System.Diagnostics.Debug.WriteLine("Closing splitter " + displaynumber);

            PanelInformation.PanelIDs[] pids = PanelInformation.GetUserSelectablePanelIDs(TabListSortAlpha);

            SplitContainer sc = (SplitContainer)panelPlayfield.Controls[0];

            string state = ControlHelpersStaticFunc.SplitterTreeState(sc, "",
                                                                      (c) => // S is either a TabStrip, or a direct UCCB. See the
            {
                ExtendedControls.TabStrip ts = c as ExtendedControls.TabStrip;
                int tagid = (int)c.Tag;
                if (ts != null)           // if tab strip..
                {
                    return(tagid.ToStringInvariant() + "," + (ts.SelectedIndex >= 0 ? (int)pids[ts.SelectedIndex] : NoTabPanelSelected).ToStringInvariant());
                }
                else
                {
                    PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByType(c.GetType());           // must return, as it must be one of the UCCB types
                    return(tagid.ToStringInvariant() + "," + (FixedPanelOffset + ((int)pi.PopoutID)).ToStringInvariant());
                }
            });

            //System.Diagnostics.Debug.WriteLine("Split save " + state);
            EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(DbWindows, state);

            (panelPlayfield.Controls[0] as SplitContainer).RunActionOnSplitterTree((p, c) =>        // runs on each split panel node exactly..
            {
                UserControlCommonBase uccb = ((c is ExtendedControls.TabStrip) ? ((c as ExtendedControls.TabStrip).CurrentControl) : c) as UserControlCommonBase;
                if (uccb != null)     // tab strip may not have a control set..
                {
                    uccb.CloseDown();
                    //System.Diagnostics.Debug.WriteLine("Closing " + c.Name + " " + c.GetType().Name + " " + uccb.Name);
                }
            });
        }
        public override void Closing()
        {
            //System.Diagnostics.Debug.WriteLine("Grid Saving to " + DbWindows);
            string s = "", p = "";

            foreach (UserControlContainerResizable r in uccrlist)   // save in uccr list
            {
                UserControlCommonBase uc = (UserControlCommonBase)r.control;

                s = s.AppendPrePad(((int)uc.panelid).ToStringInvariant(), ",");
                p = p.AppendPrePad(r.Location.X + "," + r.Location.Y + "," + r.Size.Width + "," + r.Size.Height, ",");

                //System.Diagnostics.Debug.WriteLine("  Save " + uc.GetType().Name + " at " + r.Location + " sz " + r.Size);

                uc.CloseDown();
            }

            PutSetting(dbWindowNames, s);
            PutSetting(dbPositionSize, p);
            PutSetting(dbRolledUp, rollUpPanelMenu.PinState);

            string z = "";

            foreach (Control c in panelPlayfield.Controls)
            {
                if (c is UserControlContainerResizable)
                {
                    int index = uccrlist.FindIndex(x => x.Equals(c));
                    z = z.AppendPrePad(index.ToStringInvariant(), ",");
                    //System.Diagnostics.Debug.WriteLine("Order.." + index + "=" + (c as UserControlContainerResizable).control.GetType().Name );
                }
            }

            PutSetting(dbZOrder, z);
            //System.Diagnostics.Debug.WriteLine("---- END Grid Saving to " + DbWindows);
        }
示例#7
0
        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.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)tab.TagList[si]); // must be valid, as it came from the taglist
                    Control c = PanelInformation.Create(pi.PopoutID);
                    (c as UserControlCommonBase).AutoScaleMode = AutoScaleMode.Inherit;
                    c.Name = pi.WindowTitle;        // tabs uses Name field for display, must set it
                    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);
            }
        }
示例#8
0
        public override void Init()
        {
            DBBaseName = "CaptainsLog";

            tabStrip.ImageList = new Image[] { EDDiscovery.Icons.Controls.Diary, EDDiscovery.Icons.Controls.Entries };
            tabStrip.TextList  = new string[] { "Diary".T(EDTx.UserControlCaptainsLog_Diary), "Entries".T(EDTx.UserControlCaptainsLog_Entries) };
            tabStrip.TagList   = new Type[] { typeof(CaptainsLogDiary), typeof(CaptainsLogEntries) };

            tabStrip.OnCreateTab += (tab, si) =>
            {
                UserControlCommonBase uccb = (UserControlCommonBase)Activator.CreateInstance((Type)tab.TagList[si], null);
                uccb.Name = tab.TextList[si];
                return(uccb);
            };

            tabStrip.OnPostCreateTab += (tab, ctrl, si) =>
            {
                UserControlCommonBase uccb = ctrl as UserControlCommonBase;
                uccb.Init(discoveryform, displaynumber);
                ExtendedControls.Theme.Current.ApplyStd(uccb);       // contract, in UCCB, states theming is between init and load
                uccb.LoadLayout();
                uccb.InitialDisplay();

                if (uccb is CaptainsLogDiary)
                {
                    (uccb as CaptainsLogDiary).ClickedonDate = (d, b) =>
                    {
                        gotodatestart          = gotodateend = d;
                        createnew              = b;
                        tabStrip.SelectedIndex = 1;
                    };
                }
                else if (uccb is CaptainsLogEntries)
                {
                    if (gotodatestart.HasValue)
                    {
                        var clentries = uccb as CaptainsLogEntries;
                        clentries.SelectDate(gotodatestart.Value, gotodateend.Value, createnew);
                        gotodatestart = gotodateend = null;
                    }
                }
            };

            tabStrip.OnRemoving += (tab, ctrl) =>
            {
                UserControlCommonBase uccb = ctrl as UserControlCommonBase;
                uccb.CloseDown();
            };

            tabStrip.OnControlTextClick += (tab) =>
            {
                CaptainsLogDiary cld = tabStrip.CurrentControl as CaptainsLogDiary;
                if (cld != null)
                {
                    gotodatestart          = cld.CurrentMonth;
                    gotodateend            = new DateTime(cld.CurrentMonth.Year, cld.CurrentMonth.Month, DateTime.DaysInMonth(cld.CurrentMonth.Year, cld.CurrentMonth.Month));
                    createnew              = false;
                    tabStrip.SelectedIndex = 1;
                }
            };
        }