public void StartHighlight(ITextSpan span, HighlightKind kind, bool clearAllOfKind = false) { if (clearAllOfKind) { this.ClearHighlightsInternal(p => p.Kind == kind); } this.HighlightRegions.Add(new HighlightRegion { TextSpan = span, Kind = kind }); this.InvalidateVisual(); }
public void EndHighlight(ITextSpan span, HighlightKind kind) { var idsToRemove = new List <int>(); var arr = this.HighlightRegions.ToArray(); for (int i = this.HighlightRegions.Count - 1; i >= 0; i--) { var hs = this.HighlightRegions[i]; if (hs.TextSpan.Start == span.Start && hs.TextSpan.Length == span.Length && kind == hs.Kind) { idsToRemove.Add(i); } } foreach (var id in idsToRemove) { this.HighlightRegions.RemoveAt(id); } this.InvalidateVisual(); }