protected virtual void OnPaintForeground(PaintEventArgs e)
{
base.ItemHeight = GetPreferredSize(Size.Empty).Height;
Color borderColor, foreColor;
if (isHovered && !isPressed && Enabled)
{
foreColor = MetroPaint.ForeColor.ComboBox.Hover(Theme);
borderColor = MetroPaint.BorderColor.ComboBox.Hover(Theme);
}
else if (isHovered && isPressed && Enabled)
{
foreColor = MetroPaint.ForeColor.ComboBox.Press(Theme);
borderColor = MetroPaint.BorderColor.ComboBox.Press(Theme);
}
else if (!Enabled)
{
foreColor = MetroPaint.ForeColor.ComboBox.Disabled(Theme);
borderColor = MetroPaint.BorderColor.ComboBox.Disabled(Theme);
}
else
{
foreColor = MetroPaint.ForeColor.ComboBox.Normal(Theme);
borderColor = MetroPaint.BorderColor.ComboBox.Normal(Theme);
}
using (Pen p = new Pen(borderColor))
{
Rectangle boxRect = new Rectangle(0, 0, Width - 1, Height - 1);
e.Graphics.DrawRectangle(p, boxRect);
}
using (SolidBrush b = new SolidBrush(foreColor))
{
e.Graphics.FillPolygon(b, new Point[] { new Point(Width - 20, (Height / 2) - 2), new Point(Width - 9, (Height / 2) - 2), new Point(Width - 15, (Height / 2) + 4) });
}
Rectangle textRect = new Rectangle(2, 2, Width - 20, Height - 4);
TextRenderer.DrawText(e.Graphics, Text, MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));
if (displayFocusRectangle && isFocused)
ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
if (drawPrompt)
{
DrawTextPrompt(e.Graphics);
}
}