Exemplo n.º 1
0
        private void ChoiceButton_OnClick(Button button, Choice choice)
        {
            if (choice.IsCorrect)
            {
                stopwatch.Start();

                // Add the answer if it was the first one picked.
                if (!isAnswered)
                {
                    points.FillColor = Color.Green;
                    stats.AddAnswer(choice);
                }

                // Disable all other buttons.
                foreach (var b in choicesContainer.GetChildren()
                         .Where(entity => entity is Button btn && btn != button))
                {
                    b.Disabled = true;
                }
            }
            else
            {
                button.Disabled = true;

                // Add the answer if it was the first one picked.
                if (!isAnswered)
                {
                    points.FillColor = Color.Red;
                    stats.AddAnswer(choice);
                }
            }

            isAnswered = true;
        }