forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormState.cs
More file actions
49 lines (44 loc) · 1.31 KB
/
Copy pathFormState.cs
File metadata and controls
49 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Drawing;
using System.Windows.Forms;
using PluginCore;
// From: http://www.vesic.org/english/blog/winforms/full-screen-maximize/
namespace FlashDevelop.Controls
{
/// <summary>
/// Class used to preserve and restore state of the form
/// </summary>
public class FormState
{
Rectangle windowBounds;
FormWindowState winState;
FormBorderStyle borderStyle;
/// <summary>
/// Maximizes the form to fullscreen
/// </summary>
public void Maximize(Form form)
{
Save(form);
form.WindowState = FormWindowState.Maximized;
form.FormBorderStyle = FormBorderStyle.None;
if (Win32.ShouldUseWin32()) Win32.SetWinFullScreen(form.Handle);
}
/// <summary>
/// Saves the state before maximizing
/// </summary>
public void Save(Form form)
{
winState = form.WindowState;
borderStyle = form.FormBorderStyle;
windowBounds = form.Bounds;
}
/// <summary>
/// Restores the form to old state
/// </summary>
public void Restore(Form form)
{
form.WindowState = winState;
form.FormBorderStyle = borderStyle;
form.Bounds = windowBounds;
}
}
}