ngradiobutton now scales correctly for hidpi

This commit is contained in:
David Sparer
2018-12-31 09:23:26 -06:00
parent e6e4ecacaf
commit 0e804d0bba

View File

@@ -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);
}
}
}