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); } }
public void Merge(FindMatch match) { foreach (var span in match._highlightSpans) _highlightSpans.Add(span); RecalculateHighlightSpans(); }
public bool IsSameLine(FindMatch match) { return string.Equals(_fileName, match._fileName, StringComparison.OrdinalIgnoreCase) && _lineNum == match._lineNum; }