45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace MaterialSkin.Controls
|
|
{
|
|
public partial class MaterialComboBox : ComboBox
|
|
{
|
|
|
|
[Browsable(false)]
|
|
public MaterialSkinManager SkinManager => MaterialSkinManager.Instance;
|
|
public MaterialComboBox()
|
|
{
|
|
|
|
DrawMode = DrawMode.OwnerDrawFixed;
|
|
|
|
DrawItem += AdvancedComboBox_DrawItem;
|
|
|
|
}
|
|
|
|
void AdvancedComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
|
{
|
|
if (e.Index < 0)
|
|
return;
|
|
|
|
ComboBox combo = sender as ComboBox;
|
|
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
|
|
e.Graphics.FillRectangle(new SolidBrush(SkinManager.ColorScheme.AccentColor),
|
|
e.Bounds);
|
|
else
|
|
e.Graphics.FillRectangle(new SolidBrush(combo.BackColor),
|
|
e.Bounds);
|
|
|
|
e.Graphics.DrawString(combo.Items[e.Index].ToString(), e.Font,
|
|
SkinManager.GetRaisedButtonTextBrush((e.State & DrawItemState.Selected) == DrawItemState.Selected),
|
|
new Point(e.Bounds.X, e.Bounds.Y));
|
|
|
|
e.DrawFocusRectangle();
|
|
}
|
|
|
|
|
|
}
|
|
}
|