private void HighlightMatch(Regex regex, Trend trend) { var ranges = RichTextBoxMatchFinder.FindMatches(rtbArticleContent.Document, regex); var color = GetColorForTrend(trend); RichTextBoxMatchFinder.HighlightMatches(ranges, color, FontWeights.ExtraBold); }
private void BtnCheck_OnClick(object sender, RoutedEventArgs e) { try { if (Validate() == false) { return; } rtbText.Document = RichTextBoxHelper.CleanAndReformat(rtbText.Document); var regex = tbGeneratedPattern.Text; var ranges = RichTextBoxMatchFinder.FindMatches(rtbText.Document, new Regex(regex, RegexOptions.Singleline | RegexOptions.IgnoreCase)); RichTextBoxMatchFinder.HighlightMatches(ranges, Colors.Red, FontWeights.Bold); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void HighlightMatch(Regex regex, Color color, bool isBold) { var ranges = RichTextBoxMatchFinder.FindMatches(rtbArticleContent.Document, regex); RichTextBoxMatchFinder.HighlightMatches(ranges, color, isBold? FontWeights.Bold : FontWeights.Normal); }