protected override void OnPaint(PaintEventArgs e) { Bitmap B = new Bitmap(Width, Height); dynamic G = Graphics.FromImage(B); dynamic GP = default(GraphicsPath); GraphicsPath GP1 = new GraphicsPath(); Rectangle Base = new Rectangle(0, 0, Width - 1, Height - 1); var _with2 = G; _with2.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; _with2.SmoothingMode = SmoothingMode.HighQuality; _with2.PixelOffsetMode = PixelOffsetMode.HighQuality; _with2.Clear(BackColor); switch (State) { case MouseState.None: GP = DrawHelpers.RoundRec(Base, 2); _with2.FillPath(new SolidBrush(_MainColour), GP); _with2.DrawString(Text, Font, new SolidBrush(_TextColour), Base, new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); break; case MouseState.Over: GP = DrawHelpers.RoundRec(Base, 2); _with2.FillPath(new SolidBrush(_HoverColour), GP); _with2.DrawString(Text, Font, new SolidBrush(_TextColour), Base, new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); break; case MouseState.Down: GP = DrawHelpers.RoundRec(Base, 2); _with2.FillPath(new SolidBrush(_HoverColour), GP); _with2.DrawString(Text, Font, new SolidBrush(_TextColour), Base, new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); GP1 = DrawHelpers.RoundRec(new Rectangle(0, 0, Width, Height), 3); _with2.DrawPath(new Pen(new SolidBrush(Color.LightYellow), 2), GP1); break; } base.OnPaint(e); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImageUnscaled(B, 0, 0); B.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { Bitmap B = new Bitmap(Width, Height); dynamic G = Graphics.FromImage(B); dynamic GP = default(GraphicsPath); GraphicsPath GP1 = new GraphicsPath(); var _with8 = G; _with8.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; _with8.SmoothingMode = SmoothingMode.HighQuality; _with8.PixelOffsetMode = PixelOffsetMode.HighQuality; _with8.Clear(BackColor); if (_ShowArrow) { Rectangle Base = new Rectangle(7, 0, Width - 7, Height - 1); Rectangle BorderBase = new Rectangle(8, 0, Width - 8, Height); GP = DrawHelpers.RoundRec(Base, 2); GP1 = DrawHelpers.RoundRec(BorderBase, 4); _with8.FillPath(new SolidBrush(_BaseColour), GP); _with8.DrawPath(new Pen(new SolidBrush(_BorderColour)), GP1); _with8.DrawString(Text, Font, new SolidBrush(_TextColour), new Rectangle(15, 4, Width - 17, Height - 5)); if (_ArrowFixed) { Point[] p = { new Point(9, 11), new Point(0, 17), new Point(9, 22) }; _with8.FillPolygon(new SolidBrush(_BaseColour), p); _with8.DrawPolygon(new Pen(new SolidBrush(_BaseColour)), p); _with8.DrawLine(new Pen(new SolidBrush(_BorderColour)), new Point(8, 11), new Point(0, 17)); _with8.DrawLine(new Pen(new SolidBrush(_BorderColour)), new Point(0, 17), new Point(8, 22)); } else { Point[] p = { new Point(9, Height - 19), new Point(0, Height - 25), new Point(9, Height - 30) }; _with8.FillPolygon(new SolidBrush(_BaseColour), p); _with8.DrawPolygon(new Pen(new SolidBrush(_BaseColour)), p); _with8.DrawLine(new Pen(new SolidBrush(_BorderColour)), new Point(8, Height - 19), new Point(0, Height - 25)); _with8.DrawLine(new Pen(new SolidBrush(_BorderColour)), new Point(0, Height - 25), new Point(8, Height - 30)); } } else { Rectangle Base = new Rectangle(0, 0, Width - 1, Height - 1); Rectangle BorderBase = new Rectangle(0, 0, Width, Height); GP = DrawHelpers.RoundRec(Base, 2); GP1 = DrawHelpers.RoundRec(BorderBase, 4); _with8.FillPath(new SolidBrush(_BaseColour), GP); _with8.DrawPath(new Pen(new SolidBrush(_BorderColour)), GP1); _with8.DrawString(Text, Font, new SolidBrush(_TextColour), new Rectangle(6, 4, Width - 17, Height - 5)); } base.OnPaint(e); G.Dispose(); e.Graphics.InterpolationMode = (InterpolationMode)7; e.Graphics.DrawImageUnscaled(B, 0, 0); B.Dispose(); }