private void btnHighlightAll_Click(object sender, EventArgs e) { if (!_highlightGroups.ContainsKey(_editor)) _highlightGroups[_editor] = new HighlightGroup(_editor); HighlightGroup group = _highlightGroups[_editor]; if (string.IsNullOrEmpty(LookFor)) // Clear highlights group.ClearMarkers(); else { Editor.SearchEngine.SearchRequest.SearchPattern = txtLookFor.Text; Editor.SearchEngine.SearchRequest.CaseSensitive = chkMatchCase.Active; Editor.SearchEngine.SearchRequest.WholeWordOnly = chkMatchWholeWord.Active; int offset = 0, count = 0; for (;;) { SearchResult range = Editor.SearchEngine.SearchForward(offset); if (range == null || range.SearchWrapped) break; offset = range.Offset + range.Length; count++; HighlightSegmentMarker m = new HighlightSegmentMarker(range.Offset, range.Length); group.AddMarker(m); } if (count == 0) ShowMsg("Search text not found."); else window1.Hide(); } }
public void AddMarker(HighlightSegmentMarker marker) { _markers.Add(marker); _document.AddMarker(marker); }