protected void PaintDefaultContent(FluidPaintEventArgs e) { Rectangle rect = ButtonRectangle; Color endColor = this.BackColor; Graphics g = e.Graphics; rect.Offset(e.ControlBounds.X, e.ControlBounds.Y); Color textColor = ForeColor; if (IsDown) { textColor = pressedForeColor.IsEmpty ? ColorConverter.AlphaBlendColor(endColor, textColor, 200) : pressedForeColor; } if (!Enabled) { textColor = ColorConverter.AlphaBlendColor(endColor, textColor, 32); } Brush foreBrush = Brushes.GetBrush(textColor); StringFormat sf = this.stringFormat; Rectangle r = rect; r.Inflate(e.ScaleX(-3), e.ScaleY(2)); RectangleF rf = new RectangleF(r.Left, r.Top, r.Width, r.Height); if (IsDown) { rf.X++; rf.Y++; } rf.X += (float)ScaleX(TextOffset.X); rf.Y += (float)ScaleY(TextOffset.Y); g.DrawString(Text, Font, foreBrush, rf, sf); if (Image != null) { int imW = ScaleX(Image.Width); int imH = ScaleY(Image.Height); int w = Math.Min(imW, rect.Width); int h = Math.Min(imH, rect.Height); rect.Y += (rect.Height - h) / 2; rect.X += (rect.Width - h) / 2; rect.Width = w; rect.Height = h; ImageAttributes ia = new ImageAttributes(); ia.SetColorKey(Color.Fuchsia, Color.Fuchsia); if (rect.Width > w) { rect.X += (rect.Width - w) / 2; rect.Width = w; } if (rect.Height > h) { rect.X += (rect.Height - h) / 2; rect.Height = h; } if (IsDown) { rect.X++; rect.Y++; } g.DrawImage(Image, rect, 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, ia); // g.DrawImage(Image, rect, new Rectangle(0, 0, imW, imH), GraphicsUnit.Pixel); } }