/// <summary> /// This method does al the magic of integrating GRBLMachine's UI into CamBam's /// </summary> /// <returns></returns> private static bool InstallTab() { CamBamUI ui = CamBamUI.MainUI; // Since CamBam comes with an unconstructed UI, durin 'InitPlugin' there is no UI content yet... if (ui.SysTabs != null) { // get the tabcontrol which hosts CamBam's 'Drawing' and 'System' pages TabControl tabs = ui.SysTabs.Tabs(); // // Controversial action #2: Should a plugin tamper with CamBam's UI ??? ;) :P // if (Props.EnableVisualStyles == EnabledDisabled.Enabled) { // set some properties on SysTabs because it just looks better when VisualStyles ar on. ui.SysTabs.BackColor = SystemColors.Control; ui.SysTabs.Padding = new Padding(3, 6, 1, 0); foreach (TabPage p in tabs.TabPages) { p.UseVisualStyleBackColor = false; } } // // Just for conveniance: Add a right-click menu to clear the messages // ThisApplication.TextLogger.ContextMenu = new ContextMenu(); ThisApplication.TextLogger.ContextMenu.MenuItems.Add(new MenuItem("Clear Messages", (x, y) => { ThisApplication.ClearLogMessages(); })); // hook up all eventhandlers ThisApplication.TopWindow.FormClosing += TopWindow_FormClosing; tabs.SelectedIndexChanged += Tabs_SelectedIndexChanged; tabs.Selecting += Tabs_Selecting; State += GRBLMachinePlugin_State; ConnectionExpander.Connected += ConnectionExpander_Connected; ConnectionExpander.Disconnected += ConnectionExpander_Disconnected; // add the GRBL icon to the tabcontrol's imagelist tabs.ImageList.Images.Add(Resources.Grbl_Logo_150px); Page.ImageIndex = tabs.ImageList.Images.Count - 1; // add our UI to the new tabpage Page.Controls.Add(new GRBLMachinePage()); // finally add the Machine page to the tabcontrol tabs.TabPages.Add(Page); // set the various UI states according to what was saved in GRBLMachine.config (Page.Controls[0] as GRBLMachinePage).DisplayExpander.Expanded = Props.DisplayExpanded; (Page.Controls[0] as GRBLMachinePage).ProductionExpander.Expanded = Props.ProductionExpanded; (Page.Controls[0] as GRBLMachinePage).JoggingExpander.Expanded = Props.JoggingExpanded; (Page.Controls[0] as GRBLMachinePage).ConsoleExpander.Expanded = Props.ConsoleExpanded; (Page.Controls[0] as GRBLMachinePage).ConnectionExpander.Expanded = Props.ConnectionExpanded; (Page.Controls[0] as GRBLMachinePage).AboutExpander.Expanded = Props.AboutExpanded; CamBamUI.MainUI.SysTabs.SelectedTab = Props.SelectedTab; // greet the user :) GRBLMachinePlugin.Log("Welcome to GRBL Machine v" + Version + "\n\n"); return(true); } return(false); }