/// <summary> /// Handles the <see cref="E:RemovePage" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void OnRemovePage(Object sender, EventArgs e) { MaterialTabControl ParentControl = (MaterialTabControl)Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; if (ParentControl.SelectedIndex < 0) { return; } RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); DesignerHost.DestroyComponent(ParentControl.TabPages[ParentControl.SelectedIndex]); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { ParentControl }, SelectionTypes.Auto); SetVerbs(); }
/// <summary> /// Initializes a new instance of the <see cref="TabWindow"/> class. /// </summary> /// <param name="tabPage">The tab page.</param> /// <param name="baseTab">The base tab.</param> public TabWindow(MaterialTabPage tabPage, ref MaterialTabSelector baseTab) { TabPage = tabPage; Text = TabPage.Text; Root = new MaterialTabControl(); Root.TabPages.Add(TabPage); Root.Dock = System.Windows.Forms.DockStyle.Fill; BaseTabControl = baseTab; Closable = tabPage.Closable; Size = TabPage.Size; Controls.Add(Root); allowClose = false; }
/// <summary> /// Sets the verbs. /// </summary> private void SetVerbs() { MaterialTabControl ParentControl = (MaterialTabControl)Control; switch (ParentControl.TabPages.Count) { case 0: Verbs[1].Enabled = false; break; default: Verbs[1].Enabled = true; break; } }
/// <summary> /// Handles the <see cref="E:AddPage" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void OnAddPage(Object sender, EventArgs e) { MaterialTabControl ParentControl = (MaterialTabControl)Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); System.Windows.Forms.TabPage P = (System.Windows.Forms.TabPage)(DesignerHost.CreateComponent(typeof(MaterialTabPage))); P.Text = P.Name; ParentControl.TabPages.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }