protected sealed override void GoToNormalMode() { if (OptionAttachedToolsVerboseMode) { Logging.Debug("Switching to normal modeā¦"); } _switchingInProgress = true; try { if (AppearanceManager.Instance.PreferFullscreenMode) { var screen = DpiAwareWindow.GetPreferredDeviceScreen(); Form.Width = screen.Bounds.Width; Form.Height = screen.Bounds.Height; Form.Top = screen.Bounds.Top; Form.Left = screen.Bounds.Left; FullscreenEnabled = true; } else { var size = ValuesStorage.Get(KeyNormalSize, default(Point)); var pos = ValuesStorage.Get(KeyNormalPos, default(Point)); if (size.X > 0 && size.Y > 0) { var savedScreen = pos != default(Point) ? Screen.FromPoint(new System.Drawing.Point( (int)(pos.X + size.X / 2), (int)(pos.Y + size.Y / 2))) : DpiAwareWindow.GetPreferredDeviceScreen(); var activeScreen = DpiAwareWindow.GetForcedDeviceScreen(); if (activeScreen != null && savedScreen.Bounds != activeScreen.Bounds) { SetDefaultLocation(); } else { Form.Width = size.X.RoundToInt().Clamp(320, savedScreen.Bounds.Width); Form.Height = size.Y.RoundToInt().Clamp(200, savedScreen.Bounds.Height); Form.Top = pos.Y.RoundToInt().Clamp(savedScreen.Bounds.Top, savedScreen.Bounds.Bottom - Form.Height); Form.Left = pos.X.RoundToInt().Clamp(savedScreen.Bounds.Left, savedScreen.Bounds.Right - Form.Width); } } else { SetDefaultLocation(); } if (_lastVisibleTools.HasValue) { _helper.Visible = _lastVisibleTools.Value; } FullscreenEnabled = ValuesStorage.Get(KeyNormalFullscreen, false); } void SetDefaultLocation() { var screen = DpiAwareWindow.GetPreferredDeviceScreen(); Form.Width = 1600.Clamp(320, screen.Bounds.Width); Form.Height = 900.Clamp(200, screen.Bounds.Height); Form.Top = screen.Bounds.Top + (screen.Bounds.Height - Form.Height) / 2; Form.Left = screen.Bounds.Left + (screen.Bounds.Width - Form.Width) / 2; } UpdateSize(); } finally { _switchingInProgress = false; } if (OptionAttachedToolsVerboseMode) { Logging.Here(); } }
private Rectangle GetScreenBounds() { return((Form.Visible ? Screen.FromControl(Form) : DpiAwareWindow.GetPreferredDeviceScreen()).Bounds); }