private void InitializeComponents() { if (_window.MainMenuStrip != null) { _stripMenu = _factory.CreateStripMenu(_window.MainMenuStrip); } _window.Controls["Content"].Controls.Add((TableLayoutPanel)Container.Control); Children = new List <ITabWindow>(); }
static void Main(string[] args) { FactoryCreator.DefaultContext = () => { { var page = new DefaultPage(); Panel panel = new Panel { Name = "TabContent", BorderStyle = BorderStyle.FixedSingle, BackColor = RandomColor }; panel.Controls.Add(page); return(panel); } }; IFactory factory = FactoryCreator.CreateFactory(); factory.CustomTabWindow = CustomTabWindow; ITabWindow CustomTabWindow(ITabWindow tabWindow) { IStripMenu menu = factory.CreateStripMenu(); IStripMenuItem fileTool = factory.CreateStripMenuItem("File", "&File"); IStripMenuItem windowTool = factory.CreateStripMenuItem("Window", "&Window"); void ChangeOrientation(object sender, EventArgs e) { tabWindow.Container.Orientation = tabWindow.Container.Orientation == Orientation.Horizontal? Orientation.Vertical : Orientation.Horizontal; } IStripMenuItem changeOrientation = factory.CreateStripMenuItem("Change Orientation", "&Change Orientation", Keys.Control | Keys.Shift | Keys.O, ChangeOrientation); void GoToParent(object sender, EventArgs e) { tabWindow.ComebackToParent(); } IStripMenuItem toParentItem = factory.CreateStripMenuItem("Go to parent", "&Go to parent", Keys.Control | Keys.Home, GoToParent); void JoinChildrenItem(object sender, EventArgs e) { tabWindow.JoinChildren(); } IStripMenuItem joinChildrenItem = factory.CreateStripMenuItem("Join children", "&Join children", Keys.Control | Keys.Shift | Keys.Home, JoinChildrenItem); windowTool.InnerTools.Add(changeOrientation, toParentItem, joinChildrenItem); IStripMenuItem tabsTool = factory.CreateStripMenuItem("Tabs", "&Tabs"); void TabAddItem(object sender, EventArgs e) { tabWindow.Container.AddNew(); } IStripMenuItem tabAddItem = factory.CreateStripMenuItem("Add tab", "&Add tab", Keys.Control | Keys.T, TabAddItem); void TabRemoveItem(object sender, EventArgs e) { tabWindow.Container.RemoveSelected(); } IStripMenuItem tabRemoveItem = factory.CreateStripMenuItem("Remove tab", "&Remove tab", Keys.Control | Keys.W, TabRemoveItem); tabsTool.InnerTools.Add(tabAddItem, tabRemoveItem); menu.InnerTools.Add(fileTool, windowTool, tabsTool); tabWindow.StripMenu = menu; return(tabWindow); } ViewStarter.Factory = factory; ViewStarter.Start(); }