public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView == null)
                throw new ArgumentNullException("textView");
            if (drawingContext == null)
                throw new ArgumentNullException("drawingContext");

            if (currentResults == null || !textView.VisualLinesValid)
                return;

            var visualLines = textView.VisualLines;
            if (visualLines.Count == 0)
                return;

            int viewStart = visualLines.First().FirstDocumentLine.Offset;
            int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;

            foreach (SearchResult result in currentResults.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
                BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
                geoBuilder.AlignToMiddleOfPixels = true;
                geoBuilder.CornerRadius = 3;
                geoBuilder.AddSegment(textView, result);
                Geometry geometry = geoBuilder.CreateGeometry();
                if (geometry != null) {
                    drawingContext.DrawGeometry(markerBrush, markerPen, geometry);
                }
            }
        }
Пример #2
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
            geoBuilder.AlignToMiddleOfPixels = true;
            geoBuilder.ExtendToFullWidthAtLineEnd = textArea.Selection.EnableVirtualSpace;
            geoBuilder.CornerRadius = textArea.SelectionCornerRadius;
            foreach (var segment in textArea.Selection.Segments) {
                geoBuilder.AddSegment(textView, segment);
            }
            Geometry geometry = geoBuilder.CreateGeometry();
            if (geometry != null) {
                drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
            }
        }
 public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext)
 {
     ISegment s = element.Segment;
     if (s != null) {
         BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
         geoBuilder.AlignToMiddleOfPixels = true;
         if (Layer == KnownLayer.Background) {
             geoBuilder.AddSegment(textView, s);
             drawingContext.DrawGeometry(backgroundBrush, null, geoBuilder.CreateGeometry());
         } else {
             // draw foreground only if active
             if (element.isCaretInside) {
                 geoBuilder.AddSegment(textView, s);
                 foreach (BoundActiveElement boundElement in element.context.ActiveElements.OfType<BoundActiveElement>()) {
                     if (boundElement.targetElement == element) {
                         geoBuilder.AddSegment(textView, boundElement.Segment);
                         geoBuilder.CloseFigure();
                     }
                 }
                 drawingContext.DrawGeometry(null, activeBorderPen, geoBuilder.CreateGeometry());
             }
         }
     }
 }