private void btnProcess_Click(object sender, RoutedEventArgs e) { var analyzedWords = new List <DAL.Entities.AnalizedWord>(); var highlighted = new Dictionary <int, int>(); txtSecondary.Text = string.Empty; TextRange textRange = new TextRange(mainSearchInput.Document.ContentStart, mainSearchInput.Document.ContentEnd); var txtRichText = textRange.Text; var listSentences = txtRichText.Split(new Char[] { '.', '!', '?', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var sentence in listSentences) { var listWords = sentence.Split(new Char[] { ' ', ',', '"' }, StringSplitOptions.RemoveEmptyEntries).ToList(); analyzedWords.AddRange(Existence.GetConvertedWordsByText(listWords)); } var unidentifiedWords = analyzedWords.Where(word => word.Exists == false).ToList(); foreach (var word in unidentifiedWords) { var indexes = txtRichText.AllIndexesOf(word.Name); foreach (var index in indexes) { if (!highlighted.Contains(index)) { highlighted.Add(index.Key, index.Value); } } } var txtRichSelection = mainSearchInput.Selection; txtRichSelection.ClearAllProperties(); txtSecondary.Text = string.Join("\n", highlighted); }