Beispiel #1
0
        protected async override 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");
                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;
                }
            }

            args.Callback();

            if (parentWindow != null &&
                parentWindowHadFocus)
            {
                Log.Debug("Parent Window was previously focussed - giving it focus again.");
                parentWindow.Focus();
            }
        }
        private void DoSelectCamera2(object obj)
        {
            CameraModel model = obj as CameraModel;

            if (model != null)
            {
                CalibrationService.StopCapture();
                Cameras1.Add(Calibration.Camera2);
                Cameras1.Remove(model);
                Calibration.Camera2 = model;
                CalibrationService.Initialize(Calibration, ConsoleService);
                CalibrationService.StartCapture();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="configuration">Configuration</param>
 public CalibrationController(IChromelyConfiguration configuration)
 {
     _service = new CalibrationService(configuration);
 }