public void ClearMarkers() { foreach (TextMarker m in _markers) { _document.MarkerStrategy.RemoveMarker(m); } _markers.Clear(); _editor.Refresh(); }
private void btnHighlightAll_Click(object sender, EventArgs e) { if (!_highlightGroups.ContainsKey(_editor)) { _highlightGroups[_editor] = new HighlightGroup(_editor); } HighlightGroup group = _highlightGroups[_editor]; group.ClearMarkers(); if (!string.IsNullOrEmpty(LookFor)) { _search.LookFor = txtLookFor.Text; _search.MatchCase = chkMatchCase.Checked; _search.MatchWholeWordOnly = chkMatchWholeWord.Checked; bool looped = false; int offset = 0, count = 0; for (;;) { TextRange range = _search.FindNext(offset, false, out looped); if (range == null || looped) { break; } offset = range.Offset + range.Length; count++; var m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black); group.AddMarker(m); } _editor.Refresh(); // must repaint manually // JDB: Closing and leaving all the highlights active is annoying //if (count == 0) // MessageBox.Show("Search text not found."); //else // Close(); } }
public static void SelectText(TextEditorControl textArea, int offset, int endOffset) { int textLength = textArea.ActiveTextAreaControl.Document.TextLength; if (textLength < endOffset) { endOffset = textLength - 1; } textArea.ActiveTextAreaControl.Caret.Position = textArea.Document.OffsetToPosition(endOffset); textArea.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection(); textArea.ActiveTextAreaControl.TextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, textArea.Document.OffsetToPosition(offset), textArea.Document.OffsetToPosition(endOffset))); textArea.Refresh(); }
public static void ShowCodeCoverage(TextEditorControl textEditor, string fileName) { foreach (CodeCoverageResults results in CodeCoverageService.Results) { List<CodeCoverageSequencePoint> sequencePoints = results.GetSequencePoints(fileName); if (sequencePoints.Count > 0) { codeCoverageHighlighter.AddMarkers(textEditor.Document.MarkerStrategy, sequencePoints); textEditor.Refresh(); } } }