public new void Add(string Key, string Text) { ExtendedTabPage Tab = new ExtendedTabPage(Text); Tab.Name = Key; base.Add(Tab); }
private void OnSelectionChanged(object sender, EventArgs e) { ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService)); this.tabControlSelected = false; if (service != null) { ICollection selectedComponents = service.GetSelectedComponents(); ExtendedTabControl component = (ExtendedTabControl)base.Component; foreach (object obj2 in selectedComponents) { if (obj2 == component) { this.tabControlSelected = true; } ExtendedTabPage tabPageOfComponent = GetTabPageOfComponent(obj2); if ((tabPageOfComponent != null) && (tabPageOfComponent.Parent == component)) { this.tabControlSelected = false; component.SelectedTab = tabPageOfComponent; break; } } } }
protected override void OnPaint(PaintEventArgs e) { for (int i = 0; i < this.TabCount; i++) { ExtendedTabPage Tab = this.TabPages[i]; if (i == this.SelectedIndex) { continue; } this.OnDrawTab(e.Graphics, i); } VisualStyleRenderer Renderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal); Renderer.DrawBackground(e.Graphics, this.ContentRect); if (this.SelectedTab != null) { this.OnDrawTab(e.Graphics, this.SelectedIndex); } if (this.DragInsertionIndex != -1) { Rectangle TabRect = this.GetTabRect(this.DragInsertionIndex); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; if (this.Alignment == TabAlignment.Top) { e.Graphics.FillPolygon(Brushes.Black, new PointF[] { new PointF(TabRect.X - 4, TabRect.Y - 2.5f), new PointF(TabRect.X + 4, TabRect.Y - 2.5f), new PointF(TabRect.X, TabRect.Y + 2) }); } else { e.Graphics.FillPolygon(Brushes.Black, new PointF[] { new PointF(TabRect.X - 4, TabRect.Bottom + 2.5f), new PointF(TabRect.X + 4, TabRect.Bottom + 2.5f), new PointF(TabRect.X, TabRect.Bottom - 2) }); } } }
protected override void OnDragDrop(DragEventArgs drgevent) { base.OnDragDrop(drgevent); if (this.DragInsertionIndex != -1 && drgevent.Data.GetDataPresent(typeof(ExtendedTabPage))) { ExtendedTabPage Tab = (ExtendedTabPage)drgevent.Data.GetData(typeof(ExtendedTabPage)); int TabIndex = this.GetTabIndex(Tab); if (TabIndex != -1) { this.SuspendPaint(); this.TabPages.Remove(Tab); if (TabIndex < this.DragInsertionIndex) { this.DragInsertionIndex--; } this.TabPages.Insert(this.DragInsertionIndex, Tab); this.SelectedTab = Tab; this.ResumePaint(); } } this.DragInsertionIndex = -1; this.Invalidate(false); }
public new void Add(string Key, string Text, int ImageIndex) { ExtendedTabPage Tab = new ExtendedTabPage(Text); Tab.Name = Key; Tab.ImageIndex = ImageIndex; base.Add(Tab); }
protected virtual void OnDrawTab(Graphics g, int TabIndex) { ExtendedTabPage Tab = this.TabPages[TabIndex]; Rectangle TabRect = this.GetTabRect(TabIndex); VisualStyleRenderer Renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal); StringFormat StringFormat = new StringFormat(); StringFormat.Alignment = StringAlignment.Near; StringFormat.LineAlignment = StringAlignment.Center; if (this.SelectedTab == Tab) { TabRect = this.GetSelectedTabRect(TabIndex); Renderer.SetParameters(Renderer.Class, Renderer.Part, (int)TabItemState.Selected); } else if (TabIndex == this.HotTabIndex) { Renderer.SetParameters(Renderer.Class, Renderer.Part, (int)TabItemState.Hot); } Renderer.DrawBackground(g, TabRect); if (Tab.Image != null) { g.DrawImage(Tab.Image, TabRect.Location + new Size(4, 4)); } g.DrawString(Tab.Text, this.Font, SystemBrushes.ControlText, this.GetTabTextRect(TabIndex), StringFormat); if (Tab.CanClose) { StringFormat.LineAlignment = StringAlignment.Near; Rectangle CrossRect = this.GetTabCrossRect(TabIndex); CrossRect.Y -= 3; if (TabIndex != this.SelectedIndex) { CrossRect.Y -= 1; } int HighlightedCrossIndex = -1; if (this.HoveredOnCross) { HighlightedCrossIndex = this.HotTabIndex; } if (this.PressedOnCross) { HighlightedCrossIndex = this.PressedCrossIndex; } if (TabIndex == HighlightedCrossIndex) { g.DrawString("r", this.Webdings, SystemBrushes.ControlText, CrossRect, StringFormat); } else { g.DrawString("r", this.Webdings, Brushes.Gray, CrossRect, StringFormat); } } }
private ExtendedTabPageDesigner GetSelectedTabPageDesigner() { ExtendedTabPageDesigner designer = null; ExtendedTabPage selectedTab = ((ExtendedTabControl)base.Component).SelectedTab; if (selectedTab != null) { IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { designer = service.GetDesigner(selectedTab) as ExtendedTabPageDesigner; } } return(designer); }
private void OnRemove(object sender, EventArgs eevent) { ExtendedTabControl component = (ExtendedTabControl)base.Component; if ((component != null) && (component.TabPages.Count != 0)) { MemberDescriptor member = TypeDescriptor.GetProperties(base.Component)["Controls"]; ExtendedTabPage selectedTab = component.SelectedTab; IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { DesignerTransaction transaction = null; try { try { transaction = service.CreateTransaction("TabControlRemoveTab"); base.RaiseComponentChanging(member); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return; } service.DestroyComponent(selectedTab); base.RaiseComponentChanged(member, null, null); } finally { if (transaction != null) { transaction.Commit(); } } } } }
private void OnTabSelectedIndexChanged(object sender, EventArgs e) { ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService)); if (service != null) { ICollection selectedComponents = service.GetSelectedComponents(); ExtendedTabControl component = (ExtendedTabControl)base.Component; bool flag = false; foreach (object obj2 in selectedComponents) { ExtendedTabPage tabPageOfComponent = GetTabPageOfComponent(obj2); if (((tabPageOfComponent != null) && (tabPageOfComponent.Parent == component)) && (tabPageOfComponent == component.SelectedTab)) { flag = true; break; } } if (!flag) { service.SetSelectedComponents(new object[] { base.Component }); } } }
public void Add(ExtendedTabPage Tab) { base.Add(Tab); }
public new void Add(string Text) { ExtendedTabPage Tab = new ExtendedTabPage(Text); base.Add(Tab); }
private void OnAdd(object sender, EventArgs eevent) { ExtendedTabControl component = (ExtendedTabControl)base.Component; IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { DesignerTransaction transaction = null; try { try { transaction = service.CreateTransaction("TabControlAddTab"); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return; } MemberDescriptor member = TypeDescriptor.GetProperties(component)["Controls"]; ExtendedTabPage page = (ExtendedTabPage)service.CreateComponent(typeof(ExtendedTabPage)); if (!this.addingOnInitialize) { base.RaiseComponentChanging(member); } page.Padding = new Padding(3); string str = null; PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(page)["Name"]; if ((descriptor2 != null) && (descriptor2.PropertyType == typeof(string))) { str = (string)descriptor2.GetValue(page); } if (str != null) { PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(page)["Text"]; if (descriptor3 != null) { descriptor3.SetValue(page, str); } } PropertyDescriptor descriptor4 = TypeDescriptor.GetProperties(page)["UseVisualStyleBackColor"]; if (((descriptor4 != null) && (descriptor4.PropertyType == typeof(bool))) && (!descriptor4.IsReadOnly && descriptor4.IsBrowsable)) { descriptor4.SetValue(page, true); } component.Controls.Add(page); component.SelectedIndex = component.TabCount - 1; if (!this.addingOnInitialize) { base.RaiseComponentChanged(member, null, null); } } finally { if (transaction != null) { transaction.Commit(); } } } }