private void AddServices(IEnumerable <IControlService> services) { services?.Where(s => Icons.Any(i => i.Service == s) == false) .ToList() .Where(s => _resolver.CanCreate(s)) .Select(s => (ControlServiceViewModel)_resolver.Create(s)) .ForEach(Icons.Add); }
private ITimelineStepViewModel ResolveStepActionViewModel(SessionStepActionSettings action) { ITimelineStepViewModel stepViewModel = null; if (_resolver.CanCreate(action)) { stepViewModel = (ITimelineStepViewModel)_resolver.Create(action); } return(stepViewModel); }
private async Task TryStartCalibrationAsync(ICalibrate calibrate) { if (CanCalibrate == false) { using (var cancellation = new CancellationDisposable()) { _cancellation = cancellation; await AsyncHelper.InvokeAsync <EventHandler <bool>, bool> ( () => { }, h => calibrate.CanCalibrateChanged += h, h => calibrate.CanCalibrateChanged -= h, tcs => (_, canCalibrate) => { if (canCalibrate) { tcs.TrySetResult(canCalibrate); } }, cancellation.Token ); OnPropertyChanged(nameof(CanCalibrate)); _cancellation = null; } } if (CanCalibrate) { var calibrator = calibrate.GetCalibrator(); var calibratorViewModel = (CalibratorViewModel)_resolver.Create(calibrator); ApplySettings(calibratorViewModel); Navigation.NavigateToObject(calibratorViewModel); await CalibrateAsync(calibrator); } else { Complete(); } }
public EyeTrackerCalibrationTimelineStepViewModel(EyeTrackerCalibrationActionSettings settings, IAdaptersManager adapters, ViewModelResolver resolver) : base(settings) { _settings = settings; _resolver = resolver; var eyeTracker = adapters.FirstOrDefault(a => a.Code.DeviceType == DeviceType.Physiological.EYETRACKER); if (eyeTracker != null) { _calibrate = eyeTracker?.Calibration; var adapter = (AdapterViewModel)resolver.Create(eyeTracker); ConnectCommand = new WrappedCommand(adapter.ExecuteActionCommand, DeviceAction.Connect); } Cursor = Cursors.Arrow; }
public ExecutedTimelineStepViewModel(ExecutedActionSettingsBase settings, ISessionStepActionExecutor executor, ViewModelResolver resolver) { executor.ThrowIfNull(nameof(executor)); executor.ThrowIf(e => e.CanExecute(settings) == false, nameof(executor), $"Given executor '{executor.GetType().Name}' can not execute settings of type '{settings?.GetType().Name ?? String.Empty}'."); _executor = executor; _executor.Completed += (_, args) => Dispatcher.CurrentDispatcher.Invoke(() => Completed?.Invoke(this, args)); _settings = settings; _resolver = resolver; if (settings.Content != null && resolver.CanCreate(settings.Content)) { Content = (ITimelineStepViewModel)resolver.Create(settings.Content); isContent = true; } }
public QuestionaryTimelineStepViewModel(QuestionaryActionSettings settings, ViewModelResolver resolver) : base(settings) { _id = settings.Id; var questions = settings.Questions? .Where(q => resolver.CanCreate(q)) .Select(q => { string question = q.Question.Lines != null && q.Question.Lines.Any() ? String.Join(Environment.NewLine, q.Question.Lines) : String.Empty; return(new QuestionViewModel(question, q.Id, (IQuestionAnswerViewModel)resolver.Create(q), q.IsRequired, q.HelpText)); }); Title = settings.Title?.Trim() ?? String.Empty; Questionary = new QuestionaryViewModel(questions); HasQuestions = Questionary.Questions.Any(); Cursor = Cursors.Arrow; }