/// <summary> /// Sets the verbs. /// </summary> private void SetVerbs() { ModernTabControl parentControl = (ModernTabControl)Control; switch (parentControl.TabPages.Count) { case 0: this.Verbs[1].Enabled = false; break; default: this.Verbs[1].Enabled = true; break; } }
/// <summary> /// Called when AddPage. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void OnAddPage(object sender, EventArgs e) { ModernTabControl parentControl = (ModernTabControl)this.Control; Control.ControlCollection oldTabs = parentControl.Controls; this.RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["TabPages"]); ModernTabPage page = (ModernTabPage)this.DesignerHost.CreateComponent(typeof(ModernTabPage)); page.Text = page.Name; parentControl.TabPages.Add(page); this.RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["TabPages"], oldTabs, parentControl.TabPages); parentControl.SelectedTab = page; this.SetVerbs(); }
/// <summary> /// Called when RemovePage. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void OnRemovePage(object sender, EventArgs e) { ModernTabControl parentControl = (ModernTabControl)Control; Control.ControlCollection oldTabs = parentControl.Controls; if (parentControl.SelectedIndex < 0) { return; } this.RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["TabPages"]); this.DesignerHost.DestroyComponent(parentControl.TabPages[parentControl.SelectedIndex]); this.RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["TabPages"], oldTabs, parentControl.TabPages); this.SelectionService.SetSelectedComponents(new IComponent[] { parentControl }, SelectionTypes.Auto); this.SetVerbs(); }