#if FRAMEWORK20 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Media; using System.Windows.Forms; using DevComponents.DotNetBar.Rendering; namespace DevComponents.DotNetBar { public class SuperTabStripItem : BaseItem, IDesignTimeProvider { #region Events /// /// Occurs when a tab is added to the Tabs collection /// [Description("Occurs when a tab is added to the Tabs collection.")] public event EventHandler TabItemOpen; /// /// Occurs when a tab is about to Close /// [Description("Occurs when a tab is about to Close.")] public event EventHandler TabItemClose; /// /// Occurs when a tab is removed from the Tabs collection /// [Description("Occurs when a tab is removed from the Tabs collection.")] public event EventHandler TabRemoved; /// /// Occurs when a tab is about to be displayed /// [Description("Occurs when a tab is about to be displayed.")] public event EventHandler BeforeTabDisplay; /// /// Occurs when a tab is being moved or dragged by the user /// [Description("Occurs when a tab is being moved or dragged by the user.")] public event EventHandler TabMoving; /// /// Occurs when a tab has been moved or dragged by the user /// [Description("Occurs when a tab has been moved or dragged by the user.")] public event EventHandler TabMoved; /// /// Occurs when the Selected tab is changing /// [Description("Occurs when the Selected tab is changing.")] public event EventHandler SelectedTabChanging; /// /// Occurs when the Selected tab has changed /// [Description("Occurs when the Selected tab has changed.")] public event EventHandler SelectedTabChanged; /// /// Occurs when the control needs a tab's bordering path /// [Description("Occurs when the control needs a tab's bordering path.")] public event EventHandler GetTabItemPath; /// /// Occurs when the control needs a tab's Content Rectangle /// [Description("Occurs when the control needs a tab's Content Rectangle.")] public event EventHandler GetTabItemContentRectangle; /// /// Occurs when the control needs to measure a tab /// [Description("Occurs when the control needs to measure a tab.")] public event EventHandler MeasureTabItem; /// /// Occurs before any tab rendering is done /// [Description("Occurs before any tab rendering is done.")] public event EventHandler PreRenderTabItem; /// /// Occurs After all tab rendering is complete /// [Description("Occurs After all tab rendering is complete.")] public event EventHandler PostRenderTabItem; /// /// Occurs when the control needs to get the tab's Text Bounds /// [Description("Occurs when the control needs to get the tab's Text Bounds.")] public event EventHandler GetTabTextBounds; /// /// Occurs when the control needs to get the tab's Image Bounds /// [Description("Occurs when the control needs to get the tab's Image Bounds.")] public event EventHandler GetTabImageBounds; /// /// Occurs when the control needs to get the tab's Close Button Bounds /// [Description("Occurs when the control needs to get the tab's Close Button Bounds.")] public event EventHandler GetTabCloseBounds; /// /// Occurs when the TabStrip background needs painted /// [Description("Occurs when the TabStrip background needs painted.")] public event EventHandler TabStripPaintBackground; /// /// Occurs when the TabStrip TabColor has changed /// [Description("Occurs when the TabStrip TabColor has changed.")] public event EventHandler TabStripTabColorChanged; /// /// Occurs when the TabStrip Color has changed /// [Description("Occurs when the TabStrip TabColor has changed.")] public event EventHandler TabStripColorChanged; #endregion #region Private variables private eSuperTabStyle _TabStyle = eSuperTabStyle.Office2007; private eSuperTabLayoutType _TabLayoutType = eSuperTabLayoutType.SingleLine; private Image _TabCloseButtonNormal; private Image _TabCloseButtonHot; private Image _TabCloseButtonPressed; private Size _TabCloseButtonSize = new Size(16, 16); private Size _DefaultTabCloseButtonSize = new Size(16, 16); private int _TabHorizontalSpacing = 5; private int _TabVerticalSpacing = 4; private bool _CloseButtonOnTabsVisible; private bool _CloseButtonOnTabsAlwaysDisplayed = true; private bool _DisplaySelectedTextOnly; private bool _ShowFocusRectangle; private Size _FixedTabSize = Size.Empty; private bool _HorizontalText = true; private bool _AutoCloseTabs = true; private bool _AutoSelectAttachedControl; private bool _ReorderTabsEnabled = true; private bool _RotateVerticalText; private Font _TabFont; private Font _SelectedTabFont; private SuperTabColorTable _TabStripColor = new SuperTabColorTable(); private SuperTabItem _HotTab; private SuperTabItem _SelectedTab; private BaseItem _VisibleTab; private int _SelectedTabIndex; private SuperTabControlBox _TabControlBox; private SuperTabStripBaseDisplay _TabDisplay; private Rectangle _TabItemsBounds; private SuperTabItem _DesignTimeSelection; private eTabStripAlignment _TabAlignment = eTabStripAlignment.Top; private eTabCloseButtonPosition _CloseButtonPosition = eTabCloseButtonPosition.Right; private SuperTabStrip _TabStrip; private int _TabLines; private eItemAlignment _TextAlignment; private eSuperTabArea _TabArea; private SuperTabItem _MouseDownTab; private Point _MouseDownLocation; private bool _IsTabDragging; private SuperTabDragWindow _TabDragWindow; private BaseItem _InsertTab; private bool _InsertBefore; private bool _RecalcInProgress; private Padding _ItemPadding; private ImageAlignment _ImageAlignment = ImageAlignment.NotSet; #endregion /// /// Constructor /// /// Associated SuperTabStrip public SuperTabStripItem(SuperTabStrip tabStrip) { _TabStrip = tabStrip; _TabControlBox = new SuperTabControlBox(this); _TabDisplay = new Office2007SuperTabStrip(this); _ItemPadding = new Padding(0, 0, 0, 0); SetIsContainer(true); HookEvents(true); } protected override void Dispose(bool disposing) { if (BarUtilities.DisposeItemImages && !DesignMode) { BarUtilities.DisposeImage(ref _TabCloseButtonNormal); BarUtilities.DisposeImage(ref _TabCloseButtonHot); BarUtilities.DisposeImage(ref _TabCloseButtonPressed); } if (disposing) _TabControlBox.Dispose(); base.Dispose(disposing); } #region Public properties #region AutoCloseTabs /// /// Gets or sets AutoCloseTabs /// public bool AutoCloseTabs { get { return (_AutoCloseTabs); } set { _AutoCloseTabs = value; } } #endregion #region AutoSelectAttachedControl /// /// Gets or sets whether the control attached to the TabItem.AttachedControl property /// is automatically selected when TabItem becomes the selected tab. Default value is true. /// public bool AutoSelectAttachedControl { get { return (_AutoSelectAttachedControl); } set { _AutoSelectAttachedControl = value; } } #endregion #region CloseButton properties #region TabCloseButtonNormal /// /// Gets or sets TabCloseButtonNormal /// public Image TabCloseButtonNormal { get { return (_TabCloseButtonNormal); } set { _TabCloseButtonNormal = value; _TabCloseButtonSize = (_TabCloseButtonNormal != null) ? _TabCloseButtonNormal.Size : _DefaultTabCloseButtonSize; MyRefresh(); } } #endregion #region TabCloseButtonHot /// /// Gets or sets TabCloseButtonHot /// public Image TabCloseButtonHot { get { return (_TabCloseButtonHot); } set { _TabCloseButtonHot = value; MyRefresh(); } } #endregion #region TabCloseButtonPressed /// /// Gets or sets TabCloseButtonPressed /// public Image TabCloseButtonPressed { get { return (_TabCloseButtonPressed); } set { _TabCloseButtonPressed = value; MyRefresh(); } } #endregion #region TabHorizontalSpacing /// /// Gets or sets TabHorizontalSpacing /// public int TabHorizontalSpacing { get { return (_TabHorizontalSpacing); } set { if (_TabHorizontalSpacing != value) { _TabHorizontalSpacing = value; MyRefresh(); } } } #endregion #region TabVerticalSpacing /// /// Gets or sets TabVerticalSpacing /// public int TabVerticalSpacing { get { return (_TabVerticalSpacing); } set { if (_TabVerticalSpacing != value) { _TabVerticalSpacing = value; MyRefresh(); } } } #endregion #region CloseButtonOnTabsVisible /// /// Gets or sets CloseButtonOnTabsVisible /// public bool CloseButtonOnTabsVisible { get { return (_CloseButtonOnTabsVisible); } set { if (_CloseButtonOnTabsVisible != value) { _CloseButtonOnTabsVisible = value; MyRefresh(); } } } #endregion #region CloseButtonOnTabsAlwaysDisplayed /// /// Gets or sets CloseButtonOnTabsAlwaysDisplayed /// public bool CloseButtonOnTabsAlwaysDisplayed { get { return (_CloseButtonOnTabsAlwaysDisplayed); } set { if (_CloseButtonOnTabsAlwaysDisplayed != value) { _CloseButtonOnTabsAlwaysDisplayed = value; MyRefresh(); } } } #endregion #region CloseButtonPosition /// /// Gets or sets CloseButtonPosition /// public eTabCloseButtonPosition CloseButtonPosition { get { return _CloseButtonPosition; } set { _CloseButtonPosition = value; MyRefresh(); } } #endregion #endregion #region ControlBox /// /// Gets the ControlBox /// public SuperTabControlBox ControlBox { get { return (_TabControlBox); } } #endregion #region DesignTimeSelection [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public SuperTabItem DesignTimeSelection { get { return _DesignTimeSelection; } set { _DesignTimeSelection = value; Refresh(); } } #endregion #region DisplaySelectedTextOnly /// /// Gets or sets DisplaySelectedTextOnly /// public bool DisplaySelectedTextOnly { get { return _DisplaySelectedTextOnly; } set { _DisplaySelectedTextOnly = value; MyRefresh(); } } #endregion #region Expanded /// /// Gets or set the Expanded state /// public override bool Expanded { get { return (base.Expanded); } set { base.Expanded = value; for (int i = 0; i < SubItems.Count; i++) SubItems[i].Expanded = value; if (ControlBox.Visible == true) { ControlBox.Expanded = value; for (int i = 0; i < ControlBox.SubItems.Count; i++) ControlBox.SubItems[i].Expanded = value; } } } #endregion #region Font properties #region TabFont /// /// Gets or sets the tab font /// public Font TabFont { get { return (_TabFont); } set { _TabFont = value; ClearSizingFont(); MyRefresh(); } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeTabFont() { return (_TabFont != null); } [EditorBrowsable(EditorBrowsableState.Never)] public void ResetTabFont() { TabFont = null; } #region ClearSizingFont private void ClearSizingFont() { foreach (BaseItem item in SubItems) { SuperTabItem tab = item as SuperTabItem; if (tab != null) tab.SizingFont = null; } } #endregion #endregion #region SelectedTabFont /// /// Gets or sets the selected tab font /// public Font SelectedTabFont { get { return (_SelectedTabFont); } set { _SelectedTabFont = value; ClearSizingFont(); MyRefresh(); } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeSelectedTabFont() { return (_SelectedTabFont != null); } [EditorBrowsable(EditorBrowsableState.Never)] public void ResetSelectedTabFont() { SelectedTabFont = null; } #endregion #endregion #region HorizontalText /// /// Gets or sets the HorizontalText /// public bool HorizontalText { get { return (_HorizontalText); } set { _HorizontalText = value; MyRefresh(); } } #endregion #region ImageAlignment /// /// Gets or sets the default alignment of the Image within the tab /// [DefaultValue(ImageAlignment.NotSet), Category("Appearance")] [Description("Indicates the default alignment of the Image within the tab.")] public ImageAlignment ImageAlignment { get { return (_ImageAlignment); } set { if (_ImageAlignment != value) { _ImageAlignment = value; MyRefresh(); } } } #endregion #region ItemPadding /// /// Gets or sets the BaseItem tab padding. /// public Padding ItemPadding { get { return (_ItemPadding); } set { _ItemPadding = value; } } #endregion #region RotateVerticalText /// /// Gets or sets RotateVerticalText /// public bool RotateVerticalText { get { return (_RotateVerticalText); } set { _RotateVerticalText = value; MyRefresh(); } } #endregion #region ShowFocusRectangle /// /// Gets or sets ShowFocusRectangle /// public bool ShowFocusRectangle { get { return (_ShowFocusRectangle); } set { _ShowFocusRectangle = value; } } #endregion #region Tab properties #region FixedTabSize /// /// Gets or sets the FixedTabSize /// public Size FixedTabSize { get { return _FixedTabSize; } set { value.Width = Math.Max(0, value.Width); value.Height = Math.Max(0, value.Height); if ((value.Width > 0 || value.Height > 0) && _TabDisplay != null) { Size minSize = _TabDisplay.MinTabSize; if (value.Width > 0) { if (minSize.Width > value.Width) value.Width = minSize.Width; } if (value.Height > 0) { if (minSize.Height > value.Height) value.Height = minSize.Height; } } if (_FixedTabSize != value) { _FixedTabSize = value; MyRefresh(); } } } [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeFixedTabSize() { return (_FixedTabSize.IsEmpty == false); } #endregion #region IsTabDragging /// /// Gets or sets /// public bool IsTabDragging { get { return (_IsTabDragging); } internal set { _IsTabDragging = value; } } #endregion #region MinTabStripHeight /// /// Gets the MinTabStripHeight /// public int MinTabStripHeight { get { return (_TabDisplay.MinTabStripHeight); } } #endregion #region ReorderTabsEnabled /// /// Gets or sets ReorderTabsEnabled /// public bool ReorderTabsEnabled { get { return (_ReorderTabsEnabled); } set { _ReorderTabsEnabled = value; } } #endregion #region SelectedTab /// /// Gets or sets the selected tab /// public SuperTabItem SelectedTab { get { return (_SelectedTab); } set { if (value != null) { if (value.Visible == true) SelectTab(value, eEventSource.Code); } else { SelectTab(null, eEventSource.Code); } } } #endregion #region SelectedTabIndex /// /// Gets or sets the selected tab index /// public int SelectedTabIndex { get { if (_SelectedTab != null) return (SubItems.IndexOf(_SelectedTab)); return (-1); } set { if (value >= 0 && value < SubItems.Count) { SuperTabItem tab = SubItems[value] as SuperTabItem; if (tab != null) { if (tab.Visible == true) SelectedTab = tab; } else { SelectedTab = null; } } } } #endregion #region TabAlignment /// /// Gets or sets the tab alignment /// public eTabStripAlignment TabAlignment { get { return (_TabAlignment); } set { if (_TabAlignment != value) { _TabAlignment = value; SyncOrientation(); MyRefresh(); } } } #region SyncOrientation /// /// Syncs the Orientation of each SubItem to /// the current TabAlignment Orientation /// private void SyncOrientation() { eDesignMarkerOrientation orientation = GetTabAlignmentBasedOrientation(); foreach (BaseItem item in SubItems) item.DesignMarkerOrientation = orientation; } #endregion #region GetTabAlignmentBasedOrientation /// /// Gets the Orientation based upon the current /// TabAlignment /// /// private eDesignMarkerOrientation GetTabAlignmentBasedOrientation() { return ((IsVertical == true) ? eDesignMarkerOrientation.Vertical : eDesignMarkerOrientation.Horizontal); } #endregion #region OnItemAdded /// /// Makes sure all newly added items /// are set to the design orientation and style /// /// protected internal override void OnItemAdded(BaseItem item) { item.DesignMarkerOrientation = GetTabAlignmentBasedOrientation(); item.Style = GetStyleFromTabStyle(); base.OnItemAdded(item); } #endregion #endregion #region TabLayoutType /// /// Gets or sets the TabLayoutType /// public eSuperTabLayoutType TabLayoutType { get { return (_TabLayoutType); } set { _TabLayoutType = value; _TabControlBox.Bounds = Rectangle.Empty; OnTabStyleChanged(); MyRefresh(); } } #endregion #region TabStripColor /// /// Gets or sets the TabStripColor /// public SuperTabColorTable TabStripColor { get { return (_TabStripColor); } set { if (_TabStripColor.Equals(value) == false) { if (_TabStripColor != null) _TabStripColor.ColorTableChanged -= ColorTableColorTableChanged; _TabStripColor = value; if (value != null) _TabStripColor.ColorTableChanged += ColorTableColorTableChanged; OnTabStripColorChanged(); MyRefresh(); } } } #endregion #region TabStyle /// /// Gets or sets the TabStyle /// public eSuperTabStyle TabStyle { get { return (_TabStyle); } set { if (_TabStyle != value) { _TabStyle = value; switch (value) { case eSuperTabStyle.Office2007: _TabDisplay = new Office2007SuperTabStrip(this); break; case eSuperTabStyle.Office2010BackstageBlue: _TabDisplay = new Office2010BackstageSuperTabStrip(this); break; case eSuperTabStyle.OneNote2007: _TabDisplay = new OneNote2007SuperTabStrip(this); break; case eSuperTabStyle.OfficeMobile2014: _TabDisplay = new OfficeMobile2014SuperTabStrip(this); break; case eSuperTabStyle.VisualStudio2008Dock: _TabDisplay = new VS2008DockSuperTabStrip(this); break; case eSuperTabStyle.VisualStudio2008Document: _TabDisplay = new VS2008DocumentSuperTabStrip(this); break; case eSuperTabStyle.WinMediaPlayer12: _TabDisplay = new WinMediaPlayer12SuperTabStrip(this); break; } ApplyTabStyle(); } } } #region ApplyTabStyle /// /// Applies the current TabStyle to each tab and /// sets the item style to the DotNetBarStyle from the TabStyle /// private void ApplyTabStyle() { eDotNetBarStyle style = GetStyleFromTabStyle(); foreach (BaseItem item in SubItems) { SuperTabItem tab = item as SuperTabItem; if (tab != null) tab.TabStyle = _TabStyle; item.Style = style; } TabStrip.RecalcLayout(); } #endregion #region GetStyleFromTabStyle /// /// Gets the DotNetBarStyle from the SuperTabStyle /// /// eDotNetBarStyle private eDotNetBarStyle GetStyleFromTabStyle() { eDotNetBarStyle style = eDotNetBarStyle.StyleManagerControlled; eSuperTabStyle tabStyle = _TabStyle; if (tabStyle == eSuperTabStyle.VisualStudio2008Dock || tabStyle == eSuperTabStyle.VisualStudio2008Document) { style = eDotNetBarStyle.VS2005; } return style; } #endregion #endregion #endregion #region TextAlignment /// /// Gets or sets the TextAlignment /// public eItemAlignment TextAlignment { get { return (_TextAlignment); } set { if (_TextAlignment != value) { _TextAlignment = value; Refresh(); } } } #endregion #endregion #region Internal properties #region FirstVisibleTab /// /// Gets the First Visible Tab /// internal SuperTabItem FirstVisibleTab { get { for (int i = 0; i < SubItems.Count; i++) { BaseItem item = SubItems[i]; if (item is SuperTabItem) { if (item.Visible == true && (item.Enabled == true || DesignMode == true)) { return ((SuperTabItem)item); } } } return (null); } } #endregion #region HotTab /// /// Gets the HotTab /// internal SuperTabItem HotTab { get { return (_HotTab); } } #endregion #region InsertTab /// /// Gets the InsertTab /// internal BaseItem InsertTab { get { return (_InsertTab); } } #endregion #region InsertBefore /// /// Gets whether to insert before or after /// internal bool InsertBefore { get { return (_InsertBefore); } } #endregion #region MouseOverTab /// /// Gets the MouseOver tab /// internal SuperTabItem MouseOverTab { get { return (_HotTab); } } #endregion #region IsVertical /// /// Gets TabStrip vertical orientation /// internal bool IsVertical { get { return (_TabAlignment == eTabStripAlignment.Left || _TabAlignment == eTabStripAlignment.Right); } } #endregion #region LastVisibleTab /// /// Gets the Last Visible Tab /// internal SuperTabItem LastVisibleTab { get { for (int i = SubItems.Count - 1; i >= 0; i--) { BaseItem item = SubItems[i]; if (item is SuperTabItem) { if (item.Visible == true && (item.Enabled == true || DesignMode == true)) { return ((SuperTabItem)item); } } } return (null); } } #endregion #region TabCloseButtonSize /// /// Gets the tab close button size /// internal Size TabCloseButtonSize { get { return (_TabCloseButtonSize); } } #endregion #region TabDisplay /// /// Gets the TabDisplay /// internal SuperTabStripBaseDisplay TabDisplay { get { return (_TabDisplay); } } #endregion #region TabItemsBounds /// /// Gets or sets the TabItemsBounds /// internal Rectangle TabItemsBounds { get { return (_TabItemsBounds); } set { _TabItemsBounds = value; } } #endregion #region TabLines /// /// Gets or sets the number of TabLines /// internal int TabLines { get { return (_TabLines); } set { _TabLines = value; } } #endregion #region TabStrip /// /// Gets the TabStrip /// internal SuperTabStrip TabStrip { get { return (_TabStrip); } } #endregion #region VisibleTabCount /// /// Gets the visible tab count /// internal int VisibleTabCount { get { int count = 0; for (int i = 0; i < SubItems.Count; i++) { if (SubItems[i].Parent != null && SubItems[i].Visible) count++; } return (count); } } #endregion #region VisibleTab /// /// Gets or sets the promoted visible tab /// internal BaseItem VisibleTab { get { return (_VisibleTab ?? _SelectedTab); } set { if (_VisibleTab != value) { _VisibleTab = value; MyRefresh(); } } } #endregion #endregion #region HookEvents /// /// Hooks or unhooks our events /// /// private void HookEvents(bool hook) { if (hook == true) SubItemsChanged += SuperTabStripItemSubItemsChanged; else SubItemsChanged -= SuperTabStripItemSubItemsChanged; } #endregion #region Event processing #region SubItemsChanged /// /// Handles SubItemsChanged events /// /// /// void SuperTabStripItemSubItemsChanged(object sender, CollectionChangeEventArgs e) { switch (e.Action) { case CollectionChangeAction.Add: TabItemAdded(e.Element as BaseItem); break; case CollectionChangeAction.Remove: TabItemRemoved(e.Element as BaseItem); break; case CollectionChangeAction.Refresh: MyRefresh(); break; } } #endregion #region TabItemAdded /// /// Handles newly added items /// /// internal void TabItemAdded(BaseItem item) { SuperTabItem tab = item as SuperTabItem; if (tab != null) { tab.TabStripItem = this; //tab.Visible = true; tab.TabColorChanged += TabTabColorChanged; if (TabItemOpen != null) { SuperTabStripTabItemOpenEventArgs args = new SuperTabStripTabItemOpenEventArgs(tab); TabItemOpen(this, args); } if (tab.Visible == true) { if (SelectedTab == null && VisibleTabCount == 1) SelectedTab = tab; } } MyRefresh(); } #endregion #region TabRemoved /// /// Handles newly removed items /// /// internal void TabItemRemoved(BaseItem item) { if (TabRemoved != null) { SuperTabStripTabRemovedEventArgs args = new SuperTabStripTabRemovedEventArgs(item); TabRemoved(this, args); } SuperTabItem tab = item as SuperTabItem; if (tab != null) { tab.TabColorChanged -= TabTabColorChanged; SuperTabControlPanel panel = tab.AttachedControl as SuperTabControlPanel; if (panel != null) panel.PanelColorChanged -= TabTabColorChanged; if (SelectedTab == tab) OnSelectedTabRemoved(_SelectedTabIndex, tab); if (VisibleTabCount == 0) SelectedTab = null; } Refresh(); } #endregion #region Tab_TabColorChanged /// /// Handles tab color changes /// /// /// void TabTabColorChanged(object sender, EventArgs e) { if (TabStripTabColorChanged != null) { SuperTabItem tab = sender as SuperTabItem; if (tab != null) { TabStripTabColorChanged(this, new SuperTabStripTabColorChangedEventArgs(tab)); } } Refresh(); } #endregion #region ColorTable_ColorTableChanged /// /// Handles color table changes /// /// /// void ColorTableColorTableChanged(object sender, EventArgs e) { OnTabStripColorChanged(); } #endregion #endregion #region MyRefresh /// /// Performs NeedRecalcSize and refresh /// private void MyRefresh() { NeedRecalcSize = true; Refresh(); } #endregion #region RecalcSize /// /// Recalculates the size of the tabs. /// public override void RecalcSize() { if (SuspendLayout == false && BarFunctions.IsHandleValid(this.ContainerControl as Control)) // Do not force Control to create Handle by going through RecalcSize since it will break layout on controls { if (_RecalcInProgress == false) { try { _RecalcInProgress = true; RecalcDisplaySize(); } finally { _RecalcInProgress = false; } } } } #region RecalcDisplaySize private void RecalcDisplaySize() { base.RecalcSize(); Control container = ContainerControl as Control; if (container != null) { using (Graphics g = BarFunctions.CreateGraphics(container)) { if (_TabControlBox.Visible == true) { _TabControlBox.RecalcSize(); if (DesignMode == false) _TabControlBox.Displayed = true; } _TabDisplay.RecalcSize(g); } } } #endregion #endregion #region EnsureVisible /// /// Ensures that the given item is visible on the TabStrip /// /// public void EnsureVisible(BaseItem item) { VisibleTab = item; } #endregion #region SelectTab /// /// Selects the given tab /// /// /// public void SelectTab(SuperTabItem tab, eEventSource eventSource) { if (tab != null && (tab.Enabled == true || DesignMode == true)) { bool refresh = (_VisibleTab != tab || _SelectedTab != tab); if (_SelectedTab != tab) { SuperTabControl tc = _TabStrip.Parent as SuperTabControl; if (tc != null && tc.ValidateFormOnTabSelection) { Form form = tc.FindForm(); if (form != null) { if (form.Validate() == false) return; } } SuperTabItem oldTab = _SelectedTab; if (OnSelectedTabChanging(tab, eventSource) == false) { _VisibleTab = tab; OnBeforeTabDisplay(tab); Control hideControl = null; if (_SelectedTab != null && _SelectedTab.AttachedControl != null) hideControl = _SelectedTab.AttachedControl; _SelectedTab = tab; _SelectedTabIndex = SubItems.IndexOf(tab); if (_SelectedTab.AttachedControl != null) { _SelectedTab.AttachedControl.BringToFront(); _SelectedTab.AttachedControl.Visible = true; if (tc != null) { bool select = !(tc.TabStop && tc.Focused && eventSource == eEventSource.Keyboard); if (_AutoSelectAttachedControl && select) _SelectedTab.AttachedControl.Select(); } if (hideControl == _SelectedTab.AttachedControl) hideControl = null; } if (hideControl != null) hideControl.Visible = false; OnSelectedTabChanged(oldTab, _SelectedTab, eventSource); } } if (refresh == true) MyRefresh(); } else { _SelectedTab = null; MyRefresh(); } } #endregion #region SelectPreviousTab /// /// Selects the previous tab /// /// public bool SelectPreviousTab() { return SelectPreviousTab(eEventSource.Code); } /// /// Selects the previous tab /// /// internal bool SelectPreviousTab(eEventSource eventSource) { if (SelectedTab != null && SubItems.IndexOf(SelectedTab) > 0) { for (int i = SubItems.IndexOf(SelectedTab) - 1; i >= 0; i--) { BaseItem item = SubItems[i]; if (item.Visible == true && (item.Enabled == true || DesignMode == true)) { if (item is SuperTabItem) { SelectTab((SuperTabItem)item, eventSource); return (true); } } } } return (false); } #endregion #region SelectNextTab /// /// Selects the next tab /// /// public bool SelectNextTab() { return SelectNextTab(eEventSource.Code); } /// /// Selects the next tab /// /// internal bool SelectNextTab(eEventSource eventSource) { if (SelectedTab != null && SubItems.IndexOf(SelectedTab) < SubItems.Count) { for (int i = SubItems.IndexOf(SelectedTab) + 1; i < SubItems.Count; i++) { BaseItem item = SubItems[i]; if (item.Visible == true && (item.Enabled == true || DesignMode == true)) { if (item is SuperTabItem) { SelectTab((SuperTabItem)item, eventSource); return (true); } } } } return (false); } #endregion #region SelectNewTab internal void SelectNewTab(BaseItem item) { SelectNewTab(Math.Max(0, SubItems.IndexOf(item))); } internal void SelectNewTab(int index) { SubItemsCollection items = SubItems; int k = GetNextSelectableTab(items, index); if (k < 0) k = GetPrevSelectableTab(items, index); if (k >= 0) { SelectTab(items[k] as SuperTabItem, eEventSource.Code); RecalcSize(); } else { SelectedTab = null; } } #endregion #region GetNewSelectTab internal SuperTabItem GetNewSelectTab(int index) { SubItemsCollection items = SubItems; if ((uint) index < items.Count) { int k = GetNextSelectableTab(items, index); if (k < 0) k = GetPrevSelectableTab(items, index); if (k >= 0) return (items[k] as SuperTabItem); } return (null); } #endregion #region GetNextSelectableTab internal int GetNextSelectableTab(SuperTabItem tab) { SubItemsCollection items = SubItems; return (GetNextSelectableTab(items, items.IndexOf(tab))); } internal int GetNextSelectableTab(SubItemsCollection items, int n) { n = Math.Max(n, 0); for (int i = n; i < items.Count; i++) { SuperTabItem tab = items[i] as SuperTabItem; if (tab != null && tab.Parent != null && tab.Visible && tab.Enabled) return (i); } return (-1); } #endregion #region GetPrevSelectableTab internal int GetPrevSelectableTab(SuperTabItem tab) { SubItemsCollection items = SubItems; return (GetPrevSelectableTab(items, items.IndexOf(tab))); } internal int GetPrevSelectableTab(SubItemsCollection items, int n) { n = Math.Min(n, items.Count - 1); for (int i = n; i >= 0; i--) { SuperTabItem tab = items[i] as SuperTabItem; if (tab != null && tab.Parent != null && tab.Visible && tab.Enabled) return (i); } return (-1); } #endregion #region GetNextVisibleTab internal int GetNextVisibleTab(SubItemsCollection items, int n) { n = Math.Max(n, 0); for (int i = n; i < items.Count; i++) { SuperTabItem tab = items[i] as SuperTabItem; if (tab != null && tab.Parent != null && tab.Visible) return (i); } return (-1); } #endregion #region GetPrevVisibleTab internal int GetPrevVisibleTab(SubItemsCollection items, int n) { n = Math.Min(n, items.Count - 1); for (int i = n; i >= 0; i--) { SuperTabItem tab = items[i] as SuperTabItem; if (tab != null && tab.Parent != null && tab.Visible) return (i); } return (-1); } #endregion #region UpdateSelectedTab /// /// UpdateSelectedTab /// internal void UpdateSelectedTab() { if (DesignMode == false) SelectNewTab(SelectedTab); RecalcSize(); } #endregion #region "On" processing #region OnTabStyleChanged /// /// OnTabStyleChanged /// private void OnTabStyleChanged() { MyRefresh(); EnsureVisible(SelectedTab); } #endregion #region OnMeasureTabItem /// /// OnMeasureTabItem /// /// /// /// /// internal Size OnMeasureTabItem(SuperTabItem tab, Size size, Graphics g) { if (MeasureTabItem != null) { SuperTabMeasureTabItemEventArgs args = new SuperTabMeasureTabItemEventArgs(tab, size, g); MeasureTabItem(this, args); return (args.Size); } return (size); } #endregion #region OnPreRenderTabItem /// /// OnPreRenderTabItem /// /// /// /// internal bool OnPreRenderTabItem(SuperTabItem tab, Graphics g) { if (PreRenderTabItem != null) { SuperTabPreRenderTabItemEventArgs args = new SuperTabPreRenderTabItemEventArgs(tab, g); PreRenderTabItem(this, args); return (args.Cancel); } return (false); } #endregion #region OnPostRenderTabItem /// /// OnPostRenderTabItem /// /// /// internal void OnPostRenderTabItem(SuperTabItem tab, Graphics g) { if (PostRenderTabItem != null) { SuperTabPostRenderTabItemEventArgs args = new SuperTabPostRenderTabItemEventArgs(tab, g); PostRenderTabItem(this, args); } } #endregion #region OnGetTabItemContentRectangle /// /// OnGetTabItemContentRectangle /// /// /// internal Rectangle OnGetTabItemContentRectangle(SuperTabItem tab) { if (GetTabItemContentRectangle != null) { SuperTabGetTabItemContentRectangleEventArgs args = new SuperTabGetTabItemContentRectangleEventArgs(tab); GetTabItemContentRectangle(this, args); return (args.ContentRectangle); } return (tab.TabItemDisplay.ContentRectangle()); } #endregion #region OnGetTabItemPath /// /// OnGetTabItemPath /// /// /// internal GraphicsPath OnGetTabItemPath(SuperTabItem tab) { if (GetTabItemPath != null) { SuperTabGetTabItemPathEventArgs args = new SuperTabGetTabItemPathEventArgs(tab); GetTabItemPath(this, args); return (args.Path); } return (null); } #endregion #region OnSelectedTabRemoved /// /// OnSelectedTabRemoved /// /// /// internal void OnSelectedTabRemoved(int index, SuperTabItem item) { SelectNewTab(index); } #endregion #region OnSelectedTabChanging /// /// OnSelectedTabChanging /// /// /// /// private bool OnSelectedTabChanging(SuperTabItem value, eEventSource eventSource) { if (SelectedTabChanging != null) { SuperTabStripSelectedTabChangingEventArgs eventData = new SuperTabStripSelectedTabChangingEventArgs(_SelectedTab, value, eventSource); SelectedTabChanging(this, eventData); return (eventData.Cancel); } return (false); } #endregion #region OnSelectedTabChanged /// /// OnSelectedTabChanged /// /// /// /// private void OnSelectedTabChanged(SuperTabItem oldTab, SuperTabItem newTab, eEventSource eventSource) { if (SelectedTabChanged != null) { SuperTabStripSelectedTabChangedEventArgs eventData = new SuperTabStripSelectedTabChangedEventArgs(oldTab, newTab, eventSource); SelectedTabChanged(this, eventData); } } #endregion #region OnBeforeTabDisplay /// /// OnBeforeTabDisplay /// /// internal void OnBeforeTabDisplay(SuperTabItem item) { if (BeforeTabDisplay != null) { SuperTabStripBeforeTabDisplayEventArgs args = new SuperTabStripBeforeTabDisplayEventArgs(item); BeforeTabDisplay(this, args); } } #endregion #region OnTabItemClose /// /// OnTabItemClose /// /// /// private bool OnTabItemClose(SuperTabItem tab) { if (TabItemClose != null) { SuperTabStripTabItemCloseEventArgs args = new SuperTabStripTabItemCloseEventArgs(tab); args.Cancel = (AutoCloseTabs == false); TabItemClose(this, args); return (args.Cancel); } return (AutoCloseTabs == false); } #endregion #region OnTabStripColorChanged /// /// OnTabStripColorChanged /// private void OnTabStripColorChanged() { if (TabStripColorChanged != null) TabStripColorChanged(this, EventArgs.Empty); MyRefresh(); } #endregion #region OnPaintBackground /// /// OnPaintBackground /// /// /// internal void OnPaintBackground(Graphics g, SuperTabColorTable ct) { if (TabStripPaintBackground != null) TabStripPaintBackground(this, new SuperTabStripPaintBackgroundEventArgs(g, ct)); } #endregion #region OnGetTextBounds /// /// OnGetTextBounds /// /// /// /// internal Rectangle OnGetTextBounds(SuperTabItem tab, Rectangle bounds) { if (GetTabTextBounds != null) { SuperTabGetTabTextBoundsEventArgs ev = new SuperTabGetTabTextBoundsEventArgs(tab, bounds); GetTabTextBounds(this, ev); bounds = ev.Bounds; } return (bounds); } #endregion #region OnGetImageBounds /// /// OnGetImageBounds /// /// /// /// internal Rectangle OnGetImageBounds(SuperTabItem tab, Rectangle bounds) { if (GetTabImageBounds != null) { SuperTabGetTabImageBoundsEventArgs ev = new SuperTabGetTabImageBoundsEventArgs(tab, bounds); GetTabImageBounds(this, ev); bounds = ev.Bounds; } return (bounds); } #endregion #region OnGetCloseBounds /// /// OnGetCloseBounds /// /// /// /// internal Rectangle OnGetCloseBounds(SuperTabItem tab, Rectangle bounds) { if (GetTabCloseBounds != null) { SuperTabGetTabCloseBoundsEventArgs ev = new SuperTabGetTabCloseBoundsEventArgs(tab, bounds); GetTabCloseBounds(this, ev); bounds = ev.Bounds; } return (bounds); } #endregion #region OnTabMoving /// /// OnTabMoving /// /// /// /// /// protected bool OnTabMoving( BaseItem moveTab, BaseItem insertTab, bool insertBefore) { if (TabMoving != null) { SuperTabStripTabMovingEventArgs ev = new SuperTabStripTabMovingEventArgs(moveTab, insertTab, insertBefore); TabMoving(this, ev); return (ev.CanMove); } return (true); } #endregion #region OnTabMoved /// /// OnTabMoved /// /// Tab that was moved /// Old tab order /// New tab order /// protected bool OnTabMoved(SuperTabItem tab, List oldOrder, ref List newOrder) { if (TabMoved != null) { SuperTabStripTabMovedEventArgs ev = new SuperTabStripTabMovedEventArgs(tab, oldOrder, newOrder); TabMoved(this, ev); newOrder = ev.NewOrder; return (ev.Cancel); } return (false); } #endregion #endregion #region ItemAtLocation /// /// ItemAtLocation /// /// /// /// public override BaseItem ItemAtLocation(int x, int y) { Point pt = new Point(x, y); return (GetTabFromPoint(pt) ?? GetItemFromPoint(pt)); } #endregion #region Mouse support #region InternalClick /// /// InternalClick /// /// /// public override void InternalClick(MouseButtons mb, Point pt) { base.InternalClick(mb, pt); SuperTabItem tab = GetTabFromPoint(pt); if (tab != null) tab.InternalClick(mb, pt); } #endregion #region InternalMouseDown /// /// InternalMouseDown /// /// public override void InternalMouseDown(MouseEventArgs objArg) { base.InternalMouseDown(objArg); InternalOnMouseDown(objArg); } [EditorBrowsable(EditorBrowsableState.Never)] public void InternalOnMouseDown(MouseEventArgs objArg) { HideToolTip(); _TabArea = eSuperTabArea.InNone; SuperTabItem tab = GetTabFromPoint(objArg.Location); _MouseDownTab = tab; _MouseDownLocation = objArg.Location; if (tab != null) { if (objArg.Button == MouseButtons.Left) { if (tab.Enabled == true || DesignMode == true) { _TabArea = tab.GetTabAreaFromPoint(objArg.Location); if (_TabArea == eSuperTabArea.InContent || _TabArea == eSuperTabArea.InImage) { tab.TabStrip.Focus(); if (_SelectedTab != tab) SelectTab(tab, eEventSource.Mouse); } } else { _MouseDownTab = null; SystemSounds.Beep.Play(); } } } else { if (ControlBox.Visible == true) { if (ControlBox.IsMouseOver == true) ControlBox.InternalMouseDown(objArg); } } } #endregion #region InternalMouseUp /// /// InternalMouseUp /// /// public override void InternalMouseUp(MouseEventArgs objArg) { base.InternalMouseUp(objArg); InternalOnMouseUp(objArg); } [EditorBrowsable(EditorBrowsableState.Never)] public void InternalOnMouseUp(MouseEventArgs objArg) { if (_IsTabDragging == false) ProcessMouseUp(objArg); else ProcessTabUp(); _InsertTab = null; _MouseDownTab = null; _IsTabDragging = false; } #region ProcessMouseUp private void ProcessMouseUp(MouseEventArgs objArg) { SuperTabItem tab = GetTabFromPoint(objArg.Location); if (tab != null) { if (objArg.Button == MouseButtons.Left) { eSuperTabArea upTabArea = tab.GetTabAreaFromPoint(objArg.Location); if (_TabArea == eSuperTabArea.InCloseBox && upTabArea == eSuperTabArea.InCloseBox) { CloseTab(tab); } } } else { if (ControlBox.Visible == true) { if (ControlBox.IsMouseDown == true) ControlBox.InternalMouseUp(objArg); } } } #endregion #region ProcessTabUp private void ProcessTabUp() { _TabDragWindow.Owner.Cursor = Cursors.Default; _TabDragWindow.Dispose(); _TabDragWindow = null; if (_InsertTab != null) { SuperTabItem dragTab = _HotTab; List oldOrder = GetOldOrder(); List newOrder = GetNewOrder(); if (OnTabMoved(dragTab, oldOrder, ref newOrder) == false) { SubItems.Clear(); foreach (BaseItem item in newOrder) { bool visible = item.Visible; SubItems.Add(item); if (visible == false) item.Visible = false; } SelectedTab = dragTab; } } Refresh(); } #region GetOldOrder private List GetOldOrder() { List items = new List(SubItems.Count); foreach (BaseItem item in SubItems) items.Add(item); return (items); } #endregion #region GetNewOrder private List GetNewOrder() { List items = GetOldOrder(); int n = items.IndexOf(_InsertTab); int m = items.IndexOf(_HotTab); if (n >= 0 && m >= 0) { if ((_InsertBefore == false && n + 1 != m) || (_InsertBefore == true && n - 1 != m)) { items.Remove(_HotTab); n = items.IndexOf(_InsertTab); if (_InsertBefore == false) n++; items.Insert(n, _HotTab); } } return (items); } #endregion #endregion #endregion #region InternalMouseMove /// /// InternalMouseMove /// /// public override void InternalMouseMove(MouseEventArgs objArg) { if (_IsTabDragging == false) base.InternalMouseMove(objArg); InternalOnMouseMove(objArg); } /// /// InternalOnMouseMove /// /// [EditorBrowsable(EditorBrowsableState.Never)] public void InternalOnMouseMove(MouseEventArgs objArg) { SyncMouseState(); if (_IsTabDragging == false) ProcessMouseMove(objArg); else ProcessTabMove(objArg); } #region SyncMouseState private void SyncMouseState() { if (_MouseDownTab != null) { if (Control.MouseButtons == MouseButtons.None) { if (_TabDragWindow != null) { _TabDragWindow.Dispose(); _TabDragWindow = null; } _InsertTab = null; _MouseDownTab = null; _IsTabDragging = false; } } } #endregion #region ProcessMouseMove /// /// ProcessMouseMove /// /// private void ProcessMouseMove(MouseEventArgs objArg) { SuperTabItem tab = GetTabFromPoint(objArg.Location); if (_HotTab != tab || _HotTab != null) HotTabMouseMove(objArg, tab); else ControlBoxMouseMove(objArg); } #region HotTabMouseMove /// /// HotTabMouseMove /// /// /// private void HotTabMouseMove(MouseEventArgs objArg, SuperTabItem tab) { if (_HotTab != tab) { if (_HotTab != null) _HotTab.Refresh(); if (_HotTab == null || _HotTab.CloseButtonPressed == false) _HotTab = tab; if (_HotTab != null) _HotTab.Refresh(); ResetHover(); HideToolTip(); } else if (_HotTab != null) { StartTabMove(objArg); } } #endregion #region ControlBoxMouseMove /// /// ControlBoxMouseMove /// /// private void ControlBoxMouseMove(MouseEventArgs objArg) { if (ControlBox.Visible == true) { if (ControlBox.Bounds.Contains(objArg.Location)) { if (ControlBox.IsMouseOver == false) ControlBox.InternalMouseEnter(); ControlBox.InternalMouseMove(objArg); } else { if (ControlBox.IsMouseOver == true) ControlBox.InternalMouseLeave(); } } } #endregion #endregion #region ProcessTabMove /// /// ProcessTabMove /// /// private void ProcessTabMove(MouseEventArgs objArg) { _TabDragWindow.Location = new Point(Control.MousePosition.X, Control.MousePosition.Y + _TabDragWindow.Owner.Cursor.Size.Height / 2); _InsertTab = null; BaseItem item = GetItemFromPoint(objArg.Location); if (item != null && _HotTab != null) { Point pt = objArg.Location; switch (_TabStrip.TabAlignment) { case eTabStripAlignment.Top: case eTabStripAlignment.Bottom: _InsertBefore = (pt.X < item.Bounds.X + (item.Bounds.Width / 2)); break; default: _InsertBefore = (pt.Y < item.Bounds.Y + (item.Bounds.Height / 2)); break; } int n = SubItems.IndexOf(item); int m = SubItems.IndexOf(_HotTab); if (m != n && ((_InsertBefore == true && n - 1 != m) || (_InsertBefore == false && n + 1 != m))) _InsertTab = item; } if (OnTabMoving(_HotTab, _InsertTab, _InsertBefore) == false) _InsertTab = null; _TabDragWindow.Owner.Cursor = (_InsertTab != null) ? Cursors.Hand : Cursors.No; Refresh(); } #endregion #region StartTabMove /// /// StartTabMove /// /// /// private bool StartTabMove(MouseEventArgs objArg) { if (_ReorderTabsEnabled == true && _HotTab == _MouseDownTab && _MouseDownTab.CloseButtonPressed == false) { if (Math.Abs(_MouseDownLocation.X - objArg.Location.X) > 8 || Math.Abs(_MouseDownLocation.Y - objArg.Location.Y) > 8) { _IsTabDragging = true; _TabDragWindow = new SuperTabDragWindow(); _TabDragWindow.Owner = TabStrip.FindForm(); _TabDragWindow.Paint += TabDragWindowPaint; SetDragWindowRegion(); _TabDragWindow.Show(); _TabDragWindow.Size = _MouseDownTab.Bounds.Size; return (true); } } return (false); } #endregion #region SetDragWindowRegion /// /// SetDragWindowRegion /// private void SetDragWindowRegion() { Rectangle saveRect = _MouseDownTab.Bounds; Rectangle dragRect = saveRect; dragRect.Location = new Point(0, 0); try { _MouseDownTab.Bounds = dragRect; using (GraphicsPath path = _MouseDownTab.GetTabItemPath()) { GraphicsPath cpath = (GraphicsPath) path.Clone(); using (Pen pen = new Pen(Color.Black, 2)) cpath.Widen(pen); Region rgn = new Region(path); rgn.Union(cpath); _TabDragWindow.Region = rgn; } } finally { _MouseDownTab.Bounds = saveRect; } } #endregion #region TabDragWindow_Paint /// /// TabDragWindow_Paint /// /// /// void TabDragWindowPaint(object sender, PaintEventArgs e) { ItemPaintArgs p = new ItemPaintArgs(null, _TabStrip, e.Graphics, new ColorScheme()); Rectangle saveRect = _MouseDownTab.Bounds; Rectangle dragRect = saveRect; dragRect.Location = new Point(0, 0); try { _MouseDownTab.Bounds = dragRect; _MouseDownTab.Paint(p); } finally { _MouseDownTab.Bounds = saveRect; } } #endregion #endregion #region InternalMouseLeave /// /// InternalMouseLeave /// public override void InternalMouseLeave() { base.InternalMouseLeave(); InternalOnMouseLeave(); } /// /// InternalOnMouseLeave /// [EditorBrowsable(EditorBrowsableState.Never)] public void InternalOnMouseLeave() { HideToolTip(); if (_HotTab != null) { if (SubItems.Contains(_HotTab)) { _HotTab.CloseButtonMouseOver = false; _HotTab.Refresh(); _HotTab = null; Refresh(); } else { _HotTab = null; } } else { if (ControlBox.Visible == true) { if (ControlBox.IsMouseOver == true) ControlBox.InternalMouseLeave(); } } } #endregion #endregion #region GetTabFromPoint /// /// Get the tab at the given Point /// /// /// SuperTabItem or null public SuperTabItem GetTabFromPoint(Point pt) { if (SelectedTab != null) { if (SelectedTab.PointInTab(pt) == true) return (SelectedTab); } for (int i = 0; i < SubItems.Count; i++) { SuperTabItem tab = SubItems[i] as SuperTabItem; if (tab != null) { if (tab.Visible == true && tab.Displayed == true) { if (tab.PointInTab(pt) == true) return (tab); } } } return (null); } #endregion #region GetItemFromPoint /// /// Gets the item at the given point /// /// /// BaseItem or null public BaseItem GetItemFromPoint(Point pt) { for (int i = 0; i < SubItems.Count; i++) { BaseItem item = SubItems[i]; if (item.Visible == true && item.Displayed == true) { if (item.DisplayRectangle.Contains(pt)) return (item); } } return (null); } #endregion #region GetNextVisibleTab /// /// Gets the next visible Tab /// /// /// SuperTabItem internal SuperTabItem GetNextVisibleTab(int index) { if (index < 0 || index >= SubItems.Count) index = 0; for (int i = index; i < SubItems.Count; i++) { SuperTabItem tab = SubItems[i] as SuperTabItem; if (tab != null && tab.Visible == true) return (tab); } return (null); } #endregion #region CloseTab /// /// Closes the given tab /// /// public void CloseTab(SuperTabItem tab) { if (tab != null && SubItems.Contains(tab)) { if (OnTabItemClose(tab) == false) { if (_TabStrip.IsDesignMode == false) { SubItems.Remove(tab); Control c = tab.AttachedControl; if (c != null) { if (_TabStrip.Controls.Contains(c)) _TabStrip.Controls.Remove(c); c.Dispose(); } _TabStrip.RecalcLayout(); } } } } #endregion #region Paint /// /// Paint processing /// /// public override void Paint(ItemPaintArgs p) { if (_TabDisplay != null) _TabDisplay.Paint(p); } #endregion #region SubItemSizeChanged /// /// SubItemSizeChanged /// /// public override void SubItemSizeChanged(BaseItem objChildItem) { base.SubItemSizeChanged(objChildItem); _TabStrip.RecalcLayout(); if (DesignMode == false) SelectNewTab(SelectedTab); } #endregion #region Copy /// /// Returns copy of the item. /// public override BaseItem Copy() { SuperTabStripItem objCopy = new SuperTabStripItem(_TabStrip); CopyToItem(objCopy); return (objCopy); } /// /// Copies specific properties to new instance of the item. /// /// New SuperTabStripItem instance protected override void CopyToItem(BaseItem copy) { SuperTabStripItem objCopy = copy as SuperTabStripItem; if (objCopy != null) { base.CopyToItem(objCopy); objCopy.AutoCloseTabs = _AutoCloseTabs; objCopy.TabCloseButtonNormal = _TabCloseButtonNormal; objCopy.TabCloseButtonHot = _TabCloseButtonHot; objCopy.TabHorizontalSpacing = _TabHorizontalSpacing; objCopy.TabVerticalSpacing = _TabVerticalSpacing; objCopy.CloseButtonOnTabsVisible = _CloseButtonOnTabsVisible; objCopy.CloseButtonOnTabsAlwaysDisplayed = _CloseButtonOnTabsAlwaysDisplayed; objCopy.CloseButtonPosition = _CloseButtonPosition; objCopy.DisplaySelectedTextOnly = _DisplaySelectedTextOnly; objCopy.TabFont = _TabFont; objCopy.SelectedTabFont = _SelectedTabFont; objCopy.HorizontalText = _HorizontalText; objCopy.ShowFocusRectangle = _ShowFocusRectangle; objCopy.FixedTabSize = _FixedTabSize; objCopy.ReorderTabsEnabled = _ReorderTabsEnabled; objCopy.TabAlignment = _TabAlignment; objCopy.TabLayoutType = _TabLayoutType; objCopy.TabStripColor = _TabStripColor; objCopy.TabStyle = _TabStyle; objCopy.TextAlignment = _TextAlignment; } } #endregion #region IDesignTimeProvider Members protected virtual InsertPosition GetContainerInsertPosition(Point pScreen, BaseItem dragItem) { InsertPosition ip = DesignTimeProviderContainer.GetInsertPosition(this, pScreen, dragItem); if (ip != null) { if (ip.TargetProvider != this && dragItem is SuperTabItem) return (null); } return (ip); } InsertPosition IDesignTimeProvider.GetInsertPosition(Point pScreen, BaseItem dragItem) { return (GetContainerInsertPosition(pScreen, dragItem)); } void IDesignTimeProvider.DrawReversibleMarker(int iPos, bool before) { DesignTimeProviderContainer.DrawReversibleMarker(this, iPos, before); } void IDesignTimeProvider.InsertItemAt(BaseItem objItem, int iPos, bool before) { DesignTimeProviderContainer.InsertItemAt(this, objItem, iPos, before); } #endregion } #region enums public enum eSuperTabStyle { Office2007, Office2010BackstageBlue, OfficeMobile2014, OneNote2007, VisualStudio2008Dock, VisualStudio2008Document, WinMediaPlayer12, } public enum eSuperTabLayoutType { SingleLine, SingleLineFit, MultiLine, MultiLineFit } #endregion #region ValueChangingEventArgs /// /// Generic ValueChangingEventArgs /// /// oldValue type /// newValue type public class ValueChangingEventArgs : CancelEventArgs { #region Private variables private T1 _OldValue; private T2 _NewValue; #endregion public ValueChangingEventArgs(T1 oldValue, T2 newValue) { _OldValue = oldValue; _NewValue = newValue; } #region Public properties /// /// Gets the old value /// public T1 OldValue { get { return (_OldValue); } } /// /// Gets the new value /// public T2 NewValue { get { return (_NewValue); } } #endregion } #endregion #region ValueChangingSourceEventArgs /// /// Generic ValueChangingSourceEventArgs /// /// oldValue type /// newValue type /// EventSource public class ValueChangingSourceEventArgs : CancelEventArgs { #region Private variables private T1 _OldValue; private T2 _NewValue; private T3 _EventSource; #endregion public ValueChangingSourceEventArgs(T1 oldValue, T2 newValue, T3 eventSource) { _OldValue = oldValue; _NewValue = newValue; _EventSource = eventSource; } #region Public properties /// /// Gets the old value /// public T1 OldValue { get { return (_OldValue); } } /// /// Gets the new value /// public T2 NewValue { get { return (_NewValue); } } /// /// Gets the eventSource /// public T3 EventSource { get { return (_EventSource); } } #endregion } #endregion #region ValueChangedEventArgs /// /// Generic ValueChangedEventArgs /// /// oldValue type /// newValue type public class ValueChangedEventArgs : EventArgs { #region Private variables private T1 _OldValue; private T2 _NewValue; #endregion public ValueChangedEventArgs(T1 oldValue, T2 newValue) { _OldValue = oldValue; _NewValue = newValue; } #region Public properties /// /// Gets the old value /// public T1 OldValue { get { return (_OldValue); } } /// /// Gets the new value /// public T2 NewValue { get { return (_NewValue); } } #endregion } #endregion #region ValueChangedSourceEventArgs /// /// Generic ValueChangedSourceEventArgs /// /// oldValue type /// newValue type /// EventSource public class ValueChangedEventArgs : EventArgs { #region Private variables private T1 _OldValue; private T2 _NewValue; private T3 _EventSource; #endregion public ValueChangedEventArgs(T1 oldValue, T2 newValue, T3 eventSource) { _OldValue = oldValue; _NewValue = newValue; _EventSource = eventSource; } #region Public properties /// /// Gets the old value /// public T1 OldValue { get { return (_OldValue); } } /// /// Gets the new value /// public T2 NewValue { get { return (_NewValue); } } /// /// Gets the eventSource /// public T3 EventSource { get { return (_EventSource); } } #endregion } #endregion #region TabActionEventArgs public class TabActionEventArgs : EventArgs { #region Private variables private BaseItem _Tab; #endregion public TabActionEventArgs(BaseItem tab) { _Tab = tab; } #region Public properties /// /// Gets the tab /// public BaseItem Tab { get { return (_Tab); } } #endregion } #endregion #region SuperTabStripTabActionCancelEventArgs public class SuperTabStripTabActionCancelEventArgs : CancelEventArgs { #region Private variables private BaseItem _Tab; #endregion public SuperTabStripTabActionCancelEventArgs(BaseItem tab) { _Tab = tab; } #region Public properties /// /// Gets the tab /// public BaseItem Tab { get { return (_Tab); } } #endregion } #endregion #region SuperTabStripSelectedTabChangingEventArgs public class SuperTabStripSelectedTabChangingEventArgs : ValueChangingSourceEventArgs { public SuperTabStripSelectedTabChangingEventArgs(BaseItem oldValue, BaseItem newValue, eEventSource source) : base(oldValue, newValue, source) { } } #endregion #region SuperTabStripSelectedTabChangedEventArgs public class SuperTabStripSelectedTabChangedEventArgs : ValueChangingSourceEventArgs { public SuperTabStripSelectedTabChangedEventArgs(BaseItem oldValue, BaseItem newValue, eEventSource source) : base(oldValue, newValue, source) { } } #endregion #region SuperTabStripBeforeTabDisplayEventArgs public class SuperTabStripBeforeTabDisplayEventArgs : TabActionEventArgs { public SuperTabStripBeforeTabDisplayEventArgs(BaseItem tab) : base(tab) { } } #endregion #region SuperTabStripTabRemovedEventArgs public class SuperTabStripTabRemovedEventArgs : TabActionEventArgs { public SuperTabStripTabRemovedEventArgs(BaseItem tab) : base(tab) { } } #endregion #region SuperTabStripTabMovingEventArgs public class SuperTabStripTabMovingEventArgs : EventArgs { #region Private variables private BaseItem _MoveTab; private BaseItem _InsertTab; private bool _InsertBefore; private bool _CanMove = true; #endregion public SuperTabStripTabMovingEventArgs( BaseItem moveTab, BaseItem insertTab, bool insertBefore) { _MoveTab = moveTab; _InsertTab = insertTab; _InsertBefore = insertBefore; } #region Public properties public BaseItem MoveTab { get { return (_MoveTab); } } public BaseItem InsertTab { get { return (_InsertTab); } } public bool InsertBefore { get { return (_InsertBefore); } } public bool CanMove { get { return (_CanMove); } set { _CanMove = value; } } #endregion } #endregion #region SuperTabStripTabMovedEventArgs public class SuperTabStripTabMovedEventArgs : SuperTabStripTabActionCancelEventArgs { #region Private variables List _OldOrder; List _NewOrder; #endregion public SuperTabStripTabMovedEventArgs( BaseItem tab, List oldOrder, List newOrder) : base(tab) { _OldOrder = oldOrder; _NewOrder = newOrder; } #region Public properties /// /// Gets the old order of the tabs /// public List OldOrder { get { return (_OldOrder); } } /// /// Gets or sets the new order of the tabs /// public List NewOrder { get { return (_NewOrder); } set { _NewOrder = value; } } #endregion } #endregion #region SuperTabStripTabItemCloseEventArgs public class SuperTabStripTabItemCloseEventArgs : SuperTabStripTabActionCancelEventArgs { public SuperTabStripTabItemCloseEventArgs(BaseItem tab) : base(tab) { } } #endregion #region SuperTabStripTabItemOpenEventArgs public class SuperTabStripTabItemOpenEventArgs : TabActionEventArgs { public SuperTabStripTabItemOpenEventArgs(BaseItem tab) : base(tab) { } } #endregion #region SuperTabMeasureTabItemEventArgs public class SuperTabMeasureTabItemEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; private Size _Size; private Graphics _Graphics; #endregion public SuperTabMeasureTabItemEventArgs(SuperTabItem tab, Size size, Graphics graphics) { _Tab = tab; _Size = size; _Graphics = graphics; } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public Size Size { get { return (_Size); } set { _Size = value; } } public Graphics Graphics { get { return (_Graphics); } } #endregion } #endregion #region SuperTabPreRenderTabItemEventArgs public class SuperTabPreRenderTabItemEventArgs : CancelEventArgs { #region Private variables private SuperTabItem _Tab; private Graphics _Graphics; #endregion public SuperTabPreRenderTabItemEventArgs(SuperTabItem tab, Graphics graphics) { _Tab = tab; _Graphics = graphics; } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public Graphics Graphics { get { return (_Graphics); } } #endregion } #endregion #region SuperTabPostRenderTabItemEventArgs public class SuperTabPostRenderTabItemEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; private Graphics _Graphics; #endregion public SuperTabPostRenderTabItemEventArgs(SuperTabItem tab, Graphics graphics) { _Tab = tab; _Graphics = graphics; } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public Graphics Graphics { get { return (_Graphics); } } #endregion } #endregion #region SuperTabGetTabTextBoundsEventArgs public class SuperTabGetTabTextBoundsEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; private Rectangle _Bounds; #endregion public SuperTabGetTabTextBoundsEventArgs(SuperTabItem tab, Rectangle bounds) { _Tab = tab; _Bounds = bounds; } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public Rectangle Bounds { get { return (_Bounds); } set { _Bounds = value; } } #endregion } #endregion #region SuperTabGetTabImageBoundsEventArgs public class SuperTabGetTabImageBoundsEventArgs : SuperTabGetTabTextBoundsEventArgs { public SuperTabGetTabImageBoundsEventArgs(SuperTabItem tab, Rectangle bounds) : base(tab, bounds) { } } #endregion #region SuperTabGetTabCloseBoundsEventArgs public class SuperTabGetTabCloseBoundsEventArgs : SuperTabGetTabImageBoundsEventArgs { public SuperTabGetTabCloseBoundsEventArgs(SuperTabItem tab, Rectangle bounds) : base(tab, bounds) { } } #endregion #region SuperTabStripPaintBackgroundEventArgs public class SuperTabStripPaintBackgroundEventArgs : EventArgs { #region Private variables private Graphics _Graphics; private SuperTabColorTable _ColorTable; #endregion public SuperTabStripPaintBackgroundEventArgs(Graphics graphics, SuperTabColorTable colorTable) { _Graphics = graphics; _ColorTable = colorTable; } #region Public properties public Graphics Graphics { get { return (_Graphics); } } public SuperTabColorTable ColorTable { get { return (_ColorTable); } } #endregion } #endregion #region SuperTabStripTabColorChangedEventArgs /// /// TabStripTabColorChangedEventArgs /// public class SuperTabStripTabColorChangedEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; #endregion #region Public properties public SuperTabItem Tab { get { return (_Tab); } } #endregion public SuperTabStripTabColorChangedEventArgs(SuperTabItem tab) { _Tab = tab; } } #endregion #region SuperTabGetTabItemPathEventArgs public class SuperTabGetTabItemPathEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; private GraphicsPath _Path; #endregion public SuperTabGetTabItemPathEventArgs(SuperTabItem tab) { _Tab = tab; } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public GraphicsPath Path { get { return (_Path); } set { _Path = value; } } #endregion } #endregion #region SuperTabGetTabItemGetContentRectangleEventArgs public class SuperTabGetTabItemContentRectangleEventArgs : EventArgs { #region Private variables private SuperTabItem _Tab; private Rectangle _ContentRectangle; #endregion public SuperTabGetTabItemContentRectangleEventArgs(SuperTabItem tab) { _Tab = tab; _ContentRectangle = tab.TabItemDisplay.ContentRectangle(); } #region Public properties public SuperTabItem Tab { get { return (_Tab); } } public Rectangle ContentRectangle { get { return (_ContentRectangle); } set { _ContentRectangle = value; } } #endregion } #endregion } #endif