Exemplo n.º 1
0
        void OnAnswerButtonClicked(object sender, EventArgs args)
        {
            string answer;
            bool   correct;

            if (session.CurrentGame == null)
            {
                return;
            }

            correct = session.ScoreGame(answer_entry.Text);
            if (correct)
            {
                answer = Translations.GetString("Congratulations.");
            }
            else
            {
                answer = Translations.GetString("Incorrect answer.");
            }

            session.EnableTimer = false;
            answer_entry.Text   = String.Empty;
            UpdateStatusBar();
            UpdateSolution(answer + " " + session.CurrentGame.AnswerText,
                           correct == true ? GameDrawingArea.SolutionType.CorrectAnswer :
                           GameDrawingArea.SolutionType.InvalidAnswer);

            session.CurrentGame.Answer.Draw = true;
            ActiveInputControls(true);
            next_button.GrabFocus();
            drawing_area.QueueDraw();

            if (Preferences.Get <bool> (Preferences.SoundsKey))
            {
                Unix.PlaySound(app_window.Handle, System.IO.Path.Combine(Defines.DATA_DIR, correct ? "right.oga" : "wrong.oga"));
            }
        }