protected virtual void OnSelectedIndexChanging(SelectedIndexChangingEventArgs e)
 {
     if (SelectedIndexChanging != null)
         SelectedIndexChanging(this, e);
 }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (this.Controls.Count > 0)
                {
                    int result = -1;
                    Rectangle smartButtonRectangle;
                    CommonObjects.ButtonState smartButtonState;
                    GetSmartButtonHitTest(e.Location, out smartButtonRectangle,
                        out smartButtonState, out result);
                    switch (result)
                    {
                        /*** Is on the SmartCloseButton. ***/
                        case 0:
                            NeoTabPage stp = this.SelectedTab;
                            if (stp.IsCloseable)
                                Remove(stp);
                            break;
                        /*** Is on the SmartDropDownButton. ***/
                        case 1:
                            ContextMenuStrip dropDownMenu = new ContextMenuStrip();
                            Point menuLocation = PointToScreen(new Point(smartButtonRectangle.Left, smartButtonRectangle.Bottom));
                            using (DropDownButtonClickedEventArgs ea = 
                                new DropDownButtonClickedEventArgs(dropDownMenu, menuLocation))
                            {
                                // Fire a Notification Event.
                                OnDropDownButtonClicked(ea);
                            }
                            break;
                        /*** Is not found! ***/
                        default:
                            if (this.Controls.Count > 1)
                            {
                                int itemIndex = -1;
                                Rectangle itemRectangle;
                                CommonObjects.ButtonState itemState;
                                NeoTabPage tabItem = GetHitTest(e.Location,
                                    out itemRectangle, out itemState, out itemIndex);
                                if (tabItem != null && tabItem.IsSelectable)
                                {
                                    bool isAvailable = true;
                                    switch (renderer.NeoTabPageItemsSide)
                                    {
                                        case TabPageLayout.Top:
                                        case TabPageLayout.Bottom:
                                            if (itemRectangle.Right >= 
                                                (smartButtonRectangle.IsEmpty ? DisplayRectangle.Right : smartButtonRectangle.Left))
                                                isAvailable = false;
                                            break;
                                        default:
                                            if (itemRectangle.Bottom >= 
                                                (smartButtonRectangle.IsEmpty ? DisplayRectangle.Bottom : smartButtonRectangle.Top))
                                                isAvailable = false;
                                            break;
                                    }
                                    if (isAvailable)
                                    {
                                        if (selectedIndex != itemIndex)
                                        {
                                            using (SelectedIndexChangingEventArgs ea =
                                                new SelectedIndexChangingEventArgs(tabItem, itemIndex))
                                            {
                                                // Fire a Notification Event.
                                                OnSelectedIndexChanging(ea);

                                                if (!ea.Cancel)
                                                    this.SelectedIndex = ea.TabPageIndex;
                                            }
                                        }
                                        else
                                        {
                                            if (!DesignMode && AllowDrop)
                                            {
                                                // Starts a drag & drop operation for currently selected tab page.
                                                BeginDragDrop(tabItem, itemRectangle,
                                                    CommonObjects.ButtonState.Pressed, itemIndex);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                    }
                }
            }
        }
        protected override bool ProcessMnemonic(char charCode)
        {
            for (int i = 0; i < this.Controls.Count; i++)
            {
                NeoTabPage tp = TabPages[i] as NeoTabPage;
                if (IsMnemonic(charCode, tp.Text))
                {
                    if (tp.IsSelectable && selectedIndex != i)
                    {
                        using (SelectedIndexChangingEventArgs e =
                            new SelectedIndexChangingEventArgs(tp, i))
                        {
                            // Fire a Notification Event.
                            OnSelectedIndexChanging(e);

                            if (!e.Cancel)
                                this.SelectedIndex = e.TabPageIndex;
                        }
                    }
                    break;
                }
            }

            return base.ProcessMnemonic(charCode);
        }
        /// <summary>
        /// Selects a tab page with a specified index of the tab.
        /// </summary>
        /// <param name="tabPageIndex">Index of the tab to select</param>
        private void OnNavigateTabPage(int tabPageIndex)
        {
            if (tabPageIndex == selectedIndex || this.Controls.Count <= 1)
                return;
            if (tabPageIndex > this.Controls.Count - 1)
                tabPageIndex = 0;
            else if (tabPageIndex < 0)
                tabPageIndex = this.Controls.Count - 1;
            try
            {
                NeoTabPage selectingTabPage = TabPages[tabPageIndex] as NeoTabPage;
                if (selectingTabPage == null || !selectingTabPage.IsSelectable)
                    return;
                using (SelectedIndexChangingEventArgs e =
                    new SelectedIndexChangingEventArgs(selectingTabPage, tabPageIndex))
                {
                    // Fire a Notification Event.
                    OnSelectedIndexChanging(e);

                    if (!e.Cancel)
                        this.SelectedIndex = e.TabPageIndex;
                }
            }
            catch (ArgumentOutOfRangeException)
            { ;}
        }