protected override async void Invoke(object parameter) { var args = parameter as InteractionRequestedEventArgs; if (args == null) { return; } if (CalibrationService == null) { Log.Error("CalibrateWindowAction was invoked, but the CalibrationService (dependency property) is not set. Calibration is not possible."); return; } Window parentWindow = null; bool parentWindowHadFocus = false; if (AssociatedObject != null) { parentWindow = AssociatedObject as Window ?? VisualAndLogicalTreeHelper.FindVisualParent <Window>(AssociatedObject); if (parentWindow != null) { parentWindowHadFocus = parentWindow.IsFocused; } } var calibrationResult = args.Context as NotificationWithCalibrationResult; try { Log.Info("Starting a calibration"); MainWindowManipulationService.Hide(); var message = await CalibrationService.Calibrate(parentWindow); if (calibrationResult != null) { calibrationResult.Success = true; calibrationResult.Message = message; } } catch (Exception exception) { if (calibrationResult != null) { calibrationResult.Success = false; calibrationResult.Exception = exception; } } finally { MainWindowManipulationService.RestoreSavedState(); } args.Callback(); if (parentWindow != null && parentWindowHadFocus) { Log.Debug("Parent Window was previously focussed - giving it focus again."); parentWindow.Focus(); } }
public void ThenDockShouldBeResizedToFull() { MainWindowManipulationService.Verify(s => s.ResizeDockToFull(), Times.Once()); }
public void ThenWindowShouldBeRestored() { MainWindowManipulationService.Verify(s => s.Restore(), Times.Once()); }
public void ThenDockShouldNotBeResizedToFull() { MainWindowManipulationService.Verify(s => s.ResizeDockToFull(), Times.AtMostOnce(), "Should have been called at most once by InitialiseKeyboard"); }
public void ThenWindowShouldBeMaximised() { MainWindowManipulationService.Verify(s => s.Maximise(), Times.Once()); }
public void ThenDockShouldBeCollapsed() { MainWindowManipulationService.Verify(s => s.ResizeDockToCollapsed(), Times.Once()); }