AddSegment() public méthode

Adds the specified segment to the geometry.
public AddSegment ( TextView textView, ISegment segment ) : void
textView TextView
segment ISegment
Résultat void
 public void Draw(TextView textview, DrawingContext drawingContext)
 {
     if (_result != null)
     {
         var backgroundGeometryBuilder = new BackgroundGeometryBuilder
         {
             CornerRadius = 1.0,
             AlignToMiddleOfPixels = true
         };
         backgroundGeometryBuilder.AddSegment(textview, new TextSegment
         {
             StartOffset = _result.OpeningBracketOffset,
             Length = _result.OpeningBracketLength
         });
         backgroundGeometryBuilder.CloseFigure();
         backgroundGeometryBuilder.AddSegment(textview, new TextSegment
         {
             StartOffset = _result.ClosingBracketOffset,
             Length = _result.ClosingBracketLength
         });
         var geometry = backgroundGeometryBuilder.CreateGeometry();
         if (_borderPen == null)
         {
             UpdateColors(DefaultBackground, DefaultBackground);
         }
         if (geometry != null)
         {
             drawingContext.DrawGeometry(_backgroundBrush, _borderPen, geometry);
         }
     }
 }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (result == null)
                return;

            var builder = new BackgroundGeometryBuilder();
            builder.AlignToMiddleOfPixels = true;
            builder.AddSegment(textView, new TextSegment { StartOffset = result.OpeningOffset, Length = 1 });
            builder.CloseFigure(); // prevent connecting the two segments
            builder.AddSegment(textView, new TextSegment { StartOffset = result.ClosingOffset, Length = 1 });

            var geometry = builder.CreateGeometry();
            if (geometry != null)
                drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
        }
Exemple #3
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
            geoBuilder.CornerRadius = textArea.SelectionCornerRadius;
            foreach (var segment in textArea.Selection.Segments) {
                geoBuilder.AddSegment(textView, segment);
            }
            Geometry geometry = geoBuilder.CreateGeometry();
            if (geometry != null)
            {
                if (textArea.Selection.IsFindOnPageSelection())
                {
                    drawingContext.DrawGeometry(textArea.FindOnPageBrush, textArea.FindOnPageBorder, geometry);
                    textView.findOnPageSelectionGeometry = geometry;
                }
                else
                {
                    drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
                    textView.findOnPageSelectionGeometry = null;
                }
            }
            else
            {
                textView.findOnPageSelectionGeometry = null;
            }
        }
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (textView == null)
			{
				throw new ArgumentNullException("textView");
			}
			if (drawingContext == null)
			{
				throw new ArgumentNullException("drawingContext");
			}
			if (this.currentResults == null || !textView.VisualLinesValid)
			{
				return;
			}
			ReadOnlyCollection<VisualLine> visualLines = textView.VisualLines;
			if (visualLines.Count == 0)
			{
				return;
			}
			int offset = visualLines.First<VisualLine>().FirstDocumentLine.Offset;
			int endOffset = visualLines.Last<VisualLine>().LastDocumentLine.EndOffset;
			foreach (var current in this.currentResults.FindOverlappingSegments(offset, endOffset - offset))
			{
				BackgroundGeometryBuilder backgroundGeometryBuilder = new BackgroundGeometryBuilder();
				backgroundGeometryBuilder.AlignToMiddleOfPixels = true;
				backgroundGeometryBuilder.CornerRadius = 3.0;
				backgroundGeometryBuilder.AddSegment(textView, current);
				Geometry geometry = backgroundGeometryBuilder.CreateGeometry();
				if (geometry != null)
				{
					drawingContext.DrawGeometry(this.markerBrush, this.markerPen, geometry);
				}
			}
		}
		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);
				}
			}
		}
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (this.result == null)
				return;
			
			BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
			
			builder.CornerRadius = 1;
			builder.AlignToMiddleOfPixels = true;
			
			builder.AddSegment(textView, new TextSegment() { StartOffset = result.OpeningBracketOffset, Length = result.OpeningBracketLength });
			builder.CloseFigure(); // prevent connecting the two segments
			builder.AddSegment(textView, new TextSegment() { StartOffset = result.ClosingBracketOffset, Length = result.ClosingBracketLength });
			
			Geometry geometry = builder.CreateGeometry();
			if (geometry != null) {
				drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
			}
		}
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (markers == 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 (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart))
            {
                if (marker.BackgroundColor != null)
                {
                    var geoBuilder = new BackgroundGeometryBuilder { AlignToWholePixels = true, CornerRadius = 3 };
                    geoBuilder.AddSegment(textView, marker);
                    Geometry geometry = geoBuilder.CreateGeometry();
                    if (geometry != null)
                    {
                        Color color = marker.BackgroundColor.Value;
                        var brush = new SolidColorBrush(color);
                        brush.Freeze();
                        drawingContext.DrawGeometry(brush, null, geometry);
                    }
                }
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker))
                {
                    Point startPoint = r.BottomLeft;
                    Point endPoint = r.BottomRight;

                    var usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1);
                    usedPen.Freeze();
                    const double offset = 2.5;

                    int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);

                    var geometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = geometry.Open())
                    {
                        ctx.BeginFigure(startPoint, false, false);
                        ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
                    }

                    geometry.Freeze();

                    drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
                    break;
                }
            }
        }
Exemple #8
0
		protected override void OnRender(DrawingContext drawingContext)
		{
			base.OnRender(drawingContext);
			
			BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
			geoBuilder.AlignToMiddleOfPixels = true;
			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);
			}
		}
Exemple #9
0
        //--------------------------------------------------------------
        /// <inheritdoc/>
        public override void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (Pen == null && Brush == null)
                return;

            var geometryBuilder = new BackgroundGeometryBuilder
            {
                CornerRadius = 1,
                AlignToMiddleOfPixels = true
            };

            geometryBuilder.AddSegment(textView, this);
            var geometry = geometryBuilder.CreateGeometry();
            if (geometry != null && geometry.Bounds.Width > 1 && geometry.Bounds.Height > 1)
                drawingContext.DrawGeometry(Brush, Pen, geometry);
        }
Exemple #10
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            var 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);

            var geometry = geoBuilder.CreateGeometry();

            if (geometry != null)
                drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
        }
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (this.renderedReferences == null)
				return;
			BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
			builder.CornerRadius = cornerRadius;
			builder.AlignToMiddleOfPixels = true;
			foreach (var reference in this.renderedReferences) {
				builder.AddSegment(textView, new TextSegment() { 
				                   	StartOffset = reference.Offset, 
				                   	Length = reference.Length });
				builder.CloseFigure();
			}
			Geometry geometry = builder.CreateGeometry();
			if (geometry != null) {
				drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
			}
		}
		protected override void OnRender(DrawingContext drawingContext)
		{
			base.OnRender(drawingContext);
			
			BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
			foreach (var segment in textArea.Selection.Segments) {
				geoBuilder.AddSegment(textView, segment);
			}
			Geometry geometry = geoBuilder.CreateGeometry();
			if (geometry != null) {
				SolidColorBrush lightHighlightBrush = new SolidColorBrush(SystemColors.HighlightColor);
				lightHighlightBrush.Opacity = 0.7;
				lightHighlightBrush.Freeze();
				Pen pen = new Pen(SystemColors.HighlightBrush, 1);
				//pen.LineJoin = PenLineJoin.Round;
				pen.Freeze();
				drawingContext.DrawGeometry(lightHighlightBrush, pen, geometry);
			}
		}
Exemple #13
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)
            {
                // [DIGITALRUNE] Reduce opacity if TextEditor isn't active.
                Opacity = textArea.IsKeyboardFocusWithin ? 1.0 : 0.5;

                drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
            }
        }
Exemple #14
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <inheritdoc/>
        public override void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (Pen == null && Brush == null)
            {
                return;
            }

            var geometryBuilder = new BackgroundGeometryBuilder
            {
                CornerRadius          = 1,
                AlignToMiddleOfPixels = true
            };

            geometryBuilder.AddSegment(textView, this);
            var geometry = geometryBuilder.CreateGeometry();

            if (geometry != null && geometry.Bounds.Width > 1 && geometry.Bounds.Height > 1)
            {
                drawingContext.DrawGeometry(Brush, Pen, geometry);
            }
        }
        /// <summary>
        /// Causes the background renderer to draw.
        /// </summary>
        /// <param name="textView"></param>
        /// <param name="drawingContext"></param>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if(String.IsNullOrWhiteSpace(editor.SelectedText)
                || !editor.SelectedText.All(Char.IsLetterOrDigit))
            {
                return;
            }
            ISearchStrategy strategy = SearchStrategyFactory.Create(editor.SelectedText, false, true, SearchMode.Normal);

            foreach(ISearchResult result in strategy.FindAll(textView.Document, 0, textView.Document.TextLength))
            {
                BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder() {
                    CornerRadius = 1
                };
                builder.AddSegment(textView, result);
                drawingContext.DrawGeometry(BrushStyle, PenStyle, builder.CreateGeometry());
            }
        }
Exemple #16
0
		public void Draw(ICSharpCode.AvalonEdit.Rendering.TextView textView, DrawingContext drawingContext)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (drawingContext == null)
				throw new ArgumentNullException("drawingContext");
			if (markers == null || !textView.VisualLinesValid)
				return;
			var visualLines = textView.VisualLines;
			if (visualLines.Count == 0)
				return;
			int viewStart = visualLines.First().FirstDocumentLine.Offset;
			int viewEnd = visualLines.Last().LastDocumentLine.Offset + visualLines.Last().LastDocumentLine.Length;
			foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart).Reverse()) {
				if (!marker.IsVisible(marker.Bookmark))
					continue;
				
				if (marker.BackgroundColor != null) {
					BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
					geoBuilder.AlignToWholePixels = true;
					geoBuilder.CornerRadius = 3;
					geoBuilder.AddSegment(textView, marker);
					Geometry geometry = geoBuilder.CreateGeometry();
					if (geometry != null) {
						Color color = marker.BackgroundColor.Value;
						SolidColorBrush brush = new SolidColorBrush(color);
						brush.Freeze();
						drawingContext.DrawGeometry(brush, null, geometry);
					}
				}
				if (marker.MarkerType != TextMarkerType.None) {
					foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) {
						Point startPoint = r.BottomLeft;
						Point endPoint = r.BottomRight;
						
						Pen usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1);
						usedPen.Freeze();
						switch (marker.MarkerType) {
							case TextMarkerType.SquigglyUnderline:
								double offset = 2.5;
								
								int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);
								
								StreamGeometry geometry = new StreamGeometry();
								
								using (StreamGeometryContext ctx = geometry.Open()) {
									ctx.BeginFigure(startPoint, false, false);
									ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
								}
								
								geometry.Freeze();
								
								drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
								break;
						}
					}
				}
			}
		}
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (drawingContext == null)
				throw new ArgumentNullException("drawingContext");
			if (markers == null || !textView.VisualLinesValid)
				return;
			var visualLines = textView.VisualLines;
			if (visualLines.Count == 0)
				return;
			int viewStart = visualLines.First().FirstDocumentLine.Offset;
			int viewEnd = visualLines.Last().LastDocumentLine.Offset + visualLines.Last().LastDocumentLine.Length;
			foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
				if (marker.BackgroundColor != null) {
					BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
					geoBuilder.AddSegment(textView, marker);
					Geometry geometry = geoBuilder.CreateGeometry();
					if (geometry != null) {
						Color color = marker.BackgroundColor.Value;
						SolidColorBrush brush = new SolidColorBrush(color);
						brush.Freeze();
						drawingContext.DrawGeometry(brush, null, geometry);
					}
				}
			}
		}
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (currentReferences == null) {
				if (textView.VisualLines.Count == 0)
					return;
				var start = textView.VisualLines.First().FirstDocumentLine.LineNumber;
				var end = textView.VisualLines.Last().LastDocumentLine.LineNumber;
				currentReferences = new List<ISegment>();
				FindCurrentReferences(start, end);
			}
			if (currentReferences.Count == 0)
				return;
			BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
			builder.CornerRadius = cornerRadius;
			builder.AlignToMiddleOfPixels = true;
			foreach (var reference in this.currentReferences) {
				builder.AddSegment(textView, new TextSegment() {
					StartOffset = reference.Offset,
					Length = reference.Length
				});
				builder.CloseFigure();
			}
			Geometry geometry = builder.CreateGeometry();
			if (geometry != null) {
				drawingContext.DrawGeometry(backgroundBrush, borderPen, 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());
						}
					}
				}
			}
        /// <summary>
        /// Defines style of highlighting.
        /// </summary>
        /// <param name="segment"></param>
        /// <param name="textView"></param>
        /// <param name="drawingContext"></param>
        protected virtual void highlight(ISegment segment, TextView textView, DrawingContext drawingContext)
        {
            BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder() {
                CornerRadius = 0
            };
            geoBuilder.AddSegment(textView, segment);

            Geometry geometry = geoBuilder.CreateGeometry();
            drawingContext.DrawGeometry(BrushStyle, PenStyle, geometry);
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView == null)
                throw new ArgumentNullException(nameof(textView));
            if (drawingContext == null)
                throw new ArgumentNullException(nameof(drawingContext));
            if (_markers == null || !textView.VisualLinesValid)
                return;
            var visualLines = textView.VisualLines;
            if (visualLines.Count == 0)
                return;
            var viewStart = visualLines.First().FirstDocumentLine.Offset;
            var viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
            foreach (var marker in _markers.FindOverlappingSegments(viewStart, viewEnd - viewStart))
            {
                if (marker.BackgroundColor != null)
                {
                    var geoBuilder = new BackgroundGeometryBuilder
                    {
                        AlignToWholePixels = true,
                        CornerRadius = 3
                    };
                    geoBuilder.AddSegment(textView, marker);
                    var geometry = geoBuilder.CreateGeometry();
                    if (geometry != null)
                    {
                        var color = marker.BackgroundColor.Value;

                        if (IsActiveDebugging && marker.Bookmark != null && marker.Bookmark.BookmarkType == BookmarkType.Breakpoint)
                            color.A = 0x77;
                        else
                            color.A = 0xff;

                        var brush = new SolidColorBrush(color);
                        brush.Freeze();
                        drawingContext.DrawGeometry(brush, null, geometry);
                    }
                }
                foreach (var r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker))
                {
                    var startPoint = r.BottomLeft;
                    var endPoint = r.BottomRight;

                    Brush usedBrush = new SolidColorBrush(marker.MarkerColor);
                    usedBrush.Freeze();
                    var offset = 2.5;

                    var count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);

                    var geometry = new StreamGeometry();

                    using (var ctx = geometry.Open())
                    {
                        ctx.BeginFigure(startPoint, false, false);
                        ctx.PolyLineTo(CreatePoints(startPoint, offset, count).ToArray(), true, false);
                    }

                    geometry.Freeze();

                    var usedPen = new Pen(usedBrush, 1);
                    usedPen.Freeze();
                    drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
                }
            }
        }
Exemple #22
0
            public void Draw(TextView textView, DrawingContext drawingContext)
            {
                BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

                builder.CornerRadius = 1;
                builder.AlignToMiddleOfPixels = true;

                builder.AddSegment(textView, new TextSegment() { StartOffset = _from, Length = _len });
                builder.CloseFigure(); // prevent connecting the two segments

                Geometry geometry = builder.CreateGeometry();
                if (geometry != null)
                {
                    drawingContext.DrawGeometry(Brushes.LightGreen, border, geometry);
                }
            }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.renderedSegments == null)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
            builder.CornerRadius = this.cornerRadius;
            builder.AlignToMiddleOfPixels = true;
            foreach (var segment in this.renderedSegments)
            {
                builder.AddSegment(textView, segment);
                builder.CloseFigure();
            }

            Geometry geometry = builder.CreateGeometry();
            if (geometry != null)
            {
                drawingContext.DrawGeometry(this.backgroundBrush, this.borderPen, geometry);
            }
        }
Exemple #24
0
        /// <summary>
        /// Causes the background renderer to draw.
        /// </summary>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView.VisualLines.Count == 0)
                return;
            
            int viewStart = textView.VisualLines.First().FirstDocumentLine.Offset;
            int viewEnd = textView.VisualLines.Last().LastDocumentLine.EndOffset;
            foreach (IHighlightedRange hl in _highlights.FindOverlappingSegments(viewStart, viewEnd - viewStart))
            {
                if (hl.BackgroundColour != null)
                {
                    BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
                    geoBuilder.AlignToWholePixels = true;
                    geoBuilder.CornerRadius = 3;
                    geoBuilder.AddSegment(textView, hl);
                    Geometry geometry = geoBuilder.CreateGeometry();
                    if (geometry != null)
                    {
                        Color color = hl.BackgroundColour.Value;
                        SolidColorBrush brush = new SolidColorBrush(color);
                        brush.Freeze();
                        drawingContext.DrawGeometry(brush, null, geometry);
                    }
                }

                if (hl.ForegroundColour != null)
                {
                    DrawUnderline(textView, drawingContext, hl, hl.ForegroundColour.Value);
                }
            }
        }
    public void Draw(TextView textView, DrawingContext drawingContext) {
      if (textView == null)
        throw new ArgumentNullException("textView");
      if (drawingContext == null)
        throw new ArgumentNullException("drawingContext");
      if (markers == 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 (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
        if (marker.BackgroundColor != null) {
          BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
          geoBuilder.AlignToWholePixels = true;
          geoBuilder.CornerRadius = 3;
          geoBuilder.AddSegment(textView, marker);
          Geometry geometry = geoBuilder.CreateGeometry();
          if (geometry != null) {
            Color color = marker.BackgroundColor.Value;
            SolidColorBrush brush = new SolidColorBrush(color);
            brush.Freeze();
            drawingContext.DrawGeometry(brush, null, geometry);
          }
        }
        var underlineMarkerTypes = TextMarkerTypes.SquigglyUnderline | TextMarkerTypes.NormalUnderline | TextMarkerTypes.DottedUnderline;
        if ((marker.MarkerTypes & underlineMarkerTypes) != 0) {
          foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) {
            Point startPoint = r.BottomLeft;
            Point endPoint = r.BottomRight;

            Brush usedBrush = new SolidColorBrush(marker.MarkerColor);
            usedBrush.Freeze();
            if ((marker.MarkerTypes & TextMarkerTypes.SquigglyUnderline) != 0) {
              double offset = 2.5;

              int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);

              StreamGeometry geometry = new StreamGeometry();

              using (StreamGeometryContext ctx = geometry.Open()) {
                ctx.BeginFigure(startPoint, false, false);
                ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
              }

              geometry.Freeze();

              Pen usedPen = new Pen(usedBrush, 1);
              usedPen.Freeze();
              drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
            }
            if ((marker.MarkerTypes & TextMarkerTypes.NormalUnderline) != 0) {
              Pen usedPen = new Pen(usedBrush, 1);
              usedPen.Freeze();
              drawingContext.DrawLine(usedPen, startPoint, endPoint);
            }
            if ((marker.MarkerTypes & TextMarkerTypes.DottedUnderline) != 0) {
              Pen usedPen = new Pen(usedBrush, 1);
              usedPen.DashStyle = DashStyles.Dot;
              usedPen.Freeze();
              drawingContext.DrawLine(usedPen, startPoint, endPoint);
            }
          }
        }
      }
    }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.result == null)
            return;

              BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

              builder.CornerRadius = 1;
              builder.AlignToMiddleOfPixels = true;

              builder.AddSegment(textView, new TextSegment() { StartOffset = result.OpeningBracketOffset, Length = result.OpeningBracketLength });
              builder.CloseFigure(); // prevent connecting the two segments
              builder.AddSegment(textView, new TextSegment() { StartOffset = result.ClosingBracketOffset, Length = result.ClosingBracketLength });

              Geometry geometry = builder.CreateGeometry();

              //Transform highlightFixTransform = new TranslateTransform(0, 2);
              //geometry.Transform.Value.OffsetY = 2;

              if (borderPen == null)
            this.UpdateColors(DefaultBackground, DefaultBackground);
              if (result.ClosingBracketLength == 0)
              this.UpdateColors(InvalidBackground, InvalidBackground);
              else
              this.UpdateColors(DefaultBackground, DefaultBackground);

              if (geometry != null)
              {
            drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry );
              }
        }