Skip to content

Commit 8b7f313

Browse files
Leaf ShiLeaf Shi
authored andcommitted
Scale the Anchor editor according to DPI
1 parent 6bce8b5 commit 8b7f313

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,44 +69,51 @@ public virtual AnchorStyles GetSelectedAnchor()
6969

7070
internal virtual void InitializeComponent()
7171
{
72-
int XBORDER = SystemInformation.Border3DSize.Width;
73-
int YBORDER = SystemInformation.Border3DSize.Height;
72+
int XBORDER = ScaleHelper.ScaleToInitialSystemDpi(SystemInformation.Border3DSize.Width);
73+
int YBORDER = ScaleHelper.ScaleToInitialSystemDpi(SystemInformation.Border3DSize.Height);
7474
SuspendLayout();
75-
SetBounds(0, 0, 90, 90);
75+
76+
var pixel_10 = ScaleHelper.ScaleToInitialSystemDpi(10);
77+
var pixel_30 = ScaleHelper.ScaleToInitialSystemDpi(30);
78+
var pixel_40 = ScaleHelper.ScaleToInitialSystemDpi(40);
79+
var pixel_60 = ScaleHelper.ScaleToInitialSystemDpi(60);
80+
var pixel_90 = ScaleHelper.ScaleToInitialSystemDpi(90);
81+
82+
SetBounds(0, 0, pixel_90, pixel_90);
7683

7784
AccessibleName = SR.AnchorEditorAccName;
7885

7986
_container.Location = new Point(0, 0);
80-
_container.Size = new Size(90, 90);
87+
_container.Size = new Size(pixel_90, pixel_90);
8188
_container.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
8289

83-
_control.Location = new Point(30, 30);
84-
_control.Size = new Size(30, 30);
90+
_control.Location = new Point(pixel_30, pixel_30);
91+
_control.Size = new Size(pixel_30, pixel_30);
8592
_control.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
8693

87-
_right.Location = new Point(60, 40);
88-
_right.Size = new Size(30 - XBORDER, 10);
94+
_right.Location = new Point(pixel_60, pixel_40);
95+
_right.Size = new Size(pixel_30 - XBORDER, pixel_10);
8996
_right.TabIndex = 2;
9097
_right.TabStop = true;
9198
_right.Anchor = AnchorStyles.Right;
9299
_right.AccessibleName = SR.AnchorEditorRightAccName;
93100

94-
_left.Location = new Point(XBORDER, 40);
95-
_left.Size = new Size(30 - XBORDER, 10);
101+
_left.Location = new Point(XBORDER, pixel_40);
102+
_left.Size = new Size(pixel_30 - XBORDER, pixel_10);
96103
_left.TabIndex = 0;
97104
_left.TabStop = true;
98105
_left.Anchor = AnchorStyles.Left;
99106
_left.AccessibleName = SR.AnchorEditorLeftAccName;
100107

101-
_top.Location = new Point(40, YBORDER);
102-
_top.Size = new Size(10, 30 - YBORDER);
108+
_top.Location = new Point(pixel_40, YBORDER);
109+
_top.Size = new Size(pixel_10, pixel_30 - YBORDER);
103110
_top.TabIndex = 1;
104111
_top.TabStop = true;
105112
_top.Anchor = AnchorStyles.Top;
106113
_top.AccessibleName = SR.AnchorEditorTopAccName;
107114

108-
_bottom.Location = new Point(40, 60);
109-
_bottom.Size = new Size(10, 30 - YBORDER);
115+
_bottom.Location = new Point(pixel_40, pixel_60);
116+
_bottom.Size = new Size(pixel_10, pixel_30 - YBORDER);
110117
_bottom.TabIndex = 3;
111118
_bottom.TabStop = true;
112119
_bottom.Anchor = AnchorStyles.Bottom;

0 commit comments

Comments
 (0)