From 0e804d0bba924f49fab181fdea775a7ce04d97d9 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Mon, 31 Dec 2018 09:23:26 -0600 Subject: [PATCH] ngradiobutton now scales correctly for hidpi --- mRemoteV1/UI/Controls/Base/NGRadioButton.cs | 27 +++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mRemoteV1/UI/Controls/Base/NGRadioButton.cs b/mRemoteV1/UI/Controls/Base/NGRadioButton.cs index 6b480f5e..e4a7949c 100644 --- a/mRemoteV1/UI/Controls/Base/NGRadioButton.cs +++ b/mRemoteV1/UI/Controls/Base/NGRadioButton.cs @@ -10,14 +10,18 @@ namespace mRemoteNG.UI.Controls.Base class NGRadioButton : RadioButton { private ThemeManager _themeManager; - private Rectangle circle; - private Rectangle circle_small; + private readonly Rectangle _circle; + private readonly Rectangle _circleSmall; + private readonly int _textXCoord; + // Constructor public NGRadioButton() { - // Init - circle_small = new Rectangle(4, 4, 6, 6 ); - circle = new Rectangle(1, 1, 12, 12 ); + var display = new DisplayProperties(); + + _circleSmall = new Rectangle(display.ScaleWidth(4), display.ScaleHeight(4), display.ScaleWidth(6), display.ScaleHeight(6)); + _circle = new Rectangle(display.ScaleWidth(1), display.ScaleHeight(1), display.ScaleWidth(12), display.ScaleHeight(12)); + _textXCoord = display.ScaleWidth(16); ThemeManager.getInstance().ThemeChanged += OnCreateControl; } @@ -88,8 +92,7 @@ namespace mRemoteNG.UI.Controls.Base e.Graphics.Clear(Parent.BackColor); if (Enabled) { - - if(Checked) + if (Checked) { center = _themeManager.ActiveTheme.ExtendedPalette.getColor("CheckBox_Glyph"); } @@ -109,14 +112,12 @@ namespace mRemoteNG.UI.Controls.Base fore = _themeManager.ActiveTheme.ExtendedPalette.getColor("CheckBox_Text_Disabled"); } - var textRect = new Rectangle(16, Padding.Top, Width - 16, Height); + var textRect = new Rectangle(_textXCoord, Padding.Top, Width - 16, Height); TextRenderer.DrawText(e.Graphics, Text, Font, textRect, fore, Parent.BackColor, TextFormatFlags.PathEllipsis); - g.FillEllipse(new SolidBrush(centerBack), circle); - g.FillEllipse(new SolidBrush(center), circle_small); - g.DrawEllipse(new Pen(outline), circle); - + g.FillEllipse(new SolidBrush(centerBack), _circle); + g.FillEllipse(new SolidBrush(center), _circleSmall); + g.DrawEllipse(new Pen(outline), _circle); } - } }