mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-18 21:52:34 +08:00
a25ebdfd4d
一般是在 if 控制范围很大的情况下进行调整,如果控制范围小则不调整。 从第三方代码的 Demo 中复制的代码块不修改。
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace PDFPatcher.Functions
|
|
{
|
|
/// <summary>
|
|
/// Class used to preserve / restore / maximize state of the form
|
|
/// </summary>
|
|
public sealed class FormState
|
|
{
|
|
FormBorderStyle brdStyle;
|
|
bool topMost;
|
|
Rectangle bounds;
|
|
|
|
bool IsMaximized;
|
|
|
|
public void Maximize(Form targetForm) {
|
|
if (IsMaximized) {
|
|
return;
|
|
}
|
|
|
|
IsMaximized = true;
|
|
if (targetForm.WindowState == FormWindowState.Maximized) {
|
|
targetForm.WindowState = FormWindowState.Normal;
|
|
}
|
|
Save(targetForm);
|
|
targetForm.FormBorderStyle = FormBorderStyle.None;
|
|
targetForm.TopMost = true;
|
|
targetForm.Bounds = Screen.FromControl(targetForm).Bounds;
|
|
}
|
|
|
|
void Save(Form targetForm) {
|
|
brdStyle = targetForm.FormBorderStyle;
|
|
topMost = targetForm.TopMost;
|
|
bounds = targetForm.Bounds;
|
|
}
|
|
|
|
public void Restore(Form targetForm) {
|
|
targetForm.FormBorderStyle = brdStyle;
|
|
targetForm.TopMost = topMost;
|
|
targetForm.Bounds = bounds;
|
|
IsMaximized = false;
|
|
}
|
|
}
|
|
}
|