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