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); discoveryform.theme.ApplyToControls(uccr, discoveryform.theme.GetFont); return(uccr); }
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(uc.GetType().Name, ","); p = p.AppendPrePad(r.Location.X + "," + r.Location.Y + "," + r.Size.Width + "," + r.Size.Height, ","); System.Diagnostics.Debug.WriteLine(" Save " + uc.GetType().Name); uc.Closing(); } SQLiteConnectionUser.PutSettingString(DbWindows, s); SQLiteConnectionUser.PutSettingString(DbPositions, p); string z = ""; foreach (Control c in panelPlayfield.Controls) { if (c is UserControlContainerResizable) { z = z.AppendPrePad(uccrlist.FindIndex(x => x.Equals(c)).ToStringInvariant(), ","); } } SQLiteConnectionUser.PutSettingString(DbZOrder, z); System.Diagnostics.Debug.WriteLine("---- END Grid Saving to " + DbWindows); }
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(uc.GetType().Name, ","); 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(); } EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(DBWindowNames, s); EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(DbPositionSize, p); 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 ); } } EliteDangerousCore.DB.UserDatabase.Instance.PutSettingString(DbZOrder, z); //System.Diagnostics.Debug.WriteLine("---- END Grid Saving to " + DbWindows); }
private UserControlContainerResizable CreatePanel(UserControlCommonBase uccb, Point pos, Size size) { UserControlContainerResizable uccr = new UserControlContainerResizable(); PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByType(uccb.GetType()); uccr.Init(uccb, pi.WindowTitlePrefix); 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 = DisplayNumberOfGridInstance(numopenedinside); //System.Diagnostics.Debug.WriteLine(" Create " + uccb.GetType().Name + " " + dnum + " Assign THC " + ucursor_inuse.GetHashCode() ); panelPlayfield.Controls.Add(uccr); uccb.Init(discoveryform, ucursor_inuse, dnum); 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(); if (uccb is UserControlTravelGrid) { (uccb as UserControlTravelGrid).ExtraIcons(true, false); } if (uccb is UserControlJournalGrid) { (uccb as UserControlJournalGrid).ExtraIcons(true, false); } return(uccr); }
public UserControlCommonBase FindUserControl(Type c) { if (UserControl != null && UserControl.GetType().Equals(c)) { return(UserControl); } else { return(null); } }
public void CloseTabList() { List <int> idlist = new List <int>(); idlist.Add(SelectedIndex); // first is current index string tabnames = ""; foreach (TabPage p in TabPages) // all main tabs, load/display { UserControls.UserControlCommonBase uccb = p.Controls[0] as UserControls.UserControlCommonBase; uccb.Closing(); PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByType(uccb.GetType()); idlist.Add(pi != null ? (int)pi.PopoutID : -1); idlist.Add(uccb.displaynumber); tabnames += p.Text + ";"; } SQLiteConnectionUser.PutSettingString("MajorTabControlList", string.Join(",", idlist)); SQLiteConnectionUser.PutSettingString("MajorTabControlName", tabnames); }
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); }
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; } }
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 = ExtendedControls.Theme.Current.GridBorderLines; uccr.SelectedBorderColor = ExtendedControls.Theme.Current.TextBlockHighlightColor; int numopenedinsidealready = uccrlist.Count(x => x.control.GetType().Equals(uccb.GetType())); // how many others are there BEFORE add uccrlist.Add(uccr); int dnum = DisplayNumberOfGrid(numopenedinsidealready); // will be at least 1 (si panelPlayfield.Controls.Add(uccr); //System.Diagnostics.Trace.WriteLine("GD:Create " + uccb.GetType().Name + " " + dnum + " " + numopenedinsidealready); uccb.Init(discoveryform, dnum); return(uccr); }
// 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); }
// 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); }
// 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); }