public ExtendedControls.TabStrip GetTabStrip(string name) // name is a logical name, map to approx locations { int tagid = -1; // -1 will make it not find if (name.Equals("Bottom", StringComparison.InvariantCultureIgnoreCase)) // tagids based on default grid IDs on the history window. { tagid = 1; // if user changes the deployment -tough } else if (name.Equals("Bottom-Right", StringComparison.InvariantCultureIgnoreCase)) { tagid = 4; } else if (name.Equals("Middle-Right", StringComparison.InvariantCultureIgnoreCase)) { tagid = 3; } else if (name.Equals("Top-Right", StringComparison.InvariantCultureIgnoreCase)) { tagid = 2; } ExtendedControls.TabStrip found = null; (panelPlayfield.Controls[0] as SplitContainer).RunActionOnSplitterTree((p, c) => // runs on each split panel node exactly.. { if ((int)c.Tag == tagid && c is ExtendedControls.TabStrip) // if its a tab strip, and tag is right { found = c as ExtendedControls.TabStrip; } }); return(found); }
public override void Closing() { PanelInformation.PanelIDs[] pids = PanelInformation.GetPanelIDs(); string state = ControlHelpersStaticFunc.SplitterTreeState(panelPlayfield.Controls[0] as SplitContainer, "", (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); SQLiteConnectionUser.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.Closing(); //System.Diagnostics.Debug.WriteLine("Closing " + c.Name + " " + c.GetType().Name + " " + uccb.Name); } }); }
Control TabCreate(ExtendedControls.TabStrip t, int si) // called by tab strip when selected index changes.. create a new one.. only create. { PopOutControl.PopOuts i = (PopOutControl.PopOuts)(si + PopOutControl.PopOuts.StartTabButtons); _discoveryForm.ActionRun("onPanelChange", "UserUIEvent", null, new Conditions.ConditionVariables(new string[] { "PanelTabName", PopOutControl.popoutinfo[i].WindowRefName, "PanelTabTitle", PopOutControl.popoutinfo[i].WindowTitlePrefix, "PanelName", t.Name })); return(PopOutControl.Create(i)); }
Control TabCreate(ExtendedControls.TabStrip t, int si) // called by tab strip when selected index changes.. create a new one.. only create. { Control c = PopOutControl.Create(si); c.Name = PopOutControl.PopOutList[si].WindowTitlePrefix; // tabs uses Name field for display, must set it _discoveryForm.ActionRun(Actions.ActionEventEDList.onPanelChange, null, new Conditions.ConditionVariables(new string[] { "PanelTabName", PopOutControl.PopOutList[si].WindowRefName, "PanelTabTitle", PopOutControl.PopOutList[si].WindowTitlePrefix, "PanelName", t.Name })); return(c); }
void TabConfigure(ExtendedControls.TabStrip t, string name, int displayno) { t.Images = tabbitmaps; t.ToolTips = tabtooltips; t.Tag = displayno; // these are IDs for purposes of identifying different instances of a control.. 0 = main ones (main travel grid, main tab journal). 1..N are popups t.OnRemoving += TabRemoved; t.OnCreateTab += TabCreate; t.OnPostCreateTab += TabPostCreate; t.OnPopOut += TabPopOut; t.Name = name; }
void TabConfigure(ExtendedControls.TabStrip t, string name, int displayno) { t.ImageList = PanelInformation.GetPanelImages(); t.TextList = PanelInformation.GetPanelDescriptions(); t.Tag = displayno; // these are IDs for purposes of identifying different instances of a control.. 0 = main ones (main travel grid, main tab journal). 1..N are popups t.OnRemoving += TabRemoved; t.OnCreateTab += TabCreate; t.OnPostCreateTab += TabPostCreate; t.OnPopOut += TabPopOut; t.Name = name; }
Control TabCreate(ExtendedControls.TabStrip t, int si) // called by tab strip when selected index changes.. create a new one.. only create. { PopOutControl.PopOuts i = (PopOutControl.PopOuts)si; Control c = PopOutControl.Create(i); c.Name = PopOutControl.GetPopOutName(i); // tabs uses Name field for display, must set it _discoveryForm.ActionRun("onPanelChange", "UserUIEvent", null, new Conditions.ConditionVariables(new string[] { "PanelTabName", PopOutControl.popoutinfo[i].WindowRefName, "PanelTabTitle", PopOutControl.popoutinfo[i].WindowTitlePrefix, "PanelName", t.Name })); return(c); }
Control TabCreate(ExtendedControls.TabStrip t, int si) // called by tab strip when selected index changes.. create a new one.. only create. { PanelInformation.PanelInfo pi = PanelInformation.GetPanelInfoByEnum((PanelInformation.PanelIDs)t.TagList[si]); Control c = PanelInformation.Create(pi.PopoutID); c.Name = pi.WindowTitle; // tabs uses Name field for display, must set it discoveryform.ActionRun(Actions.ActionEventEDList.onPanelChange, null, new Conditions.ConditionVariables(new string[] { "PanelTabName", pi.WindowRefName, "PanelTabTitle", pi.WindowTitle, "PanelName", t.Name })); return(c); }
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 ExtendedControls.TabStrip tabstrip = insidesplitter.Panel2.Controls[0] as ExtendedControls.TabStrip; // it must contain a tabstrip UserControlCommonBase discard = tabstrip.CurrentControl as UserControlCommonBase; // we are discarding this UCCB, this can be null, as it may not contain one if (discard?.AllowClose() ?? true) // check if can close, if null, we can { currentsplitter.Merge(panel); AssignTHC(); // because we may have removed the cursor } }
private Control TabStrip1_OnCreateTab(ExtendedControls.TabStrip t, int no) { UserControl uc = new UserControl(); uc.BackColor = Color.Cyan; Label lb = new Label(); lb.Location = new Point(10, 10); lb.Text = "User Control " + (no + 0); uc.Name = "UC " + no; uc.Dock = DockStyle.Fill; uc.Controls.Add(lb); tabStrip1.SetControlText("CT<" + uc.Name + ">"); return(uc); }
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) { UserControlPostCreate(displaynumber, uc); uc.Display(userControlTravelGrid.GetCurrentHistoryEntry, _discoveryForm.history); } //System.Diagnostics.Debug.WriteLine("And theme {0}", i); _discoveryForm.theme.ApplyToControls(t); }
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 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); } }); }
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 bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(); if (cmdname == null) { ap.ReportError("Missing panel name in Historytab"); } else { ExtendedControls.TabStrip ts = (ap.actioncontroller as ActionController).DiscoveryForm.PrimarySplitter.GetTabStrip(cmdname); // case insensitive if (ts != null) { string nextcmd = sp.NextWordLCInvariant(" "); if (nextcmd == null) { ap.ReportError("Missing command after panel name in Historytab"); } else if (nextcmd.Equals("toggle")) { ts.Toggle(); } else { PopOutControl poc = (ap.actioncontroller as ActionController).DiscoveryForm.PopOuts; PanelInformation.PanelIDs?id = PanelInformation.GetPanelIDByWindowsRefName(nextcmd); if (id != null) { PanelInformation.PanelIDs[] list = ts.TagList.Cast <PanelInformation.PanelIDs>().ToArray(); int index = Array.IndexOf(list, id.Value); if (!ts.ChangePanel(index)) { ap.ReportError("Panel " + nextcmd + " cannot be used in Historytab"); } } else { ap.ReportError("Cannot find generic panel type name " + nextcmd + " in Historytab"); } } } else { ap.ReportError("Unknown panel name or panels re-ordered " + cmdname + " in Historytab"); } } } else { ap.ReportError(res); } return(true); }
void TabPopOut(ExtendedControls.TabStrip t, int i) // pop out clicked { discoveryform.PopOuts.PopOut(i); }
void TabRemoved(ExtendedControls.TabStrip t, Control ctrl) // called by tab strip when a control is removed { UserControlCommonBase uccb = ctrl as UserControlCommonBase; uccb.Closing(); }
void TabPopOut(ExtendedControls.TabStrip t, int i) // pop out clicked { _discoveryForm.PopOuts.PopOut((PopOutControl.PopOuts)i); }
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); } }
void TabPopOut(ExtendedControls.TabStrip t, int i) // pop out clicked { discoveryform.PopOuts.PopOut((PanelInformation.PanelIDs)t.TagList[i]); }
void TabPopOut(ExtendedControls.TabStrip t, int i) // pop out clicked { _discoveryForm.PopOuts.PopOut((PopOutControl.PopOuts)(i + PopOutControl.PopOuts.StartTabButtons)); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string cmdname = sp.NextWord(); if (cmdname == null) { ap.ReportError("Missing panel name in Historytab"); } else { ExtendedControls.TabStrip ts = (ap.actioncontroller as ActionController).DiscoveryForm.TravelControl.GetTabStrip(cmdname); // case insensitive if (ts != null) { string nextcmd = sp.NextWord(" ", true); if (nextcmd == null) { ap.ReportError("Missing command after panel name in Historytab"); } else if (nextcmd.Equals("toggle")) { ts.Toggle(); } else { Forms.PopOutControl poc = (ap.actioncontroller as ActionController).DiscoveryForm.PopOuts; Forms.PopOutControl.PopOuts?poi = Forms.PopOutControl.GetPopOutTypeByName(nextcmd); if (poi.HasValue) { if (!ts.ChangeTo((int)poi.Value)) { ap.ReportError("Panel " + nextcmd + " cannot be used in Historytab"); } } else { ap.ReportError("Cannot find generic panel type name " + nextcmd + " in Historytab"); } } } else { ap.ReportError("Unknown panel name " + cmdname + " in Historytab"); } } } else { ap.ReportError(res); } return(true); }
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); } }