Example #1
0
 private void OnSearch(SearchResultEvent e)
 {
     if (!_textView.HasAggregateFocus || _textView.IsClosed)
     {
         return;
     }
     _searchEvents = e.IsHighlightDisabled ? null : e.SearchEvents;
     this.InvokeTagsChanged(TagsChanged, _buffer);
 }
Example #2
0
        private void OnSearch(SearchResultEvent e)
        {
            if (!_textView.HasAggregateFocus || _textView.IsClosed)
            {
                return;
            }
            double lineHeight = (_textView as IWpfTextView)?.LineHeight ?? 0;

            foreach (SearchEvent eSearchEvent in e.SearchEvents)
            {
                TagSpan <IntraTextAdornmentTag> tagger = new TagSpan <IntraTextAdornmentTag>(
                    span: new SnapshotSpan(_buffer.CurrentSnapshot, new Span(eSearchEvent.StartPosition, 0)),
                    tag: new IntraTextAdornmentTag(new LetterWithMarker(eSearchEvent.Letters, lineHeight), null,
                                                   PositionAffinity.Predecessor));
                bool taggerExist = _taggers.ContainsKey(eSearchEvent.StartPosition);

                if (eSearchEvent.StartPosition == 0 &&
                    taggerExist)
                {
                    _taggers[eSearchEvent.StartPosition] = tagger;
                    continue;
                }

                if (taggerExist)
                {
                    continue;
                }

                _taggers.Add(eSearchEvent.StartPosition, tagger);
            }

            IEnumerable <int> keysToRemove =
                _taggers.Keys
                .Where(p => p != 0 &&
                       !e.SearchEvents.Exists(x => x.StartPosition == p))
                .ToList();

            foreach (int i in keysToRemove)
            {
                _taggers.Remove(i);
            }

            this.InvokeTagsChanged(TagsChanged, _buffer);
        }
Example #3
0
        public void UpdateSearchResults(object sender, SearchResultEvent e)
        {
            SearchResults.Clear();

            if (e.Results.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("The search you asked for returned no results. That's a shame...", "No Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                foreach (User user in e.Results)
                {
                    if (!Participants.Contains(user))
                    {
                        SearchResults.Add(user);
                    }
                }
            }
        }