Пример #1
0
        private static void OnKeywordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightTextBlock htb = d as HighlightTextBlock;

            if (htb != null && string.IsNullOrEmpty(e.NewValue as string)) // 검색 키워드가 지워졌을 경우, 원래 text로 세팅
            {
                htb.Inlines.Clear();
                htb.SetColorOfString(htb.FullText);
                return;
            }

            if (htb.IsEnableMultiHighlight && htb.KeywordList != null && htb.KeywordList.Count > 0)
            {
                htb.SearchMultipleKeywordAndHighlight(htb.KeywordList);
            }
            else
            {
                htb.SearchKeywordAndHighlight((string)e.NewValue);
            }
        }
Пример #2
0
        private static void OnKeywordListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightTextBlock htb = d as HighlightTextBlock;

            if (htb != null)
            {
                if (!htb.IsEnableMultiHighlight)
                {
                    return;
                }

                if ((e.NewValue == null) || (e.NewValue as ObservableCollection <string>).Count == 0) // 검색 키워드가 지워졌을 경우, 원래 text로 세팅
                {
                    htb.Inlines.Clear();
                    htb.SetColorOfString(htb.FullText);
                    return;
                }

                if (e.NewValue != null && e.NewValue is ObservableCollection <string> )
                {
                    htb.SearchMultipleKeywordAndHighlight(e.NewValue as ObservableCollection <string>);
                }
            }
        }
Пример #3
0
        private static void OnFullTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(e.NewValue as string))
            {
                return;
            }

            HighlightTextBlock htb = d as HighlightTextBlock;

            if (htb != null)
            {
                htb.Inlines.Clear();
                htb.SetColorOfString(e.NewValue as string);
            }

            if (htb.IsEnableMultiHighlight && htb.KeywordList != null && htb.KeywordList.Count > 0)
            {
                htb.SearchMultipleKeywordAndHighlight(htb.KeywordList);
            }
            else if (string.IsNullOrEmpty(htb.Keyword) == false)
            {
                htb.SearchKeywordAndHighlight(htb.Keyword);
            }
        }