Пример #1
0
        /// <summary>
        ///     Handle the incoming key, send from ExerciseView.
        ///     Checks if InputKey == ExpectedKey
        /// </summary>
        public void Handle_Key(object sender, KeyEventArgs e)
        {
            if (CheckDone())
            {
                databaseController.AddMistakesToDb(WrongChars);
                return;
            }
            KeyData.KeystrokeCounter++;
            if (!exerciseStarted)
            {
                dispatcherTimer.Start();
                exerciseStarted = true;
            }
            var inputKey = KeyEventConverter(e);

            if (inputKey == GetExpectedChar().ToString())
            {
                KeyData.GoodKeyPresses++;
                SetNextExpectedKey(exerciseView.ExerciseTextBoxParagraph);
                KeyboardController.HandleKey_Down(e, Brushes.Gray);
                KeyboardController.HighlightCorrectButton(GetExpectedChar(), Brushes.Gold);
            }
            else
            {
                KeyboardController.HandleKey_Down(e, SettingsView.ReturnBrushColorFromInt(Settings.Default.FalseColor));
                KeyboardController.HighlightCorrectButton(GetExpectedChar(), Brushes.Green);
                WrongChars.Add(GetExpectedChar().ToString().ToLower());
            }
            CalculateAccuracy();
        }