Skip to content

Commit

Permalink
1.2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Mochengvia committed Jun 6, 2024
1 parent ce01b3b commit 6154d0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -11,6 +12,21 @@ public static class TextBlockHelper
{
#region Properties

#region Text
public static string GetText(TextBlock textBlock)
{
return (string)textBlock.GetValue(TextProperty);
}

public static void SetText(TextBlock textBlock, string value)
{
textBlock.SetValue(TextProperty, value);
}

public static readonly DependencyProperty TextProperty =
DependencyProperty.RegisterAttached("Text", typeof(string), typeof(TextBlockHelper), new PropertyMetadata(OnHighlightTextChanged));
#endregion

#region HighlightText
public static string GetHighlightText(TextBlock textBlock)
{
Expand Down Expand Up @@ -97,7 +113,7 @@ private static void OnHighlightTextChanged(DependencyObject d, DependencyPropert
{
return;
}
var text = textBlock.Text;
var text = GetText(textBlock);
var regex = GetHighlightRegex(textBlock);
var highlightText = GetHighlightText(textBlock);
var foreground = GetHighlightForeground(textBlock);
Expand Down Expand Up @@ -143,7 +159,7 @@ private static void OnHighlightTextChanged(DependencyObject d, DependencyPropert
index = match.Index;
matchText = match.Value;

if (string.IsNullOrEmpty(matchText)
if (string.IsNullOrEmpty(matchText)
|| rule == HighlightRule.FirstOnly)
{
textBlock.Inlines.Add(new Run(text));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
ResourceDictionaryLocation.SourceAssembly
)]

[assembly: AssemblyVersion("1.2.1.7")]
[assembly: AssemblyFileVersion("1.2.1.7")]
[assembly: AssemblyVersion("1.2.1.8")]
[assembly: AssemblyFileVersion("1.2.1.8")]

0 comments on commit 6154d0a

Please sign in to comment.