Пример #1
0
        void BtnAnswerClick(object sender, EventArgs args)
        {
            if (Revision)
            {
                return;
            }

            BtnAnswers.ForEach(x => x.IsEnabled = true);
            ((View)sender).IsEnabled            = false;
            CurrentQ.TestAnswer = Grid.GetColumn((View)sender) + Grid.GetRow((View)sender);
        }
Пример #2
0
        void BtnAnswerClick(object sender, EventArgs args)
        {
            if (Revision)
            {
                return;
            }

            BtnAnswers.ForEach(x => x.IsEnabled = true);
            ((Button)sender).IsEnabled          = false;
            CurrentQ.TestAnswer = BtnAnswers.IndexOf((Button)sender);
        }
Пример #3
0
        void LoadQuestion()
        {
            promptValue.Text = (Questions.IndexOf(CurrentQ) + 1) + ". " + CurrentQ.Prompt;

            #region Adding Answer Controls

            GridAnswers.Children.Clear();
            BtnAnswers.Clear();

            for (int i = 0; i < CurrentQ.Answers.Count; i++)
            {
                View control;
                if (CurrentQ.Answers[i].StartsWith("@"))
                {
                    #region Image
                    control = new Image()
                    {
                        Source = CurrentQ.Answers[i].Substring(1)
                    };
                    ((Image)control).GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() =>
                        {
                            BtnAnswerClick(control, EventArgs.Empty);
                        })
                    });
                    #endregion
                }
                else
                {
                    #region Button
                    control = new Button()
                    {
                        Text = CurrentQ.Answers[i], BackgroundColor = Color.Default
                    };
                    ((Button)control).Clicked += BtnAnswerClick;
                    #endregion
                }

                const int columns = 2;
                Grid.SetRow(control, i / columns);
                Grid.SetColumn(control, i % columns);

                if (!Revision)
                {
                    if (CurrentQ.TestAnswer == -1)
                    {
                        control.IsEnabled = true;
                    }
                    else
                    {
                        control.IsEnabled = !(i == CurrentQ.TestAnswer);
                    }
                }
                else
                {
                    if (CurrentQ.TestAnswer == i)
                    {
                        control.BackgroundColor = Color.Red;
                    }
                    if (CurrentQ.CorrectAnswer == i)
                    {
                        control.BackgroundColor = Color.Green;
                    }
                }

                BtnAnswers.Add(control);
                GridAnswers.Children.Add(control);
            }
            #endregion

            #region Back and Next Visibility
            if (CurrentQuestionNumber == 0)
            {
                btnBack.IsVisible = false;
            }
            else if (CurrentQuestionNumber == Questions.Count - 1)
            {
                btnNext.IsVisible = false;
            }
            else
            {
                btnBack.IsVisible = btnNext.IsVisible = true;
            }
            #endregion
        }