protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if ((!Hovered) || !Enabled) { currentBackColor = MathHelper.ColorLerp(currentBackColor, NormalColor, 5); g.FillRectangle(new SolidBrush(currentBackColor), 0, 0, Width, Height); g.DrawRectangle(new Pen(NormalBorderColor), 0, 0, Width, Height); } else { currentBackColor = MathHelper.ColorLerp(currentBackColor, HoverColor, 5); g.FillRectangle(new SolidBrush(currentBackColor), 0, 0, Width, Height); g.DrawRectangle(new Pen(HoverBorderColor), 0, 0, Width, Height); } SolidBrush textBrush = new SolidBrush(ForeColor); if (!Enabled) { textBrush.Color = ForeColor + Color.FromArgb(0, 128, 128, 128); } if (Image != null && Image.uTexture != null) { var imageToPaint = Image; var imageColorToPaint = ImageColor; if (Hovered) { if (ImageHover != null) { imageToPaint = ImageHover; } if (ImageHoverColor != null) { imageColorToPaint = ImageHoverColor.Value; } } switch (BackgroundImageLayout) { default: case ImageLayout.None: g.DrawTexture(imageToPaint, 0, 0, Image.Width, Image.Height, imageColorToPaint); break; case ImageLayout.Center: g.DrawTexture(imageToPaint, Width / 2 - Image.Width / 2, Height / 2 - Image.Height / 2, Image.Width, Image.Height, imageColorToPaint); break; case ImageLayout.Stretch: g.DrawTexture(imageToPaint, 0, 0, Width, Height, imageColorToPaint); break; case ImageLayout.Zoom: // TODO: not working. break; } } g.DrawString(Text, Font, textBrush, Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom, TextAlign); }