Пример #1
0
        private void OnSearchTextChanged()
        {
            Items.ForEach(i => i.Highlight = false);
            SearchMatches.Clear();

            if (SearchText == null || SearchText.Length < 3)
            {
                return;
            }

            var matches = Items.Where(IsSearchMatch).ToList();

            matches.ForEach(i => i.Highlight = true);
            SearchMatches.AddRange(matches.Select(i => i.Item.Y + i.Item.Height / 2.0).Distinct());
        }
Пример #2
0
        private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            var txt = tbSearch.Text;

            foreach (var item in _usedVisualizers)
            {
                if (_foundItems.Contains(item.Key))
                {
                    item.Value.ClearValue(BackgroundProperty);
                }
            }

            if (string.IsNullOrWhiteSpace(txt))
            {
                SearchMatches.Clear();
                _foundItems.Clear();
                return;
            }

            if (txt.Length < 3)
            {
                return;
            }

            _foundItems = new HashSet <Item>(Items.Where(i => IsSearchMatch(i, txt)));

            foreach (var item in _usedVisualizers)
            {
                if (_foundItems.Contains(item.Key))
                {
                    item.Value.Background = ItemVisualizer.FoundItemBrush;
                }
            }

            SearchMatches = new ObservableCollection <int>(_foundItems.Select(i => i.Y).Distinct());
        }