Пример #1
0
        public void Run()
        {
            actionHandler.PrepareWindow(content);
            var stopWatch = Stopwatch.StartNew();

            while (currentRowIndex < content.Length)
            {
                currentKeyIsValid = false;
                lastTypedSymbol   = inputProvider.GetKey();
                if (lastTypedSymbol == content[currentRowIndex][currentLineIndex])
                {
                    currentKeyIsValid = true;
                    validSymbolsTyped++;
                    currentLineIndex++;

                    if (content[currentRowIndex].Length <= currentLineIndex)
                    {
                        currentRowIndex++;
                        currentLineIndex = 0;
                    }
                }
                else
                {
                    currentErrorCount++;
                }

                var isFinished = currentRowIndex == content.Length;
                OnChanged?.Invoke(GetTypingState(isFinished, stopWatch.Elapsed.TotalSeconds));
            }

            stopWatch.Stop();
        }