示例#1
0
        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();
            }
        }
示例#2
0
 public void ThenDockShouldBeResizedToFull()
 {
     MainWindowManipulationService.Verify(s => s.ResizeDockToFull(), Times.Once());
 }
示例#3
0
 public void ThenWindowShouldBeRestored()
 {
     MainWindowManipulationService.Verify(s => s.Restore(), Times.Once());
 }
示例#4
0
 public void ThenDockShouldNotBeResizedToFull()
 {
     MainWindowManipulationService.Verify(s => s.ResizeDockToFull(), Times.AtMostOnce(),
                                          "Should have been called at most once by InitialiseKeyboard");
 }
示例#5
0
 public void ThenWindowShouldBeMaximised()
 {
     MainWindowManipulationService.Verify(s => s.Maximise(), Times.Once());
 }
示例#6
0
 public void ThenDockShouldBeCollapsed()
 {
     MainWindowManipulationService.Verify(s => s.ResizeDockToCollapsed(), Times.Once());
 }