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;
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        private ITimelineStepViewModel ResolveStepActionViewModel(SessionStepActionSettings action)
        {
            ITimelineStepViewModel stepViewModel = null;

            if (_resolver.CanCreate(action))
            {
                stepViewModel = (ITimelineStepViewModel)_resolver.Create(action);
            }

            return(stepViewModel);
        }
Exemplo n.º 4
0
        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;
            }
        }