コード例 #1
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);
        }
コード例 #2
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);
                }
            });
        }
コード例 #3
0
        private UserControlContainerResizable CreateInitPanel(UserControlCommonBase uccb)
        {
            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);

            panelPlayfield.Controls.Add(uccr);

            //System.Diagnostics.Trace.WriteLine("GD:Create " + uccb.GetType().Name + " " + dnum);
            uccb.Init(discoveryform, dnum);

            return(uccr);
        }
コード例 #4
0
        private void ButtonPress(Object o, int i)
        {
            int button = (int)o;

            System.Diagnostics.Debug.WriteLine("Selected " + button + " " + i);

            if (button == 999)
            {
                discoveryform.manageAddOnsToolStripMenuItem_Click(null, null);
            }
            else
            {
                PanelInformation.PanelInfo pi = PanelInformation.PanelList[button];

                if (i == 0)
                {
                    discoveryform.PopOuts.PopOut(pi.PopoutID);
                }
                else
                {
                    discoveryform.AddTab(pi.PopoutID, -1);   // add as last tab
                }
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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.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);
            }
        }
コード例 #7
0
        private void Redraw()
        {
            panelVScroll.SuspendLayout();

            panelVScroll.RemoveAllControls();

            // design for std 8.25 font sizes

            Bitmap backimage = new Bitmap(EDDiscovery.Icons.Controls.Selector);
            Color  centre = backimage.GetPixel(48, 48);
            Size   iconsize = new Size(24, 24);
            int    width = 96;
            int    padbot = 6, padbetween = 5;

            float brigthness = ExtendedControls.Theme.Current.Form.GetBrightness();
            Image selback    = brigthness < 0.3 ? EDDiscovery.Icons.Controls.Selector : EDDiscovery.Icons.Controls.Selector2;

            {
                Versions.VersioningManager mgr = new Versions.VersioningManager();
                AddOnManagerForm.ReadLocalFiles(mgr, true);

                int i = mgr.DownloadItems.Count;

                CompositeButton cb = CompositeButton.QuickInit(
                    selback,
                    (i == 0) ? "NO ADD ONS!".T(EDTx.UserControlPanelSelector_NOADDONS) : i.ToString() + " Add Ons".T(EDTx.UserControlPanelSelector_AddOns),
                    ExtendedControls.Theme.Current.GetFont,
                    (i == 0) ? Color.Red : (ExtendedControls.Theme.Current.TextBlockColor.GetBrightness() < 0.1 ? Color.AntiqueWhite : ExtendedControls.Theme.Current.TextBlockColor),
                    Color.Transparent,
                    EDDiscovery.Icons.Controls.ManageAddOns, iconsize,
                    new Image[] { EDDiscovery.Icons.Controls.ManageAddOns }, iconsize,
                    padbetween,
                    ButtonPress);

                panelVScroll.Controls.Add(cb);
                cb.Name = "Add on";
                cb.Tag  = null;
                toolTip.SetToolTip(cb.Buttons[0], "Click to add or remove Add Ons".T(EDTx.UserControlPanelSelector_TTA));
                toolTip.SetToolTip(cb.Decals[0], "Add ons are essential additions to your EDD experience!".T(EDTx.UserControlPanelSelector_TTB));

                ExtendedControls.Theme.Current.ApplyStd(cb);       // need to theme up the button
                cb.Size                 = new Size(width, cb.FindMaxSubControlArea(0, padbot).Height);
                cb.Label.BackColor      = cb.Decals[0].BackColor = Color.Transparent;
                cb.Buttons[0].BackColor = centre;   // but then fix the back colour again
            }

            PanelInformation.PanelIDs[] pids = PanelInformation.GetUserSelectablePanelIDs(EDDConfig.Instance.SortPanelsByName);

            for (int i = 0; i < pids.Length; i++)
            {
                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(pids[i]);

                CompositeButton cb = CompositeButton.QuickInit(
                    selback,
                    pi.WindowTitle,
                    ExtendedControls.Theme.Current.GetFont,
                    ExtendedControls.Theme.Current.TextBlockColor.GetBrightness() < 0.1 ? Color.AntiqueWhite : ExtendedControls.Theme.Current.TextBlockColor,
                    Color.Transparent,
                    pi.TabIcon, iconsize,
                    new Image[] { EDDiscovery.Icons.Controls.Popout, EDDiscovery.Icons.Controls.AddTab }, iconsize,
                    padbetween,
                    ButtonPress);
                cb.SuspendLayout();
                panelVScroll.Controls.Add(cb);
                cb.Tag = pi.PopoutID;
                toolTip.SetToolTip(cb.Buttons[0], "Pop out in a new window".T(EDTx.UserControlPanelSelector_PP1));
                toolTip.SetToolTip(cb.Buttons[1], "Open as a new menu tab".T(EDTx.UserControlPanelSelector_MT1));
                toolTip.SetToolTip(cb.Decals[0], pi.Description);

                ExtendedControls.Theme.Current.ApplyStd(cb);
                cb.ResumeLayout();

                cb.Size                 = new Size(width, cb.FindMaxSubControlArea(0, padbot).Height);
                cb.Label.BackColor      = cb.Decals[0].BackColor = Color.Transparent;
                cb.Buttons[0].BackColor = centre; // need to reset the colour back!
                cb.Buttons[1].BackColor = centre; // need to reset the colour back!
            }

            panelVScroll.Scale(this.FindForm().CurrentAutoScaleFactor());
            Reposition();

            panelVScroll.ResumeLayout();
        }
コード例 #8
0
        private void Redraw()
        {
            panelVScroll.SuspendLayout();

            panelVScroll.RemoveAllControls();

            Bitmap backimage = new Bitmap(EDDiscovery.Icons.Controls.Selector_Background);
            Color  centre    = backimage.GetPixel(48, 48);


            {
                Versions.VersioningManager mgr = new Versions.VersioningManager();
                AddOnManagerForm.ReadLocalFiles(mgr, true);

                int i = mgr.DownloadItems.Count;

                CompositeButton cb = new CompositeButton();
                cb.Size    = panelsize;
                cb.Tag     = 999;
                cb.Padding = new Padding(10);
                cb.QuickInit(EDDiscovery.Icons.Controls.Selector_Background,
                             (i == 0) ? "NO ADD ONS!".Tx(this) : i.ToString() + " Add Ons".Tx(this),
                             EDDTheme.Instance.GetFontAtSize(11),
                             (i == 0) ? Color.Red : (EDDTheme.Instance.TextBlockColor.GetBrightness() < 0.1 ? Color.AntiqueWhite : EDDTheme.Instance.TextBlockColor),
                             centre,
                             EDDiscovery.Icons.Controls.Main_Addons_ManageAddOns,
                             new Size(48, 48),
                             new Image[] { EDDiscovery.Icons.Controls.Main_Addons_ManageAddOns },
                             new Size(48, 48),
                             ButtonPress);

                toolTip.SetToolTip(cb.Buttons[0], "Click to add or remove Add Ons".Tx(this, "TTA"));
                toolTip.SetToolTip(cb.Decals[0], "Add ons are essential additions to your EDD experience!".Tx(this, "TTB"));
                panelVScroll.Controls.Add(cb);
                EDDTheme.Instance.ApplyToControls(cb.Buttons[0], null, true); // need to theme up the button
                cb.Buttons[0].BackColor = centre;                             // but then fix the back colour again
            }

            PanelInformation.PanelIDs[] pids = PanelInformation.GetUserSelectablePanelIDs(EDDConfig.Instance.SortPanelsByName);

            for (int i = 0; i < pids.Length; i++)
            {
                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(pids[i]);

                CompositeButton cb = new CompositeButton();
                cb.Size    = panelsize;
                cb.Tag     = pi.PopoutID;
                cb.Padding = new Padding(10);
                cb.QuickInit(EDDiscovery.Icons.Controls.Selector_Background,
                             pi.WindowTitle,
                             EDDTheme.Instance.GetFontAtSize(11),
                             EDDTheme.Instance.TextBlockColor.GetBrightness() < 0.1 ? Color.AntiqueWhite : EDDTheme.Instance.TextBlockColor,
                             centre,
                             pi.TabIcon,
                             new Size(48, 48),
                             new Image[] { EDDiscovery.Icons.Controls.TabStrip_Popout, EDDiscovery.Icons.Controls.Selector_AddTab },
                             new Size(48, 48),
                             ButtonPress);
                toolTip.SetToolTip(cb.Buttons[0], "Pop out in a new window".Tx(this, "PP1"));
                toolTip.SetToolTip(cb.Buttons[1], "Open as a new menu tab".Tx(this, "MT1"));
                toolTip.SetToolTip(cb.Decals[0], pi.Description);
                EDDTheme.Instance.ApplyToControls(cb.Buttons[0], null, true);
                cb.Buttons[0].BackColor = centre; // need to reset the colour back!
                EDDTheme.Instance.ApplyToControls(cb.Buttons[1], null, true);
                cb.Buttons[1].BackColor = centre;

                panelVScroll.Controls.Add(cb);       // we don't theme it.. its already fully themed to a fixed theme.
            }

            Reposition();

            panelVScroll.ResumeLayout();
        }