private void SetWindowState(FormWindowState state, bool setSize) { if (state == FormWindowState.Maximized) { this.IsMaximized = true; if (setSize) { this.previousPosition = this.Bounds; } this.WindowState = FormWindowState.Normal; this.FormBorderStyle = FormBorderStyle.None; this.Location = Point.Empty; this.Size = Screen.FromHandle(this.Handle).Bounds.Size; } else { this.FormBorderStyle = FormBorderStyle.Sizable; this.Bounds = this.previousPosition; this.IsMaximized = false; } }