#if FRAMEWORK20 using System; using System.ComponentModel; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using DevComponents.DotNetBar.Rendering; namespace DevComponents.DotNetBar { [ToolboxItem(true), ComVisible(false)] [Designer("DevComponents.DotNetBar.Design.SuperTabStripDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")] public class SuperTabStrip : ItemControl, ISupportInitialize { #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; #endregion #region Private variables private BaseItem _DesignTimeSelection; private SuperTabStripItem _TabStripItem; private bool _IsInitializing; private bool _Available = true; #endregion /// /// Constructor /// public SuperTabStrip() { _TabStripItem = new SuperTabStripItem(this); _TabStripItem.GlobalItem = false; _TabStripItem.ContainerControl = this; _TabStripItem.Stretch = false; _TabStripItem.Displayed = true; _TabStripItem.SetOwner(this); SetBaseItemContainer(_TabStripItem); SetStyle(ControlStyles.SupportsTransparentBackColor, true); HookEvents(true); StyleManager.Register(this); } #region Public properties #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. /// [Browsable(false)] public bool AutoSelectAttachedControl { get { return (TabStripItem.AutoSelectAttachedControl); } set { TabStripItem.AutoSelectAttachedControl = value; } } #endregion #region Close button properties #region AutoCloseTabs /// /// Gets or sets whether tabs are automatically closed when a close button is clicked /// [Browsable(true), DefaultValue(true), Category("Close Button")] [Description("Indicates whether tab is automatically closed when close button is clicked.")] public bool AutoCloseTabs { get { return (_TabStripItem.AutoCloseTabs); } set { _TabStripItem.AutoCloseTabs = value; } } #endregion #region CloseButtonOnTabsAlwaysDisplayed /// /// Gets or sets whether the tab's visible close button is displayed for every tab state /// [Browsable(true), DefaultValue(true), DevCoBrowsable(true), Category("Close Button")] [Description("Indicates whether the tab's visible close button is displayed for every tab state.")] public bool CloseButtonOnTabsAlwaysDisplayed { get { return (_TabStripItem.CloseButtonOnTabsAlwaysDisplayed); } set { _TabStripItem.CloseButtonOnTabsAlwaysDisplayed = value; } } #endregion #region CloseButtonOnTabsVisible /// /// Gets or sets whether close button is visible on each tab /// [Browsable(true), DefaultValue(false), DevCoBrowsable(true), Category("Close Button")] [Description("Indicates whether close button is visible on each tab.")] public bool CloseButtonOnTabsVisible { get { return (_TabStripItem.CloseButtonOnTabsVisible); } set { _TabStripItem.CloseButtonOnTabsVisible = value; } } #endregion #region CloseButtonPosition /// /// Gets or sets the position of the tab close button /// [Browsable(true), DefaultValue(eTabCloseButtonPosition.Right), DevCoBrowsable(true)] [Category("Close Button"), Description("Indicates the position of the tab close button.")] public eTabCloseButtonPosition CloseButtonPosition { get { return (_TabStripItem.CloseButtonPosition); } set { _TabStripItem.CloseButtonPosition = value; } } #endregion #region TabCloseButtonNormal /// /// Gets or sets the custom tab Close button image /// [Browsable(true), DefaultValue(null), Category("Close Button")] [Description("Indicates the custom tab Close button image.")] public Image TabCloseButtonNormal { get { return (_TabStripItem.TabCloseButtonNormal); } set { _TabStripItem.TabCloseButtonNormal = value; } } #endregion #region TabCloseButtonHot /// /// Gets or sets the custom Close button image that is used on tabs when the mouse is over the close button /// public Image TabCloseButtonHot { get { return (_TabStripItem.TabCloseButtonHot); } set { _TabStripItem.TabCloseButtonHot = value; } } #endregion #region TabCloseButtonPressed /// /// Gets or sets the custom Close button image that is used on tabs when the button has been pressed /// [Browsable(true), DefaultValue(null), Category("Close Button")] [Description("Indicates custom Close button image that is used on tabs when the button has been pressed.")] public Image TabCloseButtonPressed { get { return (_TabStripItem.TabCloseButtonPressed); } set { _TabStripItem.TabCloseButtonPressed = value; } } #endregion #region Visible public new bool Visible { get { return (base.Visible); } set { _Available = value; base.Visible = value; SuperTabControl stc = Parent as SuperTabControl; if (stc != null) stc.RefreshPanelsStyle(); } } #endregion #endregion #region ControlBox /// /// Gets the TabStrip ControlBox /// [Browsable(true), Category("Appearance")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Description("Gets the TabStrip ControlBox.")] public SuperTabControlBox ControlBox { get { return (_TabStripItem.ControlBox); } } #endregion #region DesignTimeSelection [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public BaseItem DesignTimeSelection { get { return (_DesignTimeSelection); } set { _DesignTimeSelection = value; Invalidate(); } } #endregion #region DisplaySelectedTextOnly /// /// Gets or sets whether the only Text displayed is for the SelectedTab /// [Browsable(true), DevCoBrowsable(true), Category("Behavior"), DefaultValue(false)] [Description("Specifies whether the only Text displayed is for the SelectedTab.")] public bool DisplaySelectedTextOnly { get { return (_TabStripItem.DisplaySelectedTextOnly); } set { _TabStripItem.DisplaySelectedTextOnly = value; } } #endregion #region HorizontalText [Browsable(true), DefaultValue(true), Category("Appearance")] [Description("Indicates whether text is drawn horizontally regardless of tab orientation.")] public bool HorizontalText { get { return (_TabStripItem.HorizontalText); } set { _TabStripItem.HorizontalText = value; } } #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 (_TabStripItem.ImageAlignment); } set { _TabStripItem.ImageAlignment = value; } } #endregion #region ImageList [Browsable(true), DevCoBrowsable(true), Category("Appearance"), DefaultValue(null)] public ImageList ImageList { get { return (Images); } set { Images = value; } } #endregion #region ItemPadding /// /// Gets or sets BaseItem tab padding in pixels. /// [Browsable(true), Category("Layout")] [Description("Indicates BaseItem tab padding in pixels.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Padding ItemPadding { get { return (_TabStripItem.ItemPadding); } set { _TabStripItem.ItemPadding = value; } } #endregion #region RotateVerticalText /// /// Gets or sets whether vertical tab text is rotated 180 degrees /// [Browsable(true), DefaultValue(false), Category("Layout")] [Description("Indicates whether vertical tab text is rotated 180 degrees.")] public bool RotateVerticalText { get { return (_TabStripItem.RotateVerticalText); } set { _TabStripItem.RotateVerticalText = value; } } #endregion #region ShowFocusRectangle [Browsable(true), DefaultValue(false), Category("Behavior")] [Description("Indicates whether focus rectangle is displayed when tab has input focus.")] public bool ShowFocusRectangle { get { return (_TabStripItem.ShowFocusRectangle); } set { _TabStripItem.ShowFocusRectangle = value; } } #endregion #region Tab properties #region FixedTabSize /// /// Gets or sets the fixed tab size in pixels. Either Height, Width, or both can be set /// [Browsable(true), Category("Appearance")] [Description("Indicates the fixed tab size in pixels. Either Height, Width, or both can be set.")] public Size FixedTabSize { get { return (_TabStripItem.FixedTabSize); } set { _TabStripItem.FixedTabSize = value; } } [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeFixedTabSize() { return (_TabStripItem.ShouldSerializeFixedTabSize()); } [EditorBrowsable(EditorBrowsableState.Never)] public void ResetFixedTabSize() { TypeDescriptor.GetProperties(this)["FixedTabSize"].SetValue(this, Size.Empty); } #endregion #region IsTabDragging /// /// Gets or sets whether a tab is currently in a drag operation /// [Browsable(false)] public bool IsTabDragging { get { return (_TabStripItem.IsTabDragging); } } #endregion #region ReorderTabsEnabled /// /// Gets or sets whether tabs can be reordered through the user interface /// [Browsable(true), DevCoBrowsable(true), Category("Behavior")] [Description("Indicates whether the control tabs can be reordered through the user interface.")] public bool ReorderTabsEnabled { get { return (_TabStripItem.ReorderTabsEnabled); } set { _TabStripItem.ReorderTabsEnabled = value; } } #endregion #region SelectedTab /// /// Gets or sets the selected tab /// [Browsable(false), DevCoBrowsable(false), Category("Behavior")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public SuperTabItem SelectedTab { get { return (_TabStripItem.SelectedTab); } set {_TabStripItem.SelectedTab = value; } } #endregion #region SelectedTabFont /// /// Gets or sets the selected tab Font /// [Browsable(true), DevCoBrowsable(true), Localizable(true), Category("Style"), DefaultValue(null)] [Description("Indicates the selected tab Font")] public Font SelectedTabFont { get { return (_TabStripItem.SelectedTabFont); } set { _TabStripItem.SelectedTabFont = value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeSelectedTabFont() { return (_TabStripItem.ShouldSerializeSelectedTabFont()); } [EditorBrowsable(EditorBrowsableState.Never)] public void ResetSelectedTabFont() { _TabStripItem.ResetSelectedTabFont(); } #endregion #region SelectedTabIndex /// /// Gets or sets the index of the selected tab /// [Browsable(true), DevCoBrowsable(true), Category("Behavior")] [Description("Indicates the index of the selected tab.")] public int SelectedTabIndex { get { return (_TabStripItem.SelectedTabIndex); } set {_TabStripItem.SelectedTabIndex = value; } } #endregion #region TabAlignment /// /// Gets or sets the tab alignment within the Tab-Strip control /// [Browsable(true), DefaultValue(eTabStripAlignment.Top), DevCoBrowsable(true)] [Category("Appearance"), Description("Indicates the tab alignment within the Tab-Strip control.")] public eTabStripAlignment TabAlignment { get { return (_TabStripItem.TabAlignment); } set {_TabStripItem.TabAlignment = value; } } #endregion #region TabFont /// /// Gets or sets the tab Font /// [Browsable(true), DevCoBrowsable(true), Localizable(true), Category("Style"), DefaultValue(null)] [Description("Indicates the tab Font")] public Font TabFont { get { return (_TabStripItem.TabFont); } set { _TabStripItem.TabFont = value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeTabFont() { return (_TabStripItem.ShouldSerializeTabFont()); } [EditorBrowsable(EditorBrowsableState.Never)] public void ResetTabFont() { _TabStripItem.ResetTabFont(); } #endregion #region TabHorizontalSpacing /// /// Gets or sets the Horizontal spacing around tab elements /// [Browsable(true), DefaultValue(5), Category("Appearance")] [Description("Indicates the Horizontal spacing around tab elements.")] public int TabHorizontalSpacing { get { return (_TabStripItem.TabHorizontalSpacing); } set { _TabStripItem.TabHorizontalSpacing = value; } } #endregion #region TabLayoutType /// /// Gets or sets the type of the tab layout /// [Browsable(true), DefaultValue(eSuperTabLayoutType.SingleLine), Category("Appearance")] [Description("Indicates the type of the tab layout.")] public eSuperTabLayoutType TabLayoutType { get { return (_TabStripItem.TabLayoutType); } set { _TabStripItem.TabLayoutType = value; } } #endregion #region Tabs /// /// Gets the collection of Tabs /// [Editor("DevComponents.DotNetBar.Design.SuperTabStripTabsEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Category("Data"), Description("Returns the collection of Tabs.")] public SubItemsCollection Tabs { get { return (_TabStripItem.SubItems); } } #endregion #region TabStripColor /// /// Gets or sets the Color of the TabStrip /// [Browsable(true), Category("Appearance")] [Description("Indicates the Color of the TabStrip.")] public SuperTabColorTable TabStripColor { get { return (_TabStripItem.TabStripColor); } set { _TabStripItem.TabStripColor = value; } } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeTabStripColor() { return (_TabStripItem.TabStripColor.IsEmpty == false); } [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public void ResetTabStripColor() { _TabStripItem.TabStripColor = new SuperTabColorTable(); } #endregion #region TabStyle /// /// Gets or sets the tab style /// [Browsable(true), DevCoBrowsable(true), DefaultValue(eSuperTabStyle.Office2007)] [Category("Appearance"), Description("Indicates the tab style.")] public eSuperTabStyle TabStyle { get { return (_TabStripItem.TabStyle); } set { _TabStripItem.TabStyle = value; } } #endregion #region TabVerticalSpacing /// /// Gets or sets the Vertical spacing around tab elements /// [Browsable(true), DefaultValue(4), Category("Appearance")] [Description("Indicates the Vertical spacing around tab elements.")] public int TabVerticalSpacing { get { return (_TabStripItem.TabVerticalSpacing); } set { _TabStripItem.TabVerticalSpacing = value; } } #endregion #endregion #region TabStripItem /// /// Gets the TabStrip associated TabStripItem /// [Browsable(false)] public SuperTabStripItem TabStripItem { get { return (_TabStripItem); } } #endregion #region TextAlignment /// /// Gets or sets tab text alignment /// [Browsable(true), DefaultValue(eItemAlignment.Near)] [DevCoBrowsable(true), Category("Layout"), Description("Indicates tab text alignment.")] public eItemAlignment TextAlignment { get { return (_TabStripItem.TextAlignment); } set { _TabStripItem.TextAlignment = value; } } #endregion #endregion #region Internal properties #region Available /// /// Gets whether the tabStrip is visually available /// internal bool Available { get { return (_Available); } } #endregion #region IsDesignMode /// /// Gets the Design state for the control /// internal bool IsDesignMode { get { if (Parent != null && Parent is SuperTabControl && Parent.Site != null) return (Parent.Site.DesignMode); return (DesignMode); } } #endregion #region IsInitializing /// /// Gets the ISupportInitialize state /// internal bool IsInitializing { get { return (_IsInitializing); } } #endregion #region TabDisplay /// /// Gets the TabDisplay /// internal SuperTabStripBaseDisplay TabDisplay { get { return (_TabStripItem.TabDisplay); } } #endregion #region ApplicationButton private BaseItem _ApplicationButton; /// /// Gets or sets the reference to ribbon application button when tab control is used as backstage ribbon control. /// [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public BaseItem ApplicationButton { get { return _ApplicationButton; } set { _ApplicationButton = value; } } #endregion #endregion #region HookEvents /// /// Hooks or unhooks TabStripItem events /// /// true to hook private void HookEvents(bool hook) { if (hook == true) { _TabStripItem.TabItemOpen += TabStripItemTabItemOpen; _TabStripItem.TabItemClose += TabStripItem_TabItemClose; _TabStripItem.TabRemoved += TabStripItem_TabRemoved; _TabStripItem.TabMoving += TabStripItem_TabMoving; _TabStripItem.TabMoved += TabStripItem_TabMoved; _TabStripItem.GetTabItemPath += TabStripItem_GetTabItemPath; _TabStripItem.GetTabItemContentRectangle += TabStripItem_GetTabItemContentRectangle; _TabStripItem.BeforeTabDisplay += TabStripItem_BeforeTabDisplay; _TabStripItem.MeasureTabItem += TabStripItem_MeasureTabItem; _TabStripItem.PreRenderTabItem += TabStripItem_PreRenderTabItem; _TabStripItem.PostRenderTabItem += TabStripItem_PostRenderTabItem; _TabStripItem.GetTabTextBounds += TabStripItem_GetTabTextBounds; _TabStripItem.GetTabImageBounds += TabStripItem_GetTabImageBounds; _TabStripItem.GetTabCloseBounds += TabStripItem_GetTabCloseBounds; _TabStripItem.TabStripPaintBackground += TabStripItem_TabStripPaintBackground; _TabStripItem.SelectedTabChanging += TabStripItem_SelectedTabChanging; _TabStripItem.SelectedTabChanged += TabStripItem_SelectedTabChanged; _TabStripItem.TabStripTabColorChanged += TabStripItem_TabStripTabColorChanged; } else { _TabStripItem.TabItemOpen -= TabStripItemTabItemOpen; _TabStripItem.TabItemClose -= TabStripItem_TabItemClose; _TabStripItem.TabRemoved -= TabStripItem_TabRemoved; _TabStripItem.TabMoving -= TabStripItem_TabMoving; _TabStripItem.TabMoved -= TabStripItem_TabMoved; _TabStripItem.GetTabItemPath -= TabStripItem_GetTabItemPath; _TabStripItem.GetTabItemContentRectangle -= TabStripItem_GetTabItemContentRectangle; _TabStripItem.BeforeTabDisplay -= TabStripItem_BeforeTabDisplay; _TabStripItem.MeasureTabItem -= TabStripItem_MeasureTabItem; _TabStripItem.PreRenderTabItem -= TabStripItem_PreRenderTabItem; _TabStripItem.PostRenderTabItem -= TabStripItem_PostRenderTabItem; _TabStripItem.GetTabTextBounds -= TabStripItem_GetTabTextBounds; _TabStripItem.GetTabImageBounds -= TabStripItem_GetTabImageBounds; _TabStripItem.GetTabCloseBounds -= TabStripItem_GetTabCloseBounds; _TabStripItem.TabStripPaintBackground -= TabStripItem_TabStripPaintBackground; _TabStripItem.SelectedTabChanging -= TabStripItem_SelectedTabChanging; _TabStripItem.SelectedTabChanged -= TabStripItem_SelectedTabChanged; _TabStripItem.TabStripTabColorChanged -= TabStripItem_TabStripTabColorChanged; } } #endregion #region Event processing #region TabStripItem_TabItemOpen /// /// TabStripItem_TabItemOpen /// /// /// void TabStripItemTabItemOpen(object sender, SuperTabStripTabItemOpenEventArgs e) { if (TabItemOpen != null) TabItemOpen(this, e); } #endregion #region TabStripItem_TabItemClose /// /// TabStripItem_TabItemClose /// /// /// void TabStripItem_TabItemClose(object sender, SuperTabStripTabItemCloseEventArgs e) { if (TabItemClose != null) TabItemClose(this, e); } #endregion #region TabStripItem_TabRemoved /// /// TabStripItem_TabRemoved /// /// /// void TabStripItem_TabRemoved(object sender, SuperTabStripTabRemovedEventArgs e) { if (TabRemoved != null) TabRemoved(this, e); } #endregion #region TabStripItem_TabMoving /// /// TabStripItem_TabMoving /// /// /// void TabStripItem_TabMoving(object sender, SuperTabStripTabMovingEventArgs e) { if (TabMoving != null) TabMoving(this, e); } #endregion #region TabStripItem_TabMoved /// /// TabStripItem_TabMoved /// /// /// void TabStripItem_TabMoved(object sender, SuperTabStripTabMovedEventArgs e) { if (TabMoved != null) TabMoved(this, e); } #endregion #region TabStripItem_GetTabItemPath /// /// TabStripItem_GetTabItemPath /// /// /// void TabStripItem_GetTabItemPath(object sender, SuperTabGetTabItemPathEventArgs e) { if (GetTabItemPath != null) GetTabItemPath(this, e); } #endregion #region TabStripItem_GetTabItemContentRectangle /// /// TabStripItem_GetTabItemContentRectangle /// /// /// void TabStripItem_GetTabItemContentRectangle(object sender, SuperTabGetTabItemContentRectangleEventArgs e) { if (GetTabItemContentRectangle != null) GetTabItemContentRectangle(this, e); } #endregion #region TabStripItem_BeforeTabDisplay /// /// TabStripItem_BeforeTabDisplay /// /// /// void TabStripItem_BeforeTabDisplay(object sender, SuperTabStripBeforeTabDisplayEventArgs e) { if (BeforeTabDisplay != null) BeforeTabDisplay(this, e); } #endregion #region TabStripItem_MeasureTabItem /// /// TabStripItem_MeasureTabItem /// /// /// void TabStripItem_MeasureTabItem(object sender, SuperTabMeasureTabItemEventArgs e) { if (MeasureTabItem != null) MeasureTabItem(this, e); } #endregion #region TabStripItem_PreRenderTabItem /// /// TabStripItem_PreRenderTabItem /// /// /// private void TabStripItem_PreRenderTabItem(object sender, SuperTabPreRenderTabItemEventArgs e) { if (PreRenderTabItem != null) PreRenderTabItem(this, e); } #endregion #region TabStripItem_PostRenderTabItem /// /// TabStripItem_PostRenderTabItem /// /// /// void TabStripItem_PostRenderTabItem(object sender, SuperTabPostRenderTabItemEventArgs e) { if (PostRenderTabItem != null) PostRenderTabItem(this, e); } #endregion #region TabStripItem_GetTabCloseBounds /// /// TabStripItem_GetTabCloseBounds /// /// /// void TabStripItem_GetTabCloseBounds(object sender, SuperTabGetTabCloseBoundsEventArgs e) { if (GetTabCloseBounds != null) GetTabCloseBounds(this, e); } #endregion #region TabStripItem_GetTabImageBounds /// /// TabStripItem_GetTabImageBounds /// /// /// void TabStripItem_GetTabImageBounds(object sender, SuperTabGetTabImageBoundsEventArgs e) { if (GetTabImageBounds != null) GetTabImageBounds(this, e); } #endregion #region TabStripItem_GetTabTextBounds /// /// TabStripItem_GetTabTextBounds /// /// /// void TabStripItem_GetTabTextBounds(object sender, SuperTabGetTabTextBoundsEventArgs e) { if (GetTabTextBounds != null) GetTabTextBounds(this, e); } #endregion #region TabStripItem_TabStripPaintBackground /// /// TabStripItem_TabStripPaintBackground /// /// /// void TabStripItem_TabStripPaintBackground(object sender, SuperTabStripPaintBackgroundEventArgs e) { if (TabStripPaintBackground != null) TabStripPaintBackground(this, e); } #endregion #region TabStripItem_SelectedTabChanging /// /// TabStripItem_SelectedTabChanging /// /// /// void TabStripItem_SelectedTabChanging(object sender, SuperTabStripSelectedTabChangingEventArgs e) { if (SelectedTabChanging != null) SelectedTabChanging(this, e); } #endregion #region TabStripItem_SelectedTabChanged /// /// TabStripItem_SelectedTabChanged /// /// /// void TabStripItem_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e) { if (SelectedTabChanged != null) SelectedTabChanged(this, e); } #endregion #region TabStripItem_TabStripTabColorChanged /// /// TabStripItem_TabStripTabColorChanged /// /// /// void TabStripItem_TabStripTabColorChanged(object sender, SuperTabStripTabColorChangedEventArgs e) { if (TabStripTabColorChanged != null) TabStripTabColorChanged(this, e); } #endregion #region Theme Changing /// /// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if /// its style is controlled by StyleManager. /// /// New active style. [EditorBrowsable(EditorBrowsableState.Never)] public void StyleManagerStyleChanged(eDotNetBarStyle newStyle) { if (BarFunctions.IsHandleValid(this)) this.Invalidate(true); TabDisplay.SetDefaultColorTable(); } #endregion #endregion #region DefaultSize /// /// Gets the DefaultSize /// protected override Size DefaultSize { get { return new Size(236, 25); } } #endregion #region RecalcLayout private bool _RecalcLayoutInProgress = false; /// /// Performs layout recalculation /// public override void RecalcLayout() { if (!this.IsHandleCreated || _RecalcLayoutInProgress) return; // Do not force creation of Control Handle by going through RecalcLayout. It breaks up the actual layout of controls when Anchor and Dock properties are used. _RecalcLayoutInProgress = true; try { base.RecalcLayout(); if (_IsInitializing == false) { if (_TabStripItem != null) _TabStripItem.RecalcSize(); } } finally { _RecalcLayoutInProgress = false; } } #endregion #region EnsureVisible /// /// Ensures that the given tab is visible on the TabStrip /// /// public void EnsureVisible(SuperTabItem tab) { _TabStripItem.EnsureVisible(tab); } #endregion #region GetTabFromPoint /// /// Gets the SuperTabItem from the given Point /// /// /// SuperTabItem or null public SuperTabItem GetTabFromPoint(Point pt) { return (_TabStripItem.GetTabFromPoint(pt)); } #endregion #region GetItemFromPoint /// /// Gets the BaseItem from the given Point /// /// /// BaseItem or null public BaseItem GetItemFromPoint(Point pt) { return (_TabStripItem.GetItemFromPoint(pt)); } #endregion #region CloseTab /// /// Closes the given tab /// /// public void CloseTab(SuperTabItem tab) { _TabStripItem.CloseTab(tab); } #endregion #region SelectPreviousTab /// /// Selects the previous tab /// /// true if successful public bool SelectPreviousTab() { return (_TabStripItem.SelectPreviousTab()); } #endregion #region SelectNextTab /// /// Selects the next tab /// /// true if successful public bool SelectNextTab() { return (_TabStripItem.SelectNextTab()); } #endregion #region OnResize /// /// OnResize processing /// /// protected override void OnResize(EventArgs e) { base.OnResize(e); if (_TabStripItem != null) _TabStripItem.VisibleTab = null; RecalcLayout(); } #endregion #region OnGotFocus protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); if (SelectedTab != null) SelectedTab.Refresh(); } #endregion #region OnLostFocus protected override void OnLostFocus(EventArgs e) { base.OnLostFocus(e); if (SelectedTab != null) SelectedTab.Refresh(); } #endregion #region OnKeyDown protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.Handled == false) { switch (e.KeyData) { case Keys.Tab: Parent.SelectNextControl(this, true, true, true, true); if (SelectedTab != null) SelectedTab.Refresh(); break; case Keys.Tab | Keys.Shift: Parent.SelectNextControl(this, false, true, true, true); if (SelectedTab != null) SelectedTab.Refresh(); break; case Keys.Left: case Keys.Right: case Keys.Up: case Keys.Down: switch (GetKeyDir(e.KeyData)) { case KeyDir.Previous: if (SelectPreviousTab() == true) e.Handled = true; break; case KeyDir.Next: if (SelectNextTab() == true) e.Handled = true; break; } break; case Keys.Home: SuperTabItem ftab = TabStripItem.FirstVisibleTab; if (ftab != null) { TabStripItem.SelectTab(ftab, eEventSource.Keyboard); e.Handled = true; } break; case Keys.End: SuperTabItem ltab = TabStripItem.LastVisibleTab; if (ltab != null) { TabStripItem.SelectTab(ltab, eEventSource.Keyboard); e.Handled = true; } break; } if (e.Handled == true) Focus(); } } #region GetKeyDir private enum KeyDir { None, Previous, Next } private KeyDir GetKeyDir(Keys keys) { switch (keys) { case Keys.Left: if (TabStripItem.HorizontalText == false) { if ((TabStripItem.TabAlignment == eTabStripAlignment.Left && TabStripItem.RotateVerticalText == false) || (TabStripItem.TabAlignment == eTabStripAlignment.Right && TabStripItem.RotateVerticalText == true)) { return (KeyDir.Next); } } return (KeyDir.Previous); case Keys.Right: if (TabStripItem.HorizontalText == false) { if ((TabStripItem.TabAlignment == eTabStripAlignment.Left && TabStripItem.RotateVerticalText == false) || (TabStripItem.TabAlignment == eTabStripAlignment.Right && TabStripItem.RotateVerticalText == true)) { return (KeyDir.Previous); } } return (KeyDir.Next); case Keys.Up: return (KeyDir.Previous); case Keys.Down: return (KeyDir.Next); } return (KeyDir.None); } #endregion #region IsInputKey protected override bool IsInputKey(Keys keyData) { switch (keyData) { case Keys.Right: case Keys.Left: case Keys.Up: case Keys.Down: case Keys.Tab: return true; } return (base.IsInputKey(keyData)); } #endregion #endregion #region Mnemonic Processing protected override bool ProcessItemMnemonicKey(BaseItem item) { if (item != null && item.Visible && item.GetEnabled()) { if (item is SuperTabItem) { SuperTabItem tab = (SuperTabItem)item; SuperTabControl tabControl = Parent as SuperTabControl; if (tabControl != null && !tabControl.ContainsFocus) return false; if (!tab.IsSelected) { _TabStripItem.SelectTab((SuperTabItem)item, eEventSource.Keyboard); return true; } return false; } } return base.ProcessItemMnemonicKey(item); } #endregion #region ISupportInitialize Members /// /// BeginInit /// void ISupportInitialize.BeginInit() { _IsInitializing = true; } /// /// EndInit /// void ISupportInitialize.EndInit() { _IsInitializing = false; } #endregion #region KeyTips public override bool ProcessMnemonicEx(char charCode) { bool processed = base.ProcessMnemonicEx(charCode); if (processed) { if (ShowKeyTips) ShowKeyTips = false; if (ApplicationButton is ApplicationButton) ((ApplicationButton)ApplicationButton).BackstageMnemonicProcessed(charCode); else if (ApplicationButton is Metro.MetroAppButton) ((Metro.MetroAppButton)ApplicationButton).BackstageMnemonicProcessed(charCode); } return processed; } protected override Rectangle GetKeyTipRectangle(Graphics g, BaseItem item, Font font, string keyTip) { if (ApplicationButton != null) { Size padding = KeyTipsPainter.KeyTipsPadding; Size size = TextDrawing.MeasureString(g, keyTip, font); size.Width += padding.Width; size.Height += padding.Height; Rectangle ib = item.DisplayRectangle; Rectangle r; if (item is SuperTabItem) r = new Rectangle(ib.X + 2, ib.Y, size.Width, size.Height); else r = new Rectangle(ib.X + 24, ib.Y - 2, size.Width, size.Height); return r; } return base.GetKeyTipRectangle(g, item, font, keyTip); } #endregion #region Dispose protected override void Dispose(bool disposing) { if (disposing == true && IsDisposed == false) HookEvents(false); base.Dispose(disposing); } #endregion } } #endif