Beispiel #1
0
    public void ShowQuestion(TestQuestion question)
    {
        ShowTestTitle();
        txtQuestion.Buffer.Text = question.Text;
        // Clean previous answers
        foreach (var child in AnswersHolder.Children)
        {
            child.Destroy();
        }
        // Create new answer items
        answers = new CheckButton[question.Answers.Count];
        // Get user selected items
        var answered = results.Answered(question);

        for (int i = 0; i < question.Answers.Count; ++i)
        {
            answers [i] = new CheckButton();
            var display    = this.Display.GetScreen(0);
            int fntSize    = (int)(answers [i].PangoContext.FontDescription.Size / Pango.Scale.PangoScale);
            int maxSymbols = display.Width / fntSize;
            answers [i].Label = StringWrapper.WordWrap(question.Answers[i].Text, maxSymbols);
            AnswersHolder.Add(answers[i]);
            // Show answers already checked by user
            foreach (var answer in answered)
            {
                if (answer == question.Answers [i])
                {
                    answers [i].Active = true;
                }
            }
        }
        AnswersHolder.ShowAll();
        // Fix focus
        FocusGrabbedByTextQuestion(null, null);
    }