public void SetSpans(IMarkerSpanCollection newMarkerSpans) { if (newMarkerSpans.IsEmpty) { RemoveAllAdornments(); markedSpans = NullMarkerSpanCollection.Instance; } else { if (toMarkedLine.Count != 0) { var dict = new Dictionary <VirtualSnapshotSpan, MarkedLine>(toMarkedLine.Count, VirtualSnapshotSpanEqualityComparer.Instance); foreach (var markedLine in toMarkedLine.Values) { dict.Add(markedLine.Span, markedLine); } var infos = new List <MarkedLineInfo>(); foreach (var markedSpan in newMarkerSpans.VisibleSpans) { foreach (var info in GetMarkedLineInfos(infos, markedSpan)) { dict.Remove(info.Span); } } foreach (var markedLine in dict.Values) { adornmentLayer.RemoveAdornment(markedLine); } } markedSpans = newMarkerSpans; } AddMissingLines(); }
public Marker(IWpfTextView textView, IAdornmentLayer adornmentLayer) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } if (adornmentLayer == null) { throw new ArgumentNullException(nameof(adornmentLayer)); } this.textView = textView; this.adornmentLayer = adornmentLayer; this.toMarkedLine = new Dictionary <object, MarkedLine>(); this.markedSpans = NullMarkerSpanCollection.Instance; this.adornmentRemovedCallback = OnAdornmentRemoved; }