BBDInstaller/BandagedBD/Controls/FlatCheckBox.cs

30 lines
1.1 KiB
C#
Raw Normal View History

2019-05-25 05:46:28 +02:00
using System.ComponentModel;
using System.Drawing;
2018-10-29 07:15:48 +01:00
using System.Drawing.Text;
using System.Windows.Forms;
namespace BandagedBD.Controls {
class FlatCheckBox : CheckBox {
2019-05-25 05:46:28 +02:00
[Description("Background color for the CheckBox"), Category("Flatpak")]
public Color BoxBackColor { get; set; } = Color.FromArgb(60, 60, 60);
[Description("Foreground color for the CheckBox"), Category("Flatpak")]
public Color BoxForeColor { get; set; } = Properties.Settings.Default.Accent;
2018-10-29 07:15:48 +01:00
public FlatCheckBox() {
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
2019-05-25 05:46:28 +02:00
e.Graphics.FillRectangle(new SolidBrush(BoxBackColor), new Rectangle(0, 0, 13, 14));
2018-10-29 07:15:48 +01:00
if (Checked) {
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
2019-05-25 05:46:28 +02:00
e.Graphics.DrawString("\u2714", this.Font, new SolidBrush(BoxForeColor), -1, 1);
2018-10-29 07:15:48 +01:00
}
}
}
}