private void tmrCheckCompletion_Tick(object sender, EventArgs e) { if (Options.TimeGoal != null) { _status = _startTime.Add(Options.TimeGoal.Value).Subtract(DateTime.Now).TotalMinutes.ToString("N0") + " minutes left"; if (DateTime.Now > _startTime.Add(Options.TimeGoal.Value)) { tmrCheckCompletion.Stop(); GoalFinished(); } } if (Options.WordGoal != null) { var wordCount = CompletionUtils.GetWordCount(textBox.Text, Options.ExcludeGibberish); _status = $"{Options.WordGoal - wordCount} words left"; if (wordCount >= Options.WordGoal) { tmrCheckCompletion.Stop(); GoalFinished(); } } }
public void Initialize(ExtendedRichTextBox textBox, Func <string> getStatus) { _textBox = textBox; _getStatus = getStatus; _textBox.TextChanged += (sender, e) => { lblWordCount.Text = $"Words: {CompletionUtils.GetWordCount(_textBox.Text, false)}"; }; }