* UIForm2: 修改最大化时按钮位置

This commit is contained in:
Sunny 2024-07-20 16:26:18 +08:00
parent 0f062f387d
commit bac0f32fd2

View File

@ -339,7 +339,6 @@ namespace Sunny.UI
private void ShowMaxOrNormal() private void ShowMaxOrNormal()
{ {
Added = 16;
if (!ShowFullScreen) if (!ShowFullScreen)
{ {
if (WindowState == FormWindowState.Maximized) if (WindowState == FormWindowState.Maximized)
@ -393,7 +392,8 @@ namespace Sunny.UI
} }
else else
{ {
if (FormBorderStyle == FormBorderStyle.Sizable) ShowMaxOrNormal(); if (FormBorderStyle == FormBorderStyle.Sizable)
ShowMaxOrNormal();
} }
} }
@ -408,23 +408,13 @@ namespace Sunny.UI
Invalidate(); Invalidate();
} }
private int Added = 0;
protected override void CalcSystemBoxPos() protected override void CalcSystemBoxPos()
{ {
ControlBoxLeft = Width; ControlBoxLeft = Width;
if (ControlBox) if (ControlBox)
{ {
if (WindowState == FormWindowState.Maximized) ControlBoxRect = new Rectangle(Width - 6 - 28, titleHeight / 2 - 14, 28, 28);
{
ControlBoxRect = new Rectangle(Width - 6 - 28 - Added, titleHeight / 2 - 14, 28, 28);
}
else
{
ControlBoxRect = new Rectangle(Width - 6 - 28, titleHeight / 2 - 14, 28, 28);
}
ControlBoxLeft = ControlBoxRect.Left - 2; ControlBoxLeft = ControlBoxRect.Left - 2;
if (MaximizeBox) if (MaximizeBox)
@ -618,6 +608,8 @@ namespace Sunny.UI
{ {
winState = FormWindowState.Maximized; winState = FormWindowState.Maximized;
boundsCoreState = true; boundsCoreState = true;
CalcSystemBoxPos();
Invalidate();
} }
else if ((int)m.WParam == Win32.User.SIZE_RESTORED) else if ((int)m.WParam == Win32.User.SIZE_RESTORED)
{ {