Scale TreeViewAdv elements based on DPI

TreeViewAdv assumed a standard 96 DPI display. This commit fixes some
problems on high DPI displays, including some problems mentioned in
OHM issue 830.

- column header height
- checkboxes
- icons
- indentation
This commit is contained in:
David Wilhelm
2017-08-17 01:25:29 -07:00
parent 140b1680db
commit ff37c9f69d
5 changed files with 73 additions and 10 deletions
+6 -2
View File
@@ -46,7 +46,9 @@ namespace Aga.Controls.Tree.NodeControls
public override Size MeasureSize(TreeNodeAdv node, DrawContext context)
{
return new Size(ImageSize, ImageSize);
int scaledX = node.Tree.GetScaledSize(ImageSize, false);
int scaledY = node.Tree.GetScaledSize(ImageSize);
return new Size(scaledX, scaledY);
}
public override void Draw(TreeNodeAdv node, DrawContext context)
@@ -56,13 +58,15 @@ namespace Aga.Controls.Tree.NodeControls
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer renderer;
int scaledX = node.Tree.GetScaledSize(ImageSize, false);
int scaledY = node.Tree.GetScaledSize(ImageSize);
if (state == CheckState.Indeterminate)
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
else if (state == CheckState.Checked)
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
else
renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, ImageSize, ImageSize));
renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, scaledX, scaledY));
}
else
{