Today working on an application I saw something that can be usefull to your library.
If we select the DARK THEME and using a BRIGHT COLOR (like BRIGHT YELLOW), the comboboxes show an ugly and unreadable text: white on yellow, in my specific case...
So, I did a little change into COMBOBOX.CS, trying to make it adapt itself to these situations:
protected override void OnDrawItem(DrawItemEventArgs e)
{
if (e.Index >= 0)
{
Color foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
Color backColor = BackColor;
if (!useCustomBackColor)
{
backColor = MetroPaint.BackColor.Form(Theme);
}
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
using (SolidBrush b = new SolidBrush(MetroPaint.GetStyleColor(Style)))
{
e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
}
foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
// -------------------------------------------
Color FontForeColor = MetroPaint.GetStyleColor(Style);
if (FontForeColor.GetBrightness() >= 0.5)
{
if (FontForeColor == MetroColors.DarkBlue)
{
FontForeColor = Color.FromArgb(255, 215, 215, 215);
}
else
{
FontForeColor = Color.FromArgb(255, 0, 0, 0);
}
}
else
{
FontForeColor = Color.FromArgb(255, 255, 255, 255);
}
foreColor = FontForeColor;
}
// -------------------------------------------
else
{
using (SolidBrush b = new SolidBrush(backColor))
{
e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
}
}
if (this.DropDownStyle != ComboBoxStyle.DropDown)
{
Rectangle textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]), MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
}
else
{
Rectangle textRect = new Rectangle(0, e.Bounds.Top, this.textBox.Width, e.Bounds.Height);
TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]), MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
}
}
else
{
base.OnDrawItem(e);
}
}
This way I can get the combo's self-adapting to any user color scheme.
I guess it can be usefull to other.
Hi Denis,
Today working on an application I saw something that can be usefull to your library.
If we select the DARK THEME and using a BRIGHT COLOR (like BRIGHT YELLOW), the comboboxes show an ugly and unreadable text: white on yellow, in my specific case...
So, I did a little change into COMBOBOX.CS, trying to make it adapt itself to these situations:
This way I can get the combo's self-adapting to any user color scheme. I guess it can be usefull to other.
Best regards.