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); }
//EDDiscovery Init calls this public void CreateTabs(EDDiscoveryForm edf, bool resettabs, string resetsettings) { eddiscovery = edf; int[] panelids; int[] displaynumbers; int restoretab = 0; string majortabs = SQLiteConnectionUser.GetSettingString("MajorTabControlList", ""); string[] majortabnames = SQLiteConnectionUser.GetSettingString("MajorTabControlName", "").Replace("!error!", "+").Split(';'); // if its okay, load the name list while (true) { int[] rawtabctrl; majortabs.RestoreArrayFromString(out rawtabctrl); panelids = rawtabctrl.Where((value, index) => index % 2 != 0).ToArray(); displaynumbers = rawtabctrl.Where((value, index) => index > 0 && index % 2 == 0).ToArray(); if (resettabs || panelids.Length == 0 || panelids.Length != displaynumbers.Length || !panelids.Contains(-1) || !panelids.Contains((int)PanelInformation.PanelIDs.PanelSelector)) { majortabs = resetsettings; majortabnames = null; resettabs = false; } else { if (rawtabctrl[0] > 0 && rawtabctrl[0] < panelids.Length) { restoretab = rawtabctrl[0]; } break; } } for (int i = 0; i < panelids.Length; i++) { string name = majortabnames != null && i < majortabnames.Length && majortabnames[i].Length > 0 ? majortabnames[i] : null; try { if (panelids[i] == -1) { TabPage p = CreateTab(PanelInformation.PanelIDs.SplitterControl, name ?? "History", displaynumbers[i], TabPages.Count, false); // no need the theme, will be themed as part of overall load p.Tag = true; // this marks it as the primary tab.. } else { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)panelids[i]; CreateTab(p, name, displaynumbers[i], TabPages.Count, false); // no need the theme, will be themed as part of overall load } } catch { } // paranoia in case something crashes it, unlikely, but we want maximum chance the history tab will show } SelectedIndex = restoretab; }
internal void SaveCurrentPopouts() { foreach (int i in Enum.GetValues(typeof(PanelInformation.PanelIDs))) // in terms of PanelInformation.PopOuts Enum { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)i; UserControlCommonBase ctrl = PanelInformation.Create(p); int numopened = ctrl == null ? 0 : usercontrolsforms.CountOf(ctrl.GetType()); SQLiteConnectionUser.PutSettingInt("SavedPanelInformation.PopOuts:" + ((PanelInformation.PanelIDs)i).ToString(), numopened); } }
List <Tuple <PanelInformation.PanelIDs, Point, Size, int> > GetSavedSettings() { string[] names = GetSetting(dbWindowNames, "").Split(','); int[] positions; int[] zorder; string pos = GetSetting(dbPositionSize, ""); string zo = GetSetting(dbZOrder, ""); if (pos.RestoreArrayFromString(out positions) && zo.RestoreArrayFromString(out zorder, 0, names.Length - 1) && names.Length == zorder.Length && positions.Length == 4 * names.Length) { var ret = new List <Tuple <PanelInformation.PanelIDs, Point, Size, int> >(); for (int i = 0; i < names.Length; i++) { PanelInformation.PanelIDs pid = PanelInformation.PanelIDs.Log; if (names[i].Contains("UserControl")) { Type t = Type.GetType("EDDiscovery.UserControls." + names[i]); // previously saved by name, now we are going to save by id from now on for future use if (t == null) { return(null); } var pi = PanelInformation.GetPanelInfoByType(t); // look it up if (pi == null) { return(null); } pid = pi.PopoutID; } else { pid = (PanelInformation.PanelIDs)names[i].InvariantParseInt(0); // convert to panel ID, default is 0 (log) } int ppos = i * 4; ret.Add(new Tuple <PanelInformation.PanelIDs, Point, Size, int>(pid, new Point(positions[ppos++], positions[ppos++]), new Size(positions[ppos++], positions[ppos++]), zorder[i])); } return(ret); } else { return(null); } }
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, true); if (page != null) { UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase; uccb.LoadLayout(); uccb.InitialDisplay(); SelectedIndex = tabindex; // and select the inserted one } }
public TabPage EnsureMajorTabIsPresent(PanelInformation.PanelIDs ptype, bool selectit) { TabPage page = GetMajorTab(ptype); if (page == null) { page = CreateTab(ptype, null, -1, TabCount, true); UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase; uccb.LoadLayout(); uccb.InitialDisplay(); } if (selectit) { SelectTab(page); } return(page); }
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); }
internal void LoadSavedPopouts() { foreach (int ip in Enum.GetValues(typeof(PanelInformation.PanelIDs))) // in terms of PopOut ENUM { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)ip; int numToOpen = SQLiteConnectionUser.GetSettingInt("SavedPanelInformation.PopOuts:" + p.ToString(), 0); if (numToOpen > 0) { UserControlCommonBase ctrl = PanelInformation.Create(p); int numOpened = ctrl == null ? 0 : usercontrolsforms.CountOf(ctrl.GetType()); if (numOpened < numToOpen) { for (int i = numOpened + 1; i <= numToOpen; i++) { PopOut(p); } } } } }
private void ButtonPress(Object o, int i) { Object cbtag = ((CompositeButton)o).Tag; if (cbtag is null) // tag being null means { discoveryform.manageAddOnsToolStripMenuItem_Click(null, null); } else { PanelInformation.PanelIDs pid = (PanelInformation.PanelIDs)cbtag; System.Diagnostics.Debug.WriteLine("Selected " + pid + " " + i); if (i == 0) { discoveryform.PopOuts.PopOut(pid); } else { discoveryform.AddTab(pid, -1); // add as last tab } } }
private void ButtonPress(Object o, int i) { int button = (int)o; if (button == 999) { discoveryform.manageAddOnsToolStripMenuItem_Click(null, null); } else { PanelInformation.PanelIDs pid = (PanelInformation.PanelIDs)o; System.Diagnostics.Debug.WriteLine("Selected " + pid + " " + i); if (i == 0) { discoveryform.PopOuts.PopOut(pid); } else { discoveryform.AddTab(pid, -1); // add as last tab } } }
//EDDiscovery Init calls this public void CreateTabs(EDDiscoveryForm edf, bool resettabs, string resetsettings) { eddiscovery = edf; int[] panelids; int[] displaynumbers; int currentlyselectedtab = 0; string majortabs = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(EDDProfiles.Instance.UserControlsPrefix + "MajorTabControlList", ""); string[] majortabnames = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(EDDProfiles.Instance.UserControlsPrefix + "MajorTabControlName", "").Replace("!error!", "+").Split(';'); // if its okay, load the name list while (true) { int[] rawtabctrl; majortabs.RestoreArrayFromString(out rawtabctrl); // string is : selectedtab, [ <PanelID>, <displayno> ].. panelids = rawtabctrl.Where((value, index) => index % 2 != 0).ToArray(); displaynumbers = rawtabctrl.Where((value, index) => index > 0 && index % 2 == 0).ToArray(); if (resettabs || panelids.Length == 0 || panelids.Length != displaynumbers.Length || !panelids.Contains(-1) || !panelids.Contains((int)PanelInformation.PanelIDs.PanelSelector)) { majortabs = resetsettings; majortabnames = null; resettabs = false; } else { if (rawtabctrl[0] > 0 && rawtabctrl[0] < panelids.Length) { currentlyselectedtab = rawtabctrl[0]; } break; } } for (int i = 0; i < panelids.Length; i++) { string name = majortabnames != null && i < majortabnames.Length && majortabnames[i].Length > 0 ? majortabnames[i] : null; try { if (panelids[i] == -1) // marker indicating the special history tab { TabPage p = CreateTab(PanelInformation.PanelIDs.SplitterControl, name ?? "History", displaynumbers[i], TabPages.Count); p.Tag = true; // this marks it as the primary tab.. } else { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)panelids[i]; CreateTab(p, name, displaynumbers[i], TabPages.Count); // no need the theme, will be themed as part of overall load } } catch (Exception ex) // paranoia in case something crashes it, unlikely, but we want maximum chance the history tab will show { System.Diagnostics.Trace.WriteLine($"Exception caught creating tab {i} ({name}): {ex.ToString()}"); MessageBox.Show($"Report to EDD team - Exception caught creating tab {i} ({name}): {ex.ToString()}"); } } SelectedIndex = currentlyselectedtab; }
// 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); }
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()); }
// 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); 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 (dn == -1) // if work out display number { // not travel grid (due to clash with History control) and not in list, use primary number (0) if (ptype != PanelInformation.PanelIDs.TravelGrid && !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); uccb.Init(eddiscovery, travelgrid, dn); // start the uccb up string postfix; if (ptype != PanelInformation.PanelIDs.TravelGrid) // given the dn, work out the name { postfix = (dn == UserControls.UserControlCommonBase.DisplayNumberPrimaryTab) ? "" : "(" + (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs + 1).ToStringInvariant() + ")"; } else { postfix = (dn == UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs) ? "" : "(" + (dn - UserControls.UserControlCommonBase.DisplayNumberStartExtraTabs).ToStringInvariant() + ")"; } string title = name != null ? name : (PanelInformation.GetPanelInfoByEnum(ptype).WindowTitle + postfix); 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); if (dotheme) // only user created ones need themeing { EDDTheme.Instance.ApplyToControls(page, applytothis: true); } return(page); }
private static string PopOutSaveID(PanelInformation.PanelIDs p) { return(EDDProfiles.Instance.UserControlsPrefix + "SavedPanelInformation.PopOuts:" + p.ToString()); }
// 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); }
public void PopOut(PanelInformation.PanelIDs selected) { int index = PanelInformation.PanelList.FindIndex(x => x.PopoutID == selected); PopOut(index); }
//EDDiscovery Init calls this public void CreateTabs(EDDiscoveryForm edf) { eddiscovery = edf; string majortabs = SQLiteConnectionUser.GetSettingString("MajorTabControlList", ""); string[] majortabnames = null; int[] tabctrl; if (!majortabs.RestoreArrayFromString(out tabctrl) || tabctrl.Length == 0 || (tabctrl.Length % 2) != 1) // need it odd as we have an index tab as first { tabctrl = new int[] { 0, -1, 0, // reset.. (int)PanelInformation.PanelIDs.Route, 0, (int)PanelInformation.PanelIDs.Expedition, 0, (int)PanelInformation.PanelIDs.Settings, 0, (int)PanelInformation.PanelIDs.PanelSelector, 0 }; } else { majortabnames = SQLiteConnectionUser.GetSettingString("MajorTabControlName", "").Replace("!error!", "+").Split(';'); // if its okay, load the name list } TabPage history = TabPages[0]; // remember history page, remove TabPages.Clear(); UserControls.UserControlHistory uch = history.Controls[0] as UserControls.UserControlHistory; travelgrid = uch.GetTravelGrid; // remember travel grid globally for later bool donehistory = false; for (int i = 1; i < tabctrl.Length; i += 2) { int nameindex = (i - 1) / 2; string name = majortabnames != null && nameindex < majortabnames.Length && majortabnames[nameindex].Length > 0 ? majortabnames[nameindex] : null; if (tabctrl[i] != -1) // this means UserControlHistory, which is a special one { try { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)tabctrl[i]; CreateTab(p, name, tabctrl[i + 1], TabPages.Count, false); // no need the theme, will be themed as part of overall load // may fail if p is crap, then just ignore } catch { } // paranoia in case tabctrl number is crappy. } else if (!donehistory) // just double check for repeats { if (name != null) // set name. if set. { history.Text = name; } TabPages.Add(history); // add back in right place donehistory = true; } } if (!donehistory) // just in case its missing.. be something up if it is. { TabPages.Add(history); // add back in right place } uch.Dock = System.Windows.Forms.DockStyle.Fill; // Crucial ! uccb has to be fill, even though the VS designer does not indicate you need to set it.. copied from designer code uch.Location = new System.Drawing.Point(3, 3); uch.Init(eddiscovery, null, UserControls.UserControlCommonBase.DisplayNumberHistoryGrid); // and init at this point with 0 as dn EnsureMajorTabIsPresent(PanelInformation.PanelIDs.PanelSelector, true); // just in case it disappears due to weirdness or debugging if (tabctrl.Length > 0 && tabctrl[0] >= 0 && tabctrl[0] < TabPages.Count) // make sure external data does not crash us { SelectedIndex = tabctrl[0]; } }