public static void Restore(this WindowState state, Form form, bool firstTimeFullscreen) { if (state.Bounds != Rectangle.Empty) { form.DesktopBounds = state.Bounds; form.WindowState = state.IsMaximized ? FormWindowState.Maximized : FormWindowState.Normal; } if ((state.Bounds == Rectangle.Empty && firstTimeFullscreen) || form.IsFullyOutsideView()) { form.DesktopBounds = Screen.PrimaryScreen.WorkingArea; form.WindowState = FormWindowState.Maximized; state.Save(form); } }