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
51 lines (44 loc) · 1.37 KB
/
Copy pathFormState.cs
File metadata and controls
51 lines (44 loc) · 1.37 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
50
51
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
{
private Rectangle windowBounds;
private FormWindowState winState;
private FormBorderStyle borderStyle;
/// <summary>
/// Maximizes the form to fullscreen
/// </summary>
public void Maximize(Form form)
{
this.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)
{
this.winState = form.WindowState;
this.borderStyle = form.FormBorderStyle;
this.windowBounds = form.Bounds;
}
/// <summary>
/// Restores the form to old state
/// </summary>
public void Restore(Form form)
{
form.WindowState = this.winState;
form.FormBorderStyle = this.borderStyle;
form.Bounds = this.windowBounds;
}
}
}