public void ShowOverlay() { _logger.LogMessage("Main window: show overlay clicked."); if (_overlayController != null) { _overlayController.Activate(); return; } _overlayController = _controllerFactory.CreateController <OverlayController>(); var overlayPosition = ViewModel.AppData.Configuration.OverlayPosition; _overlayController.Top = overlayPosition.Y == 0 ? View.Top + View.Height + 10 : overlayPosition.Y; if (overlayPosition.X != 0) { _overlayController.Left = overlayPosition.X; } _overlayController.Closed += () => { _overlayController = null; ViewModel.OverlayDisplayed = false; }; _overlayController.View.LocationChanged += (s, e) => { ViewModel.AppData.Configuration.OverlayPosition = new Point(_overlayController.Left, _overlayController.Top); }; _overlayController.Show(); ViewModel.OverlayDisplayed = true; }