protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1); Rectangle BarRect = new Rectangle(0, 0, Width - 1, 32); base.OnPaint(e); G.Clear(BackColor); G.SmoothingMode = SmoothingMode.HighQuality; switch (_Shade) { case InnerShade.Light: LinearGradientBrush mainGradient = new LinearGradientBrush(ClientRectangle, Color.FromArgb(228, 230, 232), Color.FromArgb(199, 201, 205), 90); G.FillRectangle(mainGradient, ClientRectangle); G.DrawRectangle(Pens.Black, ClientRectangle); break; case InnerShade.Dark: G.FillRectangle(InnerTexture, ClientRectangle); G.DrawRectangle(Pens.Black, ClientRectangle); break; } LinearGradientBrush TopOverlay = new LinearGradientBrush(ClientRectangle, Color.FromArgb(5, Color.White), Color.FromArgb(10, Color.White), 90); G.FillRectangle(TopTexture, BarRect); ColorBlend blend = new ColorBlend(); //Add the Array of Color Color[] bColors = new Color[] { Color.FromArgb(20, Color.White), Color.FromArgb(10, Color.Black), Color.FromArgb(10, Color.White) }; blend.Colors = bColors; //Add the Array Single (0-1) colorpoints to place each Color float[] bPts = new float[] { 0, 0.9f, 1 }; blend.Positions = bPts; using (LinearGradientBrush br = new LinearGradientBrush(BarRect, Color.White, Color.Black, LinearGradientMode.Vertical)) { //Blend the colors into the Brush br.InterpolationColors = blend; //Fill the rect with the blend G.FillRectangle(br, BarRect); } G.DrawRectangle(Pens.Black, BarRect); //// Top Bar Highlights G.DrawLine(Draw.GetPen(Color.FromArgb(112, 109, 107)), 1, 1, Width - 2, 1); G.DrawLine(Draw.GetPen(Color.FromArgb(67, 63, 60)), 1, BarRect.Height - 1, Width - 2, BarRect.Height - 1); switch (_Shade) { case InnerShade.Light: Color[] c = { Color.FromArgb(153, 153, 153), Color.FromArgb(173, 174, 177), Color.FromArgb(200, 201, 204) }; Draw.InnerGlow(G, new Rectangle(1, 33, Width - 2, Height - 34), c); break; case InnerShade.Dark: Color[] c1 = { Color.FromArgb(43, 40, 38), Color.FromArgb(50, 47, 44), Color.FromArgb(55, 52, 49) }; Draw.InnerGlow(G, new Rectangle(1, 33, Width - 2, Height - 34), c1); break; } Font drawFont = new Font("Arial", 9, FontStyle.Bold); G.DrawString(Text, drawFont, Brushes.White, new Rectangle(15, 3, Width - 1, 26), new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }); e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0); G.Dispose(); B.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); G = Graphics.FromImage(B); W = Width - 1; H = Height - 1; Rectangle Base = new Rectangle(0, 0, W, H); var _with1 = G; _with1.SmoothingMode = SmoothingMode.HighQuality; _with1.Clear(BackColor); TB.BackColor = _BaseColor; TB.ForeColor = _TextColor; switch (_Style) { case RoundingStyle.Normal: _with1.FillPath(new SolidBrush(_BaseColor), Draw.CreateRound(Base, 5)); LinearGradientBrush tg = new LinearGradientBrush(Base, Color.FromArgb(186, 188, 191), Color.FromArgb(204, 205, 209), 90); _with1.DrawPath(new Pen(tg), Draw.CreateRound(Base, 5)); break; case RoundingStyle.Rounded: _with1.DrawPath(new Pen(new SolidBrush(Color.FromArgb(132, 130, 128))), Draw.CreateRound(new Rectangle(Base.X, Base.Y + 1, Base.Width, Base.Height - 1), 20)); _with1.FillPath(new SolidBrush(_BaseColor), Draw.CreateRound(new Rectangle(Base.X, Base.Y, Base.Width, Base.Height - 1), 20)); LinearGradientBrush tg1 = new LinearGradientBrush(new Rectangle(Base.X, Base.Y, Base.Width, Base.Height - 1), Color.Black, Color.FromArgb(31, 28, 24), 90); _with1.DrawPath(new Pen(tg1), Draw.CreateRound(new Rectangle(Base.X, Base.Y, Base.Width, Base.Height - 1), 20)); break; } base.OnPaint(e); G.Dispose(); e.Graphics.InterpolationMode = (InterpolationMode)7; e.Graphics.DrawImageUnscaled(B, 0, 0); B.Dispose(); }