Пример #1
0
        public void LoadSavedPopouts()
        {
            foreach (PanelInformation.PanelIDs p in Enum.GetValues(typeof(PanelInformation.PanelIDs)))        // in terms of PanelInformation.PopOuts Enum
            {
                int numtoopen = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(PopOutSaveID(p), 0);

                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(p);

                //System.Diagnostics.Debug.WriteLine("Load panel type " + paneltype.Name + " " + p.ToString() + " " + numtoopen);

                if (pi != null && numtoopen > 0) // paranoia on first..
                {
                    System.Diagnostics.Debug.WriteLine($"Load Popout {p} {numtoopen}");

                    int numopened = usercontrolsforms.CountOf(pi.PopoutType);
                    if (numopened < numtoopen)
                    {
                        for (int i = numopened + 1; i <= numtoopen; i++)
                        {
                            PopOut(p);
                        }
                    }
                }
            }
        }
Пример #2
0
        public UserControlCommonBase PopOut(PanelInformation.PanelIDs selected)
        {
            Forms.UserControlForm tcf = usercontrolsforms.NewForm();
            tcf.Icon = Properties.Resources.edlogo_3mo_icon;

            UserControlCommonBase ctrl = PanelInformation.Create(selected);

            PanelInformation.PanelInfo poi = PanelInformation.GetPanelInfoByPanelID(selected);

            if (ctrl != null && poi != null)
            {
                int    numopened   = usercontrolsforms.CountOf(ctrl.GetType()) + 1;
                string windowtitle = poi.WindowTitle + " " + ((numopened > 1) ? numopened.ToString() : "");
                string refname     = poi.WindowRefName + numopened.ToString();

                System.Diagnostics.Trace.WriteLine("PO:Make " + windowtitle + " ucf " + ctrl.GetType().Name);

                //System.Diagnostics.Debug.WriteLine("TCF init");
                tcf.Init(ctrl, windowtitle, discoveryform.theme.WindowsFrame, refname, discoveryform.TopMost,
                         poi.DefaultTransparent, discoveryform.theme.LabelColor, discoveryform.theme.SPanelColor);

                //System.Diagnostics.Debug.WriteLine("UCCB init of " + ctrl.GetType().Name);
                ctrl.Init(discoveryform, UserControls.UserControlCommonBase.DisplayNumberPopOuts + numopened - 1);

                discoveryform.theme.ApplyStd(tcf);  // apply theming/scaling to form before shown, so that it restored back to correct position (done in UCF::onLoad)

                //System.Diagnostics.Debug.WriteLine("Show");
                tcf.Show();                                                     // this ends up, via Form Shown, calls LoadLayout in the UCCB.

                discoveryform.ActionRun(Actions.ActionEventEDList.onPopUp, null, new BaseUtils.Variables(new string[] { "PopOutName", refname, "PopOutTitle", windowtitle, "PopOutIndex", numopened.ToString() }));
            }

            return(ctrl);
        }
Пример #3
0
 internal void SaveCurrentPopouts()
 {
     foreach (PanelInformation.PanelIDs p in Enum.GetValues(typeof(PanelInformation.PanelIDs)))        // in terms of PanelInformation.PopOuts Enum
     {
         PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(p);
         if (pi != null) // paranoia
         {
             int numopened = usercontrolsforms.CountOf(pi.PopoutType);
             //System.Diagnostics.Debug.WriteLine("Saved panel type " + paneltype.Name + " " + p.ToString() + " " + numopened);
             SQLiteConnectionUser.PutSettingInt(EDDProfiles.Instance.UserControlsPrefix + "SavedPanelInformation.PopOuts:" + p.ToString(), numopened);
         }
     }
 }
Пример #4
0
 public void SaveCurrentPopouts()
 {
     foreach (PanelInformation.PanelIDs p in Enum.GetValues(typeof(PanelInformation.PanelIDs)))        // in terms of PanelInformation.PopOuts Enum
     {
         PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(p);
         if (pi != null) // paranoia
         {
             int numopened = usercontrolsforms.CountOf(pi.PopoutType);
             if (numopened > 0)
             {
                 System.Diagnostics.Debug.WriteLine($"Save Popout {p} {numopened}");
             }
             EliteDangerousCore.DB.UserDatabase.Instance.PutSettingInt(PopOutSaveID(p), numopened);
         }
     }
 }
Пример #5
0
        public UserControlCommonBase PopOut(PanelInformation.PanelIDs selected)
        {
            Forms.UserControlForm tcf = usercontrolsforms.NewForm();
            tcf.Icon = Properties.Resources.edlogo_3mo_icon;

            UserControlCommonBase ctrl = PanelInformation.Create(selected);

            PanelInformation.PanelInfo poi = PanelInformation.GetPanelInfoByPanelID(selected);

            if (ctrl != null && poi != null)
            {
                int    numopened   = usercontrolsforms.CountOf(ctrl.GetType()) + 1;
                string windowtitle = poi.WindowTitle + " " + ((numopened > 1) ? numopened.ToString() : "");
                string refname     = poi.WindowRefName + numopened.ToString();

                System.Diagnostics.Trace.WriteLine("PO:Make " + windowtitle + " ucf " + ctrl.GetType().Name);

                //System.Diagnostics.Debug.WriteLine("TCF init");
                tcf.Init(ctrl, windowtitle, discoveryform.theme.WindowsFrame, refname, discoveryform.TopMost,
                         poi.DefaultTransparent, discoveryform.theme.LabelColor, discoveryform.theme.SPanelColor);

                //System.Diagnostics.Debug.WriteLine("UCCB init of " + ctrl.GetType().Name);
                ctrl.Init(discoveryform, UserControls.UserControlCommonBase.DisplayNumberPopOuts + numopened - 1);

                //System.Diagnostics.Debug.WriteLine("Show");
                tcf.Show();                                                     // this ends up, via Form Shown, calls LoadLayout in the UCCB.

                if (tcf.UserControl != null)
                {
                    tcf.UserControl.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.ApplyToForm(tcf);

                discoveryform.ActionRun(Actions.ActionEventEDList.onPopUp, null, new BaseUtils.Variables(new string[] { "PopOutName", refname, "PopOutTitle", windowtitle, "PopOutIndex", numopened.ToString() }));
            }

            return(ctrl);
        }
Пример #6
0
        internal void LoadSavedPopouts()
        {
            foreach (PanelInformation.PanelIDs p in Enum.GetValues(typeof(PanelInformation.PanelIDs)))        // in terms of PanelInformation.PopOuts Enum
            {
                int numtoopen = SQLiteConnectionUser.GetSettingInt(EDDProfiles.Instance.UserControlsPrefix + "SavedPanelInformation.PopOuts:" + p.ToString(), 0);
                PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByPanelID(p);

                //System.Diagnostics.Debug.WriteLine("Load panel type " + paneltype.Name + " " + p.ToString() + " " + numtoopen);

                if (pi != null && numtoopen > 0) // paranoia on first..
                {
                    int numopened = usercontrolsforms.CountOf(pi.PopoutType);
                    if (numopened < numtoopen)
                    {
                        for (int i = numopened + 1; i <= numtoopen; i++)
                        {
                            PopOut(p);
                        }
                    }
                }
            }
        }
Пример #7
0
        // MAY return null!

        private TabPage CreateTab(PanelInformation.PanelIDs ptype, string name, int dn, int posindex)
        {
            // debug - create an example tab page
            // keep for now
            //TabPage page = new TabPage();
            //page.Location = new System.Drawing.Point(4, 22);    // copied from normal tab creation code
            //page.Padding = new System.Windows.Forms.Padding(3);
            //UserControl uc = new UserControl();
            //uc.Dock = DockStyle.Fill;
            //uc.AutoScaleMode = AutoScaleMode.Inherit;
            //page.Controls.Add(uc);
            //ExtendedControls.TabStrip ts = new ExtendedControls.TabStrip();
            //ts.Dock = DockStyle.Fill;
            //uc.Controls.Add(ts);
            //TabPages.Insert(posindex, page);


            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.AutoScaleMode = AutoScaleMode.Inherit;               // inherit will mean Font autoscale won't happen at attach
            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);

            if (dn == -1) // if work out display number
            {
                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 (!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);

            int numoftab = (dn == UserControls.UserControlCommonBase.DisplayNumberPrimaryTab) ? 0 : (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs + 1);

            if (uccb is UserControls.UserControlContainerSplitter && numoftab > 0)          // so history is a splitter, so first real splitter will be dn=100, adjust for it
            {
                numoftab--;
            }

            string postfix = numoftab == 0 ? "" : "(" + numoftab.ToStringInvariant() + ")";
            string title   = name != null ? name : (PanelInformation.GetPanelInfoByPanelID(ptype).WindowTitle + postfix);

            uccb.Name = title;              // for debugging use

            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); // this is to allow a pad around the sides

            page.Controls.Add(uccb);

            TabPages.Insert(posindex, page);        // with inherit above, no font autoscale

            //Init control after it is added to the form
            uccb.Init(eddiscovery, dn);                           // start the uccb up

            uccb.Scale(this.FindForm().CurrentAutoScaleFactor()); // scale and
            EDDTheme.Instance.ApplyStd(page);                     // theme it.  Order as per the contract in UCCB

            return(page);
        }
Пример #8
0
        public TabPage GetMajorTab(PanelInformation.PanelIDs ptype)
        {
            Type t = PanelInformation.GetPanelInfoByPanelID(ptype).PopoutType;

            return((from TabPage x in TabPages where x.Controls[0].GetType() == t select x).FirstOrDefault());
        }
Пример #9
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);

            if (dn == -1) // if work out display number
            {
                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 (!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);

            int numoftab = (dn == UserControls.UserControlCommonBase.DisplayNumberPrimaryTab) ? 0 : (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs + 1);

            if (uccb is UserControls.UserControlContainerSplitter && numoftab > 0)          // so history is a splitter, so first real splitter will be dn=100, adjust for it
            {
                numoftab--;
            }

            string postfix = numoftab == 0 ? "" : "(" + numoftab.ToStringInvariant() + ")";
            string title   = name != null ? name : (PanelInformation.GetPanelInfoByPanelID(ptype).WindowTitle + postfix);

            uccb.Name = title;              // for debugging use

            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);

            //Init control after it is added to the form
            uccb.Init(eddiscovery, dn); // start the uccb up

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

            return(page);
        }