Пример #1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Rectangle r;
            Rectangle rx;
            Brush     b           = new SolidBrush(Color.Black);
            Brush     buttonBrush = new SolidBrush(closeButtonColor);
            Color     disTabColor1;
            Color     disTabColor2;
            Pen       p = new Pen(closeButtonXColor, 2);
            string    titel;
            Font      f = this.Font;

            for (int i = 0; i < TabCount; i++)
            {
                disTabColor1 = disTabDefColor1;
                disTabColor2 = disTabDefColor2;
                ClosableTabPage tb = TabPages[i] as ClosableTabPage;
                if (tb != null)
                {
                    if (tb.Highlighted)
                    {
                        disTabColor1 = disTabHlColor1;
                        disTabColor2 = disTabHlColor2;
                    }
                }
                r = GetTabRect(i);

                if (i == this.SelectedIndex)
                {
                    e.Graphics.FillRectangle(activTabBrush, r);
                }
                else
                {
                    disTabBrush = new LinearGradientBrush(r, disTabColor1, disTabColor2, LinearGradientMode.Vertical);
                    e.Graphics.FillRectangle(disTabBrush, r);
                    GraphicsPath bPath = new GraphicsPath();
                    int          c     = 5;
                    bPath.AddLine(r.X, r.Y + r.Height - 2, r.X, r.Y + c);
                    bPath.AddArc(r.X, r.Y, c, c, 180, 90);
                    bPath.AddLine(r.X + c, r.Y, r.X + r.Width - c, r.Y);
                    bPath.AddArc(r.X + r.Width - c, r.Y, c, c, 270, 90);
                    bPath.AddLine(r.X + r.Width, r.Y + c, r.X + r.Width, r.Y + r.Height - 2);
                    e.Graphics.DrawPath(disTabBorderPen, bPath);
                }

                r.Offset(2, 2);
                r.Width  = closeButtonW;
                r.Height = closeButtonH;
                rx       = new Rectangle(r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
                titel    = this.TabPages[i].Text;

                e.Graphics.FillRectangle(buttonBrush, r);
                e.Graphics.DrawLine(p, rx.X, rx.Y, rx.X + rx.Width, rx.Y + rx.Height);
                e.Graphics.DrawLine(p, rx.X + rx.Width, rx.Y, rx.X, rx.Y + rx.Height);

                e.Graphics.DrawString(titel, f, b, new PointF(r.X + r.Width, r.Y));
            }
        }
Пример #2
0
        public void HighlightTab(int index)
        {
            ClosableTabPage tb = TabPages[index] as ClosableTabPage;

            if (tb != null)
            {
                tb.Highlighted = true;
            }
        }