Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            base.OnPaint(e);

            try
            {
                SelectedTab.BackColor = mainBackground;
            }
            catch
            {
            }

            G.Clear(topBackground);
            G.SmoothingMode = SmoothingMode.HighQuality;

            switch (ColorScheme)
            {
            case ColorSchemes.DarkGray:
                activeTabColor = Color.FromArgb(10, 10, 10);
                _textColor     = Color.White;
                break;

            case ColorSchemes.Green:
                activeTabColor = Color.FromArgb(94, 165, 1);
                _textColor     = Color.White;
                break;

            case ColorSchemes.Blue:
                activeTabColor = Color.FromArgb(0, 97, 166);
                _textColor     = Color.White;
                break;

            case ColorSchemes.White:
                activeTabColor = Color.FromArgb(245, 245, 245);
                _textColor     = Color.FromArgb(36, 36, 36);
                break;

            case ColorSchemes.Red:
                activeTabColor = Color.FromArgb(170, 0, 0);
                _textColor     = Color.White;
                break;
            }

            for (int i = 0; i <= TabPages.Count - 1; i++)
            {
                Rectangle TabRect = new Rectangle(GetTabRect(i).X + 3, GetTabRect(i).Y, GetTabRect(i).Width - 5, GetTabRect(i).Height);
                G.FillRectangle(new SolidBrush(mainBackground), TabRect);
                G.DrawString(TabPages[i].Text, new Font("Tahoma", 9, FontStyle.Bold), new SolidBrush(ForeColor), TabRect, new StringFormat
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment     = StringAlignment.Center
                });
            }

            G.FillRectangle(new SolidBrush(mainBackground), 0, ItemSize.Height, Width, Height);

            if (!(SelectedIndex == -1))
            {
                Rectangle TabRect = new Rectangle(GetTabRect(SelectedIndex).X + 3, GetTabRect(SelectedIndex).Y, GetTabRect(SelectedIndex).Width - 5, GetTabRect(SelectedIndex).Height);
                G.FillPath(new SolidBrush(activeTabColor), Draw.RoundRect(TabRect, 4));
                G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(20, 20, 20))), Draw.RoundRect(TabRect, 4));
                G.DrawString(TabPages[SelectedIndex].Text, new Font("Tahoma", 9, FontStyle.Bold), new SolidBrush(_textColor), TabRect, new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }

            e.Graphics.DrawImage(B, new Point(0, 0));
            G.Dispose();
            B.Dispose();
        }