mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-31 14:25:16 +00:00
Improved the DPI awareness (display scaling) in the TreeViewAdv control.
This commit is contained in:
1
External/Aga.Controls/Tree/TreeViewAdv.Designer.cs
generated
vendored
1
External/Aga.Controls/Tree/TreeViewAdv.Designer.cs
generated
vendored
@@ -15,6 +15,7 @@ namespace Aga.Controls.Tree
|
||||
if (_dragTimer != null) _dragTimer.Dispose();
|
||||
if (_linePen != null) _linePen.Dispose();
|
||||
if (_markPen != null) _markPen.Dispose();
|
||||
if (_lightGrayPen != null) _lightGrayPen.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
20
External/Aga.Controls/Tree/TreeViewAdv.Draw.cs
vendored
20
External/Aga.Controls/Tree/TreeViewAdv.Draw.cs
vendored
@@ -41,7 +41,8 @@ namespace Aga.Controls.Tree
|
||||
{
|
||||
CreateLinePen();
|
||||
CreateMarkPen();
|
||||
}
|
||||
CreateLightGrayPen();
|
||||
}
|
||||
|
||||
private void CreateMarkPen()
|
||||
{
|
||||
@@ -59,7 +60,14 @@ namespace Aga.Controls.Tree
|
||||
{
|
||||
_linePen = new Pen(_lineColor);
|
||||
_linePen.DashStyle = DashStyle.Dot;
|
||||
}
|
||||
_linePen.Width = GetScaledSize(1, false);
|
||||
}
|
||||
|
||||
private void CreateLightGrayPen()
|
||||
{
|
||||
_lightGrayPen = new Pen(Color.FromArgb(247, 247, 247));
|
||||
_lightGrayPen.Width = GetScaledSize(1, false);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
@@ -136,7 +144,7 @@ namespace Aga.Controls.Tree
|
||||
OnRowDraw(e, node, context, row, rowRect);
|
||||
|
||||
if ((GridLineStyle & GridLineStyle.Horizontal) == GridLineStyle.Horizontal) {
|
||||
e.Graphics.DrawLine(LightGrayPen, 0, rowRect.Bottom, e.Graphics.ClipBounds.Right, rowRect.Bottom);
|
||||
e.Graphics.DrawLine(_lightGrayPen, 0, rowRect.Bottom, e.Graphics.ClipBounds.Right, rowRect.Bottom);
|
||||
}
|
||||
|
||||
if (FullRowSelect)
|
||||
@@ -164,8 +172,7 @@ namespace Aga.Controls.Tree
|
||||
DrawNode(node, context);
|
||||
}
|
||||
|
||||
private Brush GrayBrush = new SolidBrush(Color.FromArgb(240, 240, 240));
|
||||
private Pen LightGrayPen = new Pen(Color.FromArgb(247, 247, 247));
|
||||
private Brush GrayBrush = new SolidBrush(Color.FromArgb(240, 240, 240));
|
||||
|
||||
private void DrawVerticalGridLines(Graphics gr, int y)
|
||||
{
|
||||
@@ -260,7 +267,8 @@ namespace Aga.Controls.Tree
|
||||
{
|
||||
int level = curNode.Level;
|
||||
int scaledIndent = node.Tree.GetScaledSize(_indent, false);
|
||||
int x = (level - 1) * scaledIndent + NodePlusMinus.ImageSize / 2 + LeftMargin;
|
||||
int x = (level - 1) * scaledIndent +
|
||||
node.Tree.GetScaledSize(NodePlusMinus.ImageSize, false) / 2 + LeftMargin;
|
||||
int width = node.Tree.GetScaledSize(NodePlusMinus.Width - NodePlusMinus.ImageSize / 2, false);
|
||||
int y = rowRect.Y;
|
||||
int y2 = y + rowRect.Height;
|
||||
|
3
External/Aga.Controls/Tree/TreeViewAdv.cs
vendored
3
External/Aga.Controls/Tree/TreeViewAdv.cs
vendored
@@ -30,6 +30,7 @@ namespace Aga.Controls.Tree
|
||||
private const int DividerCorrectionGap = -2;
|
||||
|
||||
private Pen _linePen;
|
||||
private Pen _lightGrayPen;
|
||||
private Pen _markPen;
|
||||
private bool _suspendUpdate;
|
||||
private bool _needFullUpdate;
|
||||
@@ -256,7 +257,7 @@ namespace Aga.Controls.Tree
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx
|
||||
const int _default_dpi = 96;
|
||||
Graphics g = this.CreateGraphics();
|
||||
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user