public void Init(EDDiscovery.UserControls.UserControlCommonBase c, string title, bool winborder, string rf, bool deftopmostp = false, bool defwindowintaskbar = true) { UserControl = c; c.Dock = DockStyle.None; c.Location = new Point(0, 10); c.Size = new Size(200, 200); this.Controls.Add(c); transparencycolor = c.ColorTransparency; wintitle = label_index.Text = this.Text = title; // label index always contains the wintitle, but may not be shown curwindowsborder = defwindowsborder = winborder; dbrefname = "PopUpForm" + rf; this.Name = rf; deftopmost = deftopmostp; deftransparent = false; labelControlText.Text = ""; // always starts blank.. this.ShowInTaskbar = SQLiteDBClass.GetSettingBool(dbrefname + "Taskbar", defwindowintaskbar); displayTitle = SQLiteDBClass.GetSettingBool(dbrefname + "ShowTitle", true); UpdateControls(); Invalidate(); }
public void Init(EDDiscovery.UserControls.UserControlCommonBase c, string title, bool winborder, string rf, bool deftopmostp, bool deftransparentp, Color labelnormal, Color labeltransparent) { UserControl = c; c.Dock = DockStyle.None; c.Location = new Point(0, 10); c.Size = new Size(200, 200); this.Controls.Add(c); deftransparent = deftransparentp; // only applied if allowed to be transparent. labelnormalcolour = labelnormal; labeltransparentcolour = labeltransparent; transparencycolor = c.ColorTransparency; wintitle = label_index.Text = this.Text = title; // label index always contains the wintitle, but may not be shown curwindowsborder = defwindowsborder = winborder; dbrefname = "PopUpForm" + rf; this.Name = rf; deftopmost = deftopmostp; deftransparent = false; labelControlText.Text = ""; // always starts blank.. this.ShowInTaskbar = SQLiteDBClass.GetSettingBool(dbrefname + "Taskbar", true); displayTitle = SQLiteDBClass.GetSettingBool(dbrefname + "ShowTitle", true); #if !__MonoCS__ idk = DirectInputDevices.InputDeviceKeyboard.CreateKeyboard(); #endif UpdateControls(); Invalidate(); }
public UserControls.UserControl3DMap Open3DMap() // Current map - open at last position or configured position { var t3dmap = typeof(UserControls.UserControl3DMap); UserControls.UserControlCommonBase uccb = null; var tabfind3dmap = tabControlMain.Find(t3dmap); if (tabfind3dmap != null) { tabControlMain.SelectTab(tabfind3dmap.Item1); // goto tab uccb = tabfind3dmap.Item2; } else { var findpopoutform = PopOuts.FindUCCB(t3dmap); if (findpopoutform != null) { uccb = findpopoutform.UserControl; } } if (uccb == null) // none found, make one, on major tab { var tp = tabControlMain.EnsureMajorTabIsPresent(PanelInformation.PanelIDs.Map3D, true); uccb = (UserControls.UserControlCommonBase)tp.Controls[0]; } return((UserControls.UserControl3DMap)uccb); }
public void AddUserControl(EDDiscovery.UserControls.UserControlCommonBase c) { UserControl = c; c.Dock = DockStyle.None; c.Location = new Point(0, 10); c.Size = new Size(200, 200); this.Controls.Add(c); }
private void TabControlForm_Activated(object sender, EventArgs e) { isactive = true; foreach (TabPage tp in ctc.TabPages) { EDDiscovery.UserControls.UserControlCommonBase ucb = (EDDiscovery.UserControls.UserControlCommonBase)tp.Controls[0]; ucb.LoadLayout(); } }
public void RemoveTab(TabPage page) // from right click menu { UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase; if (uccb.AllowClose()) // it must allow a close to remove it { uccb.CloseDown(); page.Dispose(); } }
public void RemoveTab(int tabIndex) // from right click menu { if (tabIndex >= 0 && tabIndex < TabPages.Count) { TabPage page = TabPages[tabIndex]; UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase; uccb.CloseDown(); page.Dispose(); } }
public bool AllowClose() // tabs are closing, does all tabs allow close { foreach (TabPage p in TabPages) { UserControls.UserControlCommonBase uccb = p.Controls[0] as UserControls.UserControlCommonBase; if (uccb.AllowClose() == false) { return(false); } } return(true); }
public void AddUserControlTab(EDDiscovery.UserControls.UserControlCommonBase c, string title, int iconindex = -1) { c.Dock = DockStyle.Fill; TabPage tp = new TabPage(); tp.ImageIndex = iconindex; tp.Text = title; tp.Controls.Add(c); ctc.TabPages.Add(tp); }
bool checkmulticall = false; // debug for now public override void LoadLayout() { System.Diagnostics.Debug.Assert(checkmulticall == false); checkmulticall = true; // examples seen of multi call, lets trap it System.Diagnostics.Debug.WriteLine("Grid Restore from " + DbWindows); string[] names = SQLiteConnectionUser.GetSettingString(DbWindows, "").Split(','); int[] positions; int[] zorder; string pos = SQLiteConnectionUser.GetSettingString(DbPositions, ""); string zo = SQLiteConnectionUser.GetSettingString(DbZOrder, ""); SuspendLayout(); if (pos.RestoreArrayFromString(out positions) && zo.RestoreArrayFromString(out zorder, 0, names.Length - 1) && names.Length == zorder.Length && positions.Length == 4 * names.Length) { int ppos = 0; foreach (string n in names) { Type t = Type.GetType("EDDiscovery.UserControls." + n); if (t != null) { UserControlCommonBase uccb = (UserControlCommonBase)Activator.CreateInstance(t); CreatePanel(uccb, new Point(positions[ppos++], positions[ppos++]), new Size(positions[ppos++], positions[ppos++])); } } ppos = 0; foreach (int item in zorder) { UserControlContainerResizable uccr = uccrlist[item]; panelPlayfield.Controls.SetChildIndex(uccr, ppos++); } } ResumeLayout(); Invalidate(true); Update(); // need this to FORCE a full refresh in case there are lots of windows System.Diagnostics.Debug.WriteLine("----- Grid Restore END " + DbWindows); UpdateButtons(); AssignTHC(); }
public override void Init() { tabStrip.ImageList = new Image[] { EDDiscovery.Icons.Controls.CaptainsLog_Diary, EDDiscovery.Icons.Controls.CaptainsLog_Entries }; tabStrip.TextList = new string[] { "Diary".T(EDTx.UserControlCaptainsLog_Diary), "Entries".T(EDTx.UserControlCaptainsLog_Entries) }; tabStrip.TagList = new Type[] { typeof(CaptainsLogDiary), typeof(CaptainsLogEntries) }; 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.LoadLayout(); uccb.InitialDisplay(); if (uccb is CaptainsLogDiary) { (uccb as CaptainsLogDiary).ClickedonDate = (d, b) => { gotodate = d; createnew = b; tabStrip.SelectedIndex = 1; }; } else if (uccb is CaptainsLogEntries) { if (gotodate.HasValue) { var clentries = uccb as CaptainsLogEntries; System.Diagnostics.Debug.WriteLine("Goto " + gotodate); clentries.SelectDate(gotodate.Value, createnew); gotodate = null; } } }; tabStrip.OnRemoving += (tab, ctrl) => { UserControlCommonBase uccb = ctrl as UserControlCommonBase; uccb.CloseDown(); }; }
void TabPostCreate(ExtendedControls.TabStrip t, Control ctrl, int i) // called by tab strip after control has been added.. { // now we can do the configure of it, with the knowledge the tab has the right size int displaynumber = (int)t.Tag; // tab strip - use tag to remember display id which helps us save context. UserControlCommonBase uc = ctrl as UserControlCommonBase; if (uc != null) { uc.Init(discoveryform, userControlTravelGrid, displaynumber); uc.LoadLayout(); uc.InitialDisplay(); } //System.Diagnostics.Debug.WriteLine("And theme {0}", i); discoveryform.theme.ApplyToControls(t); }
public void HelpOn(Form parent, System.Drawing.Point pt, int tabIndex) { if (tabIndex >= 0 && tabIndex < TabPages.Count) { TabPage page = TabPages[tabIndex]; if (page.Tag != null) { EDDHelp.HistoryTab(parent, pt); } else { UserControls.UserControlCommonBase uccb = page.Controls[0] as UserControls.UserControlCommonBase; EDDHelp.Help(parent, pt, uccb); } } }
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 void LoadTabs() // called on Loading.. { //foreach (TabPage tp in tabControlMain.TabPages) System.Diagnostics.Debug.WriteLine("TP Size " + tp.Controls[0].DisplayRectangle); 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.LoadLayout(); uccb.InitialDisplay(); } //foreach (TabPage tp in tabControlMain.TabPages) System.Diagnostics.Debug.WriteLine("TP Size " + tp.Controls[0].DisplayRectangle); }
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 } }
private void TabControlForm_FormClosing(object sender, FormClosingEventArgs e) { isactive = false; foreach (TabPage tp in ctc.TabPages) { EDDiscovery.UserControls.UserControlCommonBase ucb = (EDDiscovery.UserControls.UserControlCommonBase)tp.Controls[0]; ucb.Closing(); } string root = "PopUpForm" + displaynumber; SQLiteDBClass.PutSettingInt(root + "Width", this._formWidth); SQLiteDBClass.PutSettingInt(root + "Height", this._formHeight); SQLiteDBClass.PutSettingInt(root + "Top", this._formTop); SQLiteDBClass.PutSettingInt(root + "Left", this._formLeft); SQLiteDBClass.PutSettingInt(root + "Tab", ctc.SelectedIndex); }
public List <UserControlCommonBase> GetListOfControls(Type c) { List <UserControlCommonBase> lc = new List <UserControlCommonBase>(); foreach (UserControlForm tcf in tabforms) { if (tcf.IsLoaded) { UserControlCommonBase uc = tcf.FindUserControl(c); if (uc != null) { lc.Add(uc); } } } return(lc); }
private IHistoryCursor FindTHC() { UserControlCommonBase v = null; panelPlayfield.Controls[0].RunActionOnTree((c) => c.GetType() == typeof(UserControlTravelGrid), (c) => { v = c as UserControlCommonBase; }); // see if we can find a TG if (v == null) { panelPlayfield.Controls[0].RunActionOnTree((c) => c.GetType() == typeof(UserControlJournalGrid), (c) => { v = c as UserControlCommonBase; }); // see if we can find a TG } if (v == null) { panelPlayfield.Controls[0].RunActionOnTree((c) => c.GetType() == typeof(UserControlStarList), (c) => { v = c as UserControlCommonBase; }); // see if we can find a TG } IHistoryCursor uctgfound = (v != null) ? (v as IHistoryCursor) : null; // if found, set to it return(uctgfound); }
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 void Init(EDDiscovery.UserControls.UserControlCommonBase c, string title, bool winborder, string rf, bool deftopmostp, bool deftransparentp, Color labelnormal, Color labeltransparent) { //System.Diagnostics.Debug.WriteLine("UCF Init+"); RestoreFormPositionRegKey = "PopUpForm" + rf; // position remember key UserControl = c; c.Dock = DockStyle.None; c.Location = new Point(0, 10); c.Size = new Size(200, 200); this.Controls.Add(c); deftransparent = deftransparentp; // only applied if allowed to be transparent. labelnormalcolour = labelnormal; labeltransparentcolour = labeltransparent; transparencycolor = c.ColorTransparency; wintitle = label_index.Text = this.Text = title; // label index always contains the wintitle, but may not be shown curwindowsborder = defwindowsborder = winborder; dbrefname = "PopUpForm" + rf; this.Name = rf; deftopmost = deftopmostp; deftransparent = false; labelControlText.Text = ""; // always starts blank.. this.ShowInTaskbar = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(dbrefname + "Taskbar", true); displayTitle = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(dbrefname + "ShowTitle", true); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { idk = DirectInputDevices.InputDeviceKeyboard.CreateKeyboard(); } UpdateControls(); Invalidate(); BaseUtils.Translator.Instance.Translate(toolTip1, this); //System.Diagnostics.Debug.WriteLine("UCF Init-"); }
public override void SetTransparency(bool on, Color curcol) { //System.Diagnostics.Debug.WriteLine("Splitter panel to tx " + on + " " + curcol); this.BackColor = curcol; panelPlayfield.BackColor = curcol; (panelPlayfield.Controls[0] as SplitContainer).RunActionOnSplitterTree((p, c) => // runs on each split panel node exactly.. { ExtendedControls.TabStrip ts = c as ExtendedControls.TabStrip; ts.StripBackColor = curcol; // make sure the strip gets the correct colour.. UserControlCommonBase uccb = (ts != null ? (ts.CurrentControl) : c) as UserControlCommonBase; if (uccb != null) // tab strip may not have a control set.. { uccb.SetTransparency(on, curcol); } }); }
public void Init(EDDiscovery.UserControls.UserControlCommonBase c, string title, bool winborder, string rf, bool deftopmostp, Color labelnormal, Color labeltransparent, Color transparentkey) { //System.Diagnostics.Debug.WriteLine("UCF Init+"); RestoreFormPositionRegKey = "PopUpForm" + rf; // position remember key UserControl = c; UserControl.Dock = DockStyle.None; UserControl.Location = new Point(0, 10); UserControl.Size = new Size(200, 200); this.Controls.Add(c); labelnormalcolour = labelnormal; labeltransparentcolour = labeltransparent; TransparencyColorKey = UserControl.SupportTransparency ? transparentkey : Color.Transparent; WinTitle = label_index.Text = this.Text = title; // label index always contains the wintitle, but may not be shown curwindowsborder = defwindowsborder = winborder; DBRefName = "PopUpForm" + rf; this.Name = rf; deftopmost = deftopmostp; labelControlText.Text = ""; // always starts blank.. this.ShowInTaskbar = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(DBRefName + "Taskbar", true); DisplayTitle = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(DBRefName + "ShowTitle", true); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { idk = DirectInputDevices.InputDeviceKeyboard.CreateKeyboard(); } UpdateControls(); Invalidate(); var enumlisttt = new Enum[] { EDTx.UserControlForm_panel_showtitle_ToolTip, EDTx.UserControlForm_panel_minimize_ToolTip, EDTx.UserControlForm_panel_ontop_ToolTip, EDTx.UserControlForm_panel_taskbaricon_ToolTip, EDTx.UserControlForm_panel_transparent_ToolTip, EDTx.UserControlForm_panel_close_ToolTip }; BaseUtils.Translator.Instance.TranslateTooltip(toolTip, enumlisttt, this); //System.Diagnostics.Debug.WriteLine("UCF Init-"); }
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 bool ClosePanel(UserControlContainerResizable uccr) { UserControlCommonBase uc = (UserControlCommonBase)uccr.control; if (uc.AllowClose()) { uc.CloseDown(); panelPlayfield.Controls.Remove(uccr); uccrlist.Remove(uccr); Invalidate(); uc.Dispose(); uccr.Dispose(); UpdateButtons(); AssignTHC(); return(true); } else { return(false); } }
private void Merge(int panel) // Merge a panel, which involves closing one, so we need to check { SplitContainer insidesplitter = (SplitContainer)currentsplitter.Controls[panel].Controls[0]; // get that split container in the panel UserControlCommonBase uccb = insidesplitter.Panel2.Controls[0] as UserControlCommonBase; // the panel may an embedded direct uccb.. if (uccb == null) { ExtendedControls.TabStrip tabstrip = insidesplitter.Panel2.Controls[0] as ExtendedControls.TabStrip; // it may contain a tabstrip... if (tabstrip != null) { uccb = tabstrip.CurrentControl as UserControlCommonBase; // if its a tabstrip, it may contain a UCCB, or it may be empty.. } // if its not a uccb, its a split container, so null is fine } if (uccb?.AllowClose() ?? true) // check if can close, if null, we can { currentsplitter.Merge(panel); AssignTHC(); // because we may have removed the cursor } }
public override void Init() { //System.Diagnostics.Debug.WriteLine("Grid Restore from " + DBWindowNames); var windows = GetSavedSettings(); if (windows != null) { foreach (var n in windows) { Type t = Type.GetType("EDDiscovery.UserControls." + n.Item1); if (t != null) { UserControlCommonBase uccb = (UserControlCommonBase)Activator.CreateInstance(t); CreateInitPanel(uccb); } } } ResumeLayout(); UpdateButtons(); }
public override void ChangeCursorType(IHistoryCursor thc) // a grid below changed its travel grid, update our history one { bool changedinuse = Object.ReferenceEquals(ucursor_inuse, ucursor_history); // if we are using the history as the current tg //System.Diagnostics.Debug.WriteLine("Splitter CTG " + ucursor_history.GetHashCode() + " IU " + ucursor_inuse.GetHashCode() + " New " + thc.GetHashCode()); ucursor_history = thc; // underlying one has changed. if (changedinuse) // inform the boys { ucursor_inuse = ucursor_history; (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.ChangeCursorType(ucursor_inuse); //System.Diagnostics.Debug.WriteLine("Change cursor call to " + c.Name + " " + uccb.Name); } }); } }
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 Init() { //System.Diagnostics.Debug.WriteLine("Grid Restore from " + DBWindowNames); var windows = GetSavedSettings(); if (windows != null) { foreach (var n in windows) { UserControlCommonBase uccb = PanelInformation.Create(n.Item1); if (uccb != null) { CreateInitPanel(uccb); } } } ResumeLayout(); UpdateButtons(); // contract states the PanelAndPopOuts OR the MajorTabControl will now theme and size it. }
public void Init(EDDiscovery.UserControls.UserControlCommonBase c, string title, bool winborder, string rf , bool deftopmostp = false , bool defwindowintaskbar = true ) { UserControl = c; c.Dock = DockStyle.None; c.Location = new Point(0, 10); c.Size = new Size(200, 200); this.Controls.Add(c); transparencycolor = c.ColorTransparency; wintitle = label_index.Text = this.Text = title; // label index always contains the wintitle, but may not be shown curwindowsborder = defwindowsborder = winborder; dbrefname = "PopUpForm" + rf; deftopmost = deftopmostp; deftransparent = false; labelControlText.Text = ""; // always starts blank.. this.ShowInTaskbar = SQLiteDBClass.GetSettingBool(dbrefname + "Taskbar", defwindowintaskbar); displayTitle = SQLiteDBClass.GetSettingBool(dbrefname + "ShowTitle", true); UpdateControls(); Invalidate(); }