void AddMissingLines() { if (markedSpans.IsEmpty) { return; } var infos = new List <MarkedLineInfo>(); foreach (var markedSpan in markedSpans.VisibleSpans) { foreach (var info in GetMarkedLineInfos(infos, markedSpan)) { if (toMarkedLine.ContainsKey(info.Line.IdentityTag)) { continue; } var geo = MarkerHelper.CreateGeometry(textView, info.Span, markedSpans.IsBoxMode, info.IsMultiLineSpan, true); if (geo == null) { continue; } var markedLine = new MarkedLine(info.Span, geo, info.Line.IdentityTag, BackgroundBrush, Pen); bool added = adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, markedLine.Span.SnapshotSpan, markedLine, markedLine, adornmentRemovedCallback); if (added) { toMarkedLine.Add(markedLine.IdentityTag, markedLine); } } } }
public Geometry GetMarkerGeometry(SnapshotSpan bufferSpan, bool clipToViewport, Thickness padding) { if (bufferSpan.Snapshot != snapshot) { throw new ArgumentException(); } if (MarkerHelper.IsMultiLineSpan(textView, bufferSpan)) { return(GetLineMarkerGeometry(bufferSpan, clipToViewport, padding)); } return(GetTextMarkerGeometry(bufferSpan, clipToViewport, padding)); }
public Geometry GetMarkerGeometry(SnapshotSpan bufferSpan) { if (bufferSpan.Snapshot != snapshot) { throw new ArgumentException(); } if (MarkerHelper.IsMultiLineSpan(textView, bufferSpan)) { return(GetLineMarkerGeometry(bufferSpan)); } return(GetTextMarkerGeometry(bufferSpan)); }
List <MarkedLineInfo> GetMarkedLineInfos(List <MarkedLineInfo> infos, VirtualSnapshotSpan markedSpan) { infos.Clear(); var formattedSpan = textView.TextViewLines.FormattedSpan; bool useVspace = formattedSpan.End == markedSpan.End.Position && markedSpan.End.Position.Position == markedSpan.Snapshot.Length; var virtFormattedSpan = new VirtualSnapshotSpan(new VirtualSnapshotPoint(formattedSpan.Start), new VirtualSnapshotPoint(formattedSpan.End, useVspace ? markedSpan.End.VirtualSpaces : 0)); var intersectionTmp = virtFormattedSpan.Intersection(markedSpan); if (intersectionTmp == null) { return(infos); } var span = intersectionTmp.Value; bool isMultiLineSpan = MarkerHelper.IsMultiLineSpan(textView, span.SnapshotSpan); var pos = span.Start; int lines = 0; while (pos <= span.End) { if (lines > 0 && pos == span.End) { break; } var line = textView.TextViewLines.GetTextViewLineContainingBufferPosition(pos.Position); if (line == null) { break; } bool useVspace2 = useVspace && line.IsLastDocumentLine(); var lineSpan = new VirtualSnapshotSpan(new VirtualSnapshotPoint(line.Start), new VirtualSnapshotPoint(line.EndIncludingLineBreak, useVspace2 ? markedSpan.End.VirtualSpaces : 0)); var lineIntersectionTmp = lineSpan.Intersection(span); Debug.Assert(lineIntersectionTmp != null); if (lineIntersectionTmp != null) { infos.Add(new MarkedLineInfo(line, lineIntersectionTmp.Value, isMultiLineSpan)); } if (line.IsLastDocumentLine()) { break; } pos = new VirtualSnapshotPoint(line.EndIncludingLineBreak); lines++; } return(infos); }
KeyValuePair <SnapshotSpan, Geometry>?CreateStreamSelection() { Debug.Assert(!textSelection.IsEmpty && textSelection.Mode == TextSelectionMode.Stream); bool isMultiLine = MarkerHelper.IsMultiLineSpan(textSelection.TextView, textSelection.StreamSelectionSpan.SnapshotSpan); var span = textSelection.StreamSelectionSpan.Overlap(new VirtualSnapshotSpan(textSelection.TextView.TextViewLines.FormattedSpan)); if (span == null) { return(null); } var geo = MarkerHelper.CreateGeometry(textSelection.TextView, span.Value, false, isMultiLine); if (geo == null) { return(null); } return(new KeyValuePair <SnapshotSpan, Geometry>(span.Value.SnapshotSpan, geo)); }
KeyValuePair <SnapshotSpan, Geometry>?CreateBoxSelection() { Debug.Assert(!textSelection.IsEmpty && textSelection.Mode == TextSelectionMode.Box); var allSpans = textSelection.VirtualSelectedSpans; var spans = GetVisibleBoxSpans(allSpans); if (spans.Count == 0) { return(null); } var geo = MarkerHelper.CreateBoxGeometry(textSelection.TextView, spans, allSpans.Count > 1); if (geo == null) { return(null); } var fullSpan = new SnapshotSpan(spans[0].SnapshotSpan.Start, spans[spans.Count - 1].SnapshotSpan.End); return(new KeyValuePair <SnapshotSpan, Geometry>(fullSpan, geo)); }
Geometry GetMarkerGeometry(SnapshotSpan bufferSpan, bool clipToViewport, Thickness padding, bool isLineGeometry) { if (bufferSpan.Snapshot != snapshot) { throw new ArgumentException(); } bool createOutlinedPath = false; PathGeometry geo = null; var textBounds = GetNormalizedTextBounds(bufferSpan); MarkerHelper.AddGeometries(textView, textBounds, isLineGeometry, clipToViewport, padding, 0, ref geo, ref createOutlinedPath, false); if (createOutlinedPath) { geo = geo.GetOutlinedPathGeometry(); } if (geo != null && geo.CanFreeze) { geo.Freeze(); } return(geo); }