예제 #1
0
        public void AddMatch(FindMatch match)
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(() => { AddMatch(match); }));
                    return;
                }

                var existingLvi = (from l in lstMatches.Items.Cast<ListViewItem>() where (l.Tag as FindMatch).IsSameLine(match) select l).FirstOrDefault();
                if (existingLvi != null)
                {
                    (existingLvi.Tag as FindMatch).Merge(match);
                }
                else
                {
                    var lvi = new ListViewItem(match.FileName);
                    lvi.SubItems.Add(match.LineNumber.ToString());
                    lvi.SubItems.Add(CleanLineText(match.LineText));
                    lvi.Tag = match;

                    lstMatches.Items.Add(lvi);

                    _numMatches++;
                }
            }
            catch (Exception ex)
            {
                Errors.Show(this, ex);
            }
        }
예제 #2
0
 public void Merge(FindMatch match)
 {
     foreach (var span in match._highlightSpans) _highlightSpans.Add(span);
     RecalculateHighlightSpans();
 }
예제 #3
0
 public bool IsSameLine(FindMatch match)
 {
     return string.Equals(_fileName, match._fileName, StringComparison.OrdinalIgnoreCase) && _lineNum == match._lineNum;
 }