public override void Init()
        {
            DBBaseName = "UCSearch";

            tabStrip.ImageList = new Image[] { EDDiscovery.Icons.Controls.SearchStars, EDDiscovery.Icons.Controls.SearchMaterials, EDDiscovery.Icons.Controls.SearchScan };
            tabStrip.TextList  = new string[] { "Stars".T(EDTx.UserControlSearch_Stars), "Materials Commodities".T(EDTx.UserControlSearch_MaterialsCommodities), "Scans".T(EDTx.UserControlSearch_Scans) };
            tabStrip.TagList   = new Type[] { typeof(SearchStars), typeof(SearchMaterialsCommodities), typeof(SearchScans) };

            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);
                discoveryform.theme.ApplyStd(uccb);       // contract, in UCCB, states theming is between init and load
                uccb.SetCursor(uctg);
                uccb.LoadLayout();
                uccb.InitialDisplay();
            };

            tabStrip.OnRemoving += (tab, ctrl) =>
            {
                UserControlCommonBase uccb = ctrl as UserControlCommonBase;
                uccb.CloseDown();
            };
        }
        private void UserControlForm_Shown(object sender, EventArgs e)          // as launched, it may not be in front (as its launched from a control).. bring to front
        {
            //System.Diagnostics.Debug.WriteLine("UCF Shown+");
            this.BringToFront();

            if (IsTransparencySupported)
            {
                TransparentMode = (TransparencyMode)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(DBRefName + "Transparent", deftransparent ? (int)TransparencyMode.On : (int)TransparencyMode.Off);
            }

            bool wantedTopMost = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(DBRefName + "TopMost", deftopmost);

            //kludge
            SetTopMost(wantedTopMost);
            SetTopMost(!wantedTopMost);
            SetTopMost(wantedTopMost); // this also establishes transparency

            var top = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(DBRefName + "Top", -999);

            //System.Diagnostics.Debug.WriteLine("Position Top is {0} {1}", dbrefname, top);

            if (UserControl != null)
            {
                System.Diagnostics.Debug.WriteLine("UCCB Call set curosr, load layout, initial display");
                UserControl.SetCursor(UserControl.discoveryform.PrimaryCursor);
                UserControl.LoadLayout();
                UserControl.InitialDisplay();
            }

            IsLoaded = true;
            //System.Diagnostics.Debug.WriteLine("UCF Shown-");
        }
        private void LoadLayoutPanel(UserControlContainerResizable uccr, UserControlCommonBase uccb, Point pos, Size size)
        {
            //System.Diagnostics.Trace.WriteLine("GD:Cursor/Load/Init " + uccb.GetType().Name + " to " + pos + " " + size);
            uccb.SetCursor(ucursor_inuse);
            uccb.LoadLayout();
            uccb.InitialDisplay();

            uccr.Location = pos;        // must set on load layout, themeing is defined between init and load layout and can shift numbers
            uccr.Size     = size;
        }
示例#4
0
        public void AddTab(PanelInformation.PanelIDs id, int tabindex = 0)      // -n is from the end, else before 0,1,2
        {
            if (tabindex < 0)
            {
                tabindex = Math.Max(0, TabCount + tabindex);
            }

            TabPage page = CreateTab(id, null, -1, tabindex);

            if (page != null)
            {
                UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase;
                uccb.SetCursor(PrimaryTab.GetTravelGrid);
                uccb.LoadLayout();
                uccb.InitialDisplay();
                SelectedIndex = tabindex;   // and select the inserted one
            }
        }
示例#5
0
        public TabPage EnsureMajorTabIsPresent(PanelInformation.PanelIDs ptype, bool selectit)
        {
            TabPage page = GetMajorTab(ptype);

            if (page == null)
            {
                page = CreateTab(ptype, null, -1, TabCount);
                UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase;
                uccb.SetCursor(PrimaryTab.GetTravelGrid);
                uccb.LoadLayout();
                uccb.InitialDisplay();
            }

            if (selectit)
            {
                SelectTab(page);
            }

            return(page);
        }
示例#6
0
        public void LoadTabs()     // called on Loading..
        {
            //foreach (TabPage tp in tabControlMain.TabPages) System.Diagnostics.Debug.WriteLine("TP Size " + tp.Controls[0].DisplayRectangle);

            UserControls.UserControlContainerSplitter primary = PrimaryTab;

            foreach (TabPage p in TabPages)      // all main tabs, load/display
            {
                // now a strange thing. tab Selected, cause its shown, gets resized (due to repoisition form). Other tabs dont.
                // LoadLayout could fail due to an incorrect size that would break something (such as spitters)..
                // so force size. tried perform layout to no avail
                p.Size = TabPages[SelectedIndex].Size;
                UserControls.UserControlCommonBase uccb = (UserControls.UserControlCommonBase)p.Controls[0];
                uccb.SetCursor(primary.GetTravelGrid);
                uccb.LoadLayout();
                uccb.InitialDisplay();
            }

            //foreach (TabPage tp in tabControlMain.TabPages) System.Diagnostics.Debug.WriteLine("TP Size " + tp.Controls[0].DisplayRectangle);
        }
示例#7
0
        private UserControlContainerResizable CreatePanel(UserControlCommonBase uccb, Point pos, Size size)
        {
            UserControlContainerResizable uccr = new UserControlContainerResizable();

            PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByType(uccb.GetType());
            uccr.Init(uccb, pi.WindowTitle);
            uccr.ResizeStart        += ResizeStart;
            uccr.ResizeEnd          += ResizeEnd;
            uccr.BorderColor         = discoveryform.theme.GridBorderLines;
            uccr.SelectedBorderColor = discoveryform.theme.TextBlockHighlightColor;

            uccrlist.Add(uccr);

            int numopenedinside = uccrlist.Count(x => x.GetType().Equals(uccb.GetType()));    // how many others are there?

            int dnum = DisplayNumberOfGrid(numopenedinside);

            System.Diagnostics.Trace.WriteLine("GD:Create " + uccb.GetType().Name + " " + dnum + " Assign THC " + ucursor_inuse.GetHashCode());

            panelPlayfield.Controls.Add(uccr);

            uccb.Init(discoveryform, dnum);
            uccb.SetCursor(ucursor_inuse);
            uccb.LoadLayout();

            uccr.Font = discoveryform.theme.GetFont;        // Important. Apply font autoscaling to the user control
                                                            // ApplyToForm does not apply the font to the actual UC, only
                                                            // specific children controls.  The TabControl in the discoveryform ends up autoscaling most stuff
                                                            // the children directly attached to the discoveryform are not autoscaled

            discoveryform.theme.ApplyToControls(uccr, discoveryform.theme.GetFont);

            uccr.Location = pos;
            uccr.Size     = size;

            uccb.InitialDisplay();

            return(uccr);
        }
        public override void LoadLayout()                   // cursor now set up, initial setup complete..
        {
            ucursor_history = uctg;                         // record base one
            ucursor_inuse   = FindTHC() ?? ucursor_history; // if we have a THC, use it, else use the history one
            string splitctrl = SQLiteConnectionUser.GetSettingString(DbWindows, "");

            //System.Diagnostics.Debug.WriteLine("--------------------" + splitctrl);
            //panelPlayfield.Controls[0].DumpTree(0);

            (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..
                {
                    int tagid         = (int)c.Tag;
                    int displaynumber = DisplayNumberOfSplitter(tagid);                         // tab strip - use tag to remember display id which helps us save context.
                    System.Diagnostics.Trace.WriteLine("SP:Make UCCB " + uccb.GetType().Name + " tag " + tagid + " dno " + displaynumber);

                    uccb.Init(discoveryform, displaynumber);
                    uccb.SetCursor(ucursor_inuse);
                    uccb.LoadLayout();
                    discoveryform.theme.ApplyToControls(uccb);
                    uccb.InitialDisplay();
                }
            });

            Invalidate(true);
            Update();                                 // need this to FORCE a full refresh in case there are lots of windows

            UserControlTravelGrid tg = GetTravelGrid; // if travel grid, link up

            if (tg != null)
            {
                tg.OnKeyDownInCell += Tg_OnKeyDownInCell;
            }
        }
示例#9
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);
            }
        }
        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.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.GetPanelImages();
                tabstrip.TextList       = PanelInformation.GetPanelDescriptions();
                tabstrip.TagList        = PanelInformation.GetPanelIDs().Cast <Object>().ToArray();
                tabstrip.Dock           = DockStyle.Fill;
                tabstrip.DropDownWidth  = 500;
                tabstrip.DropDownHeight = 500;
                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.Closing();
                    AssignTHC();        // in case we removed anything
                };

                tabstrip.OnCreateTab += (tab, si) =>
                {
                    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.Name = pi.WindowTitle;                                                                                            // tabs uses Name field for display, must set it

                    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);
                        uc.SetCursor(ucursor_inuse);
                        uc.LoadLayout();
                        uc.InitialDisplay();
                    }

                    //System.Diagnostics.Debug.WriteLine("And theme {0}", i);
                    discoveryform.theme.ApplyToControls(tab);
                    AssignTHC();        // in case we added one
                };

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

                discoveryform.theme.ApplyToControls(tabstrip, applytothis: true);

                PanelInformation.PanelIDs[] pids = PanelInformation.GetPanelIDs();

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

                if (panelid >= 0)                                                              // if we have a panel, open it
                {
                    tabstrip.Create(panelid);                                                  // create but not post create yet...
                }

                return(tabstrip);
            }
        }