コード例 #1
0
 public Geometry GetMarkerGeometry(SnapshotSpan bufferSpan)
 {
     if (bufferSpan.Snapshot != snapshot)
     {
         throw new ArgumentException();
     }
     if (MarkerHelper.IsMultiLineSpan(textView, bufferSpan))
     {
         return(GetLineMarkerGeometry(bufferSpan));
     }
     return(GetTextMarkerGeometry(bufferSpan));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
ファイル: Marker.cs プロジェクト: zhangguanjiong/dnSpy
        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);
        }
コード例 #4
0
ファイル: TextSelectionLayer.cs プロジェクト: pashav15/pashav
        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));
        }