/// <summary>
        /// Overridden. Inherited from <see cref="Control"/>.
        /// </summary>
        /// <param name="mea">
        /// See <see cref="Control.OnMouseDown(MouseEventArgs)"/>.
        /// </param>
        protected override void OnMouseDown(MouseEventArgs mea)
        {
            base.OnMouseDown(mea);

            Point p;

            //see if user clicked on close button
            p = mea.Location;
            for (int i = 0; i <= yaLastVisibleTabIndex; i++)
            {
                var tag = this.Controls[i].Tag;
                if (tag != null && tag.ToString() == "NEW_TAB")
                {
                    continue;
                }

                var tabRectangle = GetTabRect(i);
                var clickRectangle = GetRectangleClose(tabRectangle, 2);    //slightly larger target area for the mouse (x image padding)

                if (clickRectangle.Contains(p))
                {
                    var etc = new TabClosingEventArgs();
                    OnTabClosing(etc);
                    if (!etc.Cancel)
                    {
                        Controls.RemoveAt(i);
                        InU();
                        this.SelectedIndex = i - 1;
                        OnTabChanged(new EventArgs());
                        return;
                    }
                }
            }

            //done checking for close event
            p = new Point(mea.X - 2 * yaMargin, mea.Y);
            switch (yaTabDock)
            {
                case DockStyle.Bottom:
                    p.Y -= yaClientRectangle.Height;
                    break;
                case DockStyle.Left:
                    p.Y = mea.X;
                    p.X = Height - mea.Y;
                    break;
                case DockStyle.Right:
                    p.Y = Width - mea.X;
                    p.X = mea.Y;
                    break;
            }
            if (p.Y > yaMargin && p.Y < Convert.ToInt32(yaTabSpan + 3.0f * yaMargin))
            {
                if ((yaShowScrollButtons == YaScrollButtonStyle.Always || (yaShowScrollButtons == YaScrollButtonStyle.Auto && yaTotalTabSpan > calcWidth)) && p.X >= rightArrow[0].X - 3 * yaMargin)
                {
                    if (canScrollRight)
                    {
                        yaKeepScrolling = true;
                        ScrollerThread st = new ScrollerThread(2, this);
                        Thread t = new Thread(new ThreadStart(st.ScrollIt));
                        t.Start();
                    }
                }
                else if ((yaShowScrollButtons == YaScrollButtonStyle.Always || (yaShowScrollButtons == YaScrollButtonStyle.Auto && yaTotalTabSpan > calcWidth)) && p.X >= leftArrow[2].X - 3 * yaMargin)
                {
                    if (canScrollLeft)
                    {
                        yaKeepScrolling = true;
                        ScrollerThread st = new ScrollerThread(-2, this);
                        Thread t = new Thread(new ThreadStart(st.ScrollIt));
                        t.Start();
                    }
                }
                else
                {
                    int t = -Convert.ToInt32(yaTabLeftDif);
                    for (int i = 0; i <= yaLastVisibleTabIndex; i++)
                    {
                        if (p.X >= t && p.X < t + Convert.ToInt32(yaTabLengths[i]))
                        {
                            SelectedIndex = i;
                            break;
                        }
                        t += Convert.ToInt32(yaTabLengths[i]);
                    }
                }
            }
        }
 /// <summary>
 /// Overridden. Inherited from <see cref="Control"/>.
 /// </summary>
 /// <param name="mea">
 /// See <see cref="Control.OnMouseDown(MouseEventArgs)"/>.
 /// </param>
 protected override void OnMouseDown(MouseEventArgs mea)
 {
     base.OnMouseDown(mea);
     Point p = new Point(mea.X - 2 * userTabMargin, mea.Y);
     switch (userTabDock)
     {
         case DockStyle.Bottom:
             p.Y -= clientRectangle.Height;
             break;
         case DockStyle.Left:
             p.Y = mea.X;
             p.X = Height - mea.Y;
             break;
         case DockStyle.Right:
             p.Y = Width - mea.X;
             p.X = mea.Y;
             break;
     }
     if (p.Y > userTabMargin && p.Y < Convert.ToInt32(tabSpan + 3.0f * userTabMargin))
     {
         if ((showScrollButton == UserTabScrollButtonStyle.Always || (showScrollButton == UserTabScrollButtonStyle.Auto && totalTabSpan > calcWidth)) && p.X >= rightArrow[0].X - 3 * userTabMargin)
         {
             if (canScrollRight)
             {
                 keepScrolling = true;
                 ScrollerThread st = new ScrollerThread(2, this);
                 Thread t = new Thread(new ThreadStart(st.ScrollIt));
                 t.Start();
             }
         }
         else if ((showScrollButton == UserTabScrollButtonStyle.Always || (showScrollButton == UserTabScrollButtonStyle.Auto && totalTabSpan > calcWidth)) && p.X >= leftArrow[2].X - 3 * userTabMargin)
         {
             if (canScrollLeft)
             {
                 keepScrolling = true;
                 ScrollerThread st = new ScrollerThread(-2, this);
                 Thread t = new Thread(new ThreadStart(st.ScrollIt));
                 t.Start();
             }
         }
         else
         {
             int t = -Convert.ToInt32(tabLeftDif);
             for (int i = 0; i <= lastVisibleTabIndex; i++)
             {
                 if (p.X >= t && p.X < t + Convert.ToInt32(tabLengths[i]))
                 {
                     SelectedIndex = i;
                     break;
                 }
                 t += Convert.ToInt32(tabLengths[i]);
             }
         }
     }
 }