leocb / MaterialSkin

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

How to resize materialswitch #380

Open RecSpeed opened 1 year ago

RecSpeed commented 1 year ago

Need small materialswitch

valimaties commented 1 year ago

I don't think it will be done. If you want to use this project, you have to fork it and modify controls on your needs.

As an idea, in the controls folder, look for MaterialSwitch class and look for the below constants, modify them and see what you got:

private const int THUMB_SIZE = 22;

private const int THUMB_SIZE_HALF = THUMB_SIZE / 2;

private const int TRACK_SIZE_HEIGHT = (int)(14);
private const int TRACK_SIZE_WIDTH = (int)(36);
private const int TRACK_RADIUS = (int)(TRACK_SIZE_HEIGHT / 2);
....
private const int RIPPLE_DIAMETER = 37;

If I were you, I would redefine those constants as fields, I would create an enumerable, let's say SwitchSize having "small, medium, large" values. Then create a public property to be able to resize the switch control, this property must be visible in design time ([Browsable(true)]), as when you change the size it will automatically change in your form too (change those int fields and call invalidate() in the setter).

Good luck.