Esempio n. 1
0
        public CreateTestViewModel(IDataService dataService)
        {
            #region variables initialization

            _dataService = dataService;
            _dataService.GetData((item, error) => { if (error != null)
                                                    {
                                                        return;
                                                    }
                                 });

            ClearWindow();

            #endregion

            AddNewQuestionCommand = new GalaSoft.MvvmLight.Command.RelayCommand(
                () => CreateAndSaveQuestion());

            EditQuestionCommand = new GalaSoft.MvvmLight.Command.RelayCommand(
                () => EditAndSaveQuestion());

            DeleteQuestionCommand = new GalaSoft.MvvmLight.Command.RelayCommand(
                () => DeleteQuestion());

            Messenger.Default.Register <List <string> >(this, "question",
                                                        s => { QuestionString.Clear(); foreach (var item in s)
                                                               {
                                                                   QuestionString.Add(item);
                                                               }
                                                        });

            Messenger.Default.Register <string>(this, "result", s => Result = s);
        }
Esempio n. 2
0
        public void Visit(QuestionString question)
        {
            if (question.Condition?.Evaluate() == false)
            {
                return;
            }
            Panel.Controls.Add(new Label
            {
                Text     = question.Label,
                AutoSize = true
            });
            var textBox = new TextBox
            {
                Text     = question.Value,
                ReadOnly = question.Computed
            };

            if (!question.Computed)
            {
                textBox.TextChanged += (sender, e) =>
                {
                    question.Value = ((TextBox)sender).Text;
                    UpdateControls();
                };
            }
            Panel.Controls.Add(textBox);
        }
Esempio n. 3
0
        private void PrepareQuestionString()
        {
            /* * 0 - content, 1 .. 5 - answer, 6 - points, 7 - id*/

            QuestionString.Clear();
            QuestionString.Add(_questions[_selectedIndex].Content);

            for (int i = 0; i < 5; i++)
            {
                if (_questions[_selectedIndex].Answer.Count > i)
                {
                    QuestionString.Add(UnParseAnswer(_questions[_selectedIndex].Answer[i]));
                }
                else
                {
                    QuestionString.Add("");
                }
            }

            QuestionString.Add(_questions[_selectedIndex].Points.ToString());
            QuestionString.Add("");
        }
Esempio n. 4
0
 public void Start()
 {
     m_QuestionString = new QuestionString("ФИО", "Введите ФИО", 2, 20);
 }