Example #1
0
        public void AutocorrectNewWordNodes()
        {
            foreach (InkWordNode inkWordNode in uncheckedNewWordNodes)
            {
                string recognizedString = inkWordNode.GetRecognizedString();
                bool   correct          = !Regex.IsMatch(recognizedString, @"^[a-zA-Z]+$") ||
                                          spellchecker.Spell(recognizedString);

                if (!correct)
                {
                    List <string> suggestions             = spellchecker.Suggest(inkWordNode.GetRecognizedString());
                    List <string> alphabeticalSuggestions = new List <string>();

                    foreach (string suggestion in suggestions)
                    {
                        if (Regex.IsMatch(suggestion, @"^[a-zA-Z]+$"))
                        {
                            alphabeticalSuggestions.Add(suggestion);
                        }
                    }

                    if (alphabeticalSuggestions.Count > 0)
                    {
                        suggestionsBox.SetSuggestions(inkWordNode, alphabeticalSuggestions, fontData);
                        suggestionsBox.Visibility         = Visibility.Visible;
                        strokesAddedSinceSuggestionsShown = 0;

                        // For now, only autocorrect one word at once.
                        break;
                    }
                }
            }

            uncheckedNewWordNodes.Clear();
        }