I customized the checkbox to be rendered as a toggle button which doesn't render properly if I use two monitors with different resolutions, otherwise it renders properly. How can I lock it to be displayed as same in any monitor
This is how the custom checkbox looks like,
protected override void OnPaint(PaintEventArgs e)
{
this.OnPaintBackground(e);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
using (var path = new GraphicsPath())
{
var d = Padding.All;
var r = this.Height - 2 * d;
path.AddArc(d, d, r, r, 90, 180);
path.AddArc(this.Width - r - d, d, r, r, -90, 180);
path.CloseFigure();
e.Graphics.FillPath(Checked ? Brushes.DarkGray : Brushes.LightGray, path);
r = Height - 1;
var rect = Checked ? new Rectangle(Width - r - 1, 0, r, r)
: new Rectangle(0, 0, r, r);
SolidBrush brush = new SolidBrush(Color.FromArgb(0, 122, 204));
e.Graphics.FillEllipse(Checked ? brush : (TeamsForm.CurrentBackGroundTheme.Name == DarkBackGround) ? Brushes.WhiteSmoke : Brushes.LightGray, rect);
}
Aucun commentaire:
Enregistrer un commentaire