IgnaceMaes / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
2.84k stars 831 forks source link

Checkbox checked fill colour #100

Closed MikeGWem closed 7 years ago

MikeGWem commented 8 years ago

When a checkbox is checked the current fill colour is the accent colour. Material Design Lite (for one) uses the primary colour and it would be nice to have a choice. The following approach works OK although others might have alternate views on implementation.

Start with an Enum: public enum FillColour { Primary, DarkPrimary, LightPrimary, Accent } Add an attribute to the checkbox: private FillColour checkedFillColour = FillColour.Accent; [Description("Fill colour for checked box"), Category("Behavior")] public FillColour CheckedFillColour { get { return checkedFillColour; } set { checkedFillColour = value; if (Checked) { Invalidate(); } } } And then an addition to the short GetColor*\ functions in the skin manager class maybe: public Color GetCheckBoxCheckedFillColor(FillColour checkedFillColour) { switch (checkedFillColour) { case FillColour.Accent: return colourScheme.AccentColor; case FillColour.DarkPrimary: return colourScheme.DarkPrimaryColor; case FillColour.LightPrimary: return colourScheme.LightPrimaryColor; default: return colourScheme.PrimaryColor; } } and finally a tweak to the relevant line in the checkbox Paint: var brush = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? GetCheckBoxCheckedFillColor(checkedFillColour) : GetCheckBoxOffDisabledColor()));

IgnaceMaes commented 7 years ago

This would be a great contribution. Feel free to open a pull request.

Considering this isn't exactly an issue I'm closing this.

SoundwaveGT commented 7 years ago

How do i change the checkbox color or theme?? please reply