Beispiel #1
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (BraceMatchingResult == null)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

            builder.CornerRadius       = 1;
            builder.AlignToWholePixels = true;

            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = BraceMatchingResult.Value.LeftSpan.Start, Length = BraceMatchingResult.Value.LeftSpan.Length
            });
            builder.CloseFigure(); // prevent connecting the two segments
            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = BraceMatchingResult.Value.RightSpan.Start, Length = BraceMatchingResult.Value.RightSpan.Length
            });

            Geometry geometry = builder.CreateGeometry();

            drawingContext.DrawGeometry(_backgroundBrush, _borderPen, geometry);
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (!Enabled)
            {
                return;
            }
            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

            builder.CornerRadius       = 1;
            builder.AlignToWholePixels = true;

            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = Begin, Length = 1
            });
            builder.CloseFigure();
            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = End, Length = 1
            });

            Geometry geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
            }
        }
Beispiel #3
0
            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());
                        }
                    }
                }
            }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.openBracketOffset == null || this.closeBracketOffset == null)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

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

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

            Geometry geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
            }
        }
Beispiel #5
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (renderedReferences == null)
            {
                return;
            }
            var builder = new BackgroundGeometryBuilder
            {
                CornerRadius          = cornerRadius,
                AlignToMiddleOfPixels = true
            };

            foreach (var reference in renderedReferences)
            {
                foreach (var span in reference.HighlightSpans)
                {
                    builder.AddSegment(textView, new TextSegment()
                    {
                        StartOffset = span.TextSpan.Start,
                        Length      = span.TextSpan.Length
                    });
                    builder.CloseFigure();
                }
            }
            Geometry geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
            }
        }
 public void Draw(TextView textview, DrawingContext drawingContext)
 {
     if (_result != null)
     {
         var backgroundGeometryBuilder = new BackgroundGeometryBuilder
         {
             CornerRadius       = 1.0,
             AlignToWholePixels = true
                                  //                    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 (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);
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (result == null)
            {
                return;
            }

            var builder = new BackgroundGeometryBuilder
            {
                CornerRadius       = 1,
                AlignToWholePixels = true,
                BorderThickness    = 0.0
            };

            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = result.OpeningBracketOffset, Length = result.OpeningBracketLength
            });
            builder.CloseFigure();
            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = result.ClosingBracketOffset, Length = result.ClosingBracketLength
            });

            var geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(backgroundBrush, null, geometry);
            }
        }
Beispiel #9
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (result == null)
            {
                return;
            }

            var builder = new BackgroundGeometryBuilder();

            builder.AlignToWholePixels = 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);
            }
        }
Beispiel #10
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (currentReferences == null)
            {
                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, DrawingContext drawingContext)
        {
            if (_result == null)
            {
                return;
            }

            var builder = new BackgroundGeometryBuilder();

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

            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = _result.OpeningBracketOffset, Length = _result.OpeningBracketLength
            });
            builder.CloseFigure();
            builder.AddSegment(textView, new TextSegment()
            {
                StartOffset = _result.ClosingBracketOffset, Length = _result.ClosingBracketLength
            });

            var geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(_backgroundBrush, _borderPen, 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 (borderPen == null)
            {
                this.UpdateColors(DefaultBackground, DefaultBackground);
            }

            if (geometry != null)
            {
                drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
            }
        }
        public void Draw(ICSharpCode.AvalonEdit.Rendering.TextView textView, DrawingContext drawingContext)
        {
            if (this.result == null)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

            builder.CornerRadius = 1;

            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)
            {
                var s = Element.Segment;

                if (s != null)
                {
                    var geoBuilder = new BackgroundGeometryBuilder
                    {
                        AlignToWholePixels = true,
                        BorderThickness    = ActiveBorderPen?.Thickness ?? 0
                    };
                    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 (var boundElement in Element._context.ActiveElements.OfType <BoundActiveElement>())
                            {
                                if (boundElement.TargetElement == Element)
                                {
                                    geoBuilder.AddSegment(textView, boundElement.Segment);
                                    geoBuilder.CloseFigure();
                                }
                            }
                            drawingContext.DrawGeometry(null, ActiveBorderPen, geoBuilder.CreateGeometry());
                        }
                    }
                }
            }
Beispiel #15
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (result.HasValue)
            {
                var match = result.Value;

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

                builder.AddSegment(textView, new TextSegment()
                {
                    StartOffset = match.LeftSpan.Start, Length = match.LeftSpan.Length
                });
                builder.CloseFigure(); // prevent connecting the two segments
                builder.AddSegment(textView, new TextSegment()
                {
                    StartOffset = match.RightSpan.Start, Length = match.RightSpan.Length
                });

                Geometry geometry = builder.CreateGeometry();
                if (geometry != null)
                {
                    drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry);
                }
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (LeftOfPosition == null && RightOfPosition == null)
            {
                return;
            }

            var builder = new BackgroundGeometryBuilder
            {
                CornerRadius = 1,
#if !AVALONIA
                AlignToMiddleOfPixels = true
#endif
            };

            if (RightOfPosition != null)
            {
                builder.AddSegment(textView, new TextSegment {
                    StartOffset = RightOfPosition.Value.LeftSpan.Start, Length = RightOfPosition.Value.LeftSpan.Length
                });
                builder.CloseFigure();
                builder.AddSegment(textView, new TextSegment {
                    StartOffset = RightOfPosition.Value.RightSpan.Start, Length = RightOfPosition.Value.RightSpan.Length
                });
                builder.CloseFigure();
            }

            if (LeftOfPosition != null)
            {
                builder.AddSegment(textView, new TextSegment {
                    StartOffset = LeftOfPosition.Value.LeftSpan.Start, Length = LeftOfPosition.Value.LeftSpan.Length
                });
                builder.CloseFigure();
                builder.AddSegment(textView, new TextSegment {
                    StartOffset = LeftOfPosition.Value.RightSpan.Start, Length = LeftOfPosition.Value.RightSpan.Length
                });
                builder.CloseFigure();
            }

            var geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(_backgroundBrush, null, geometry);
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            var text        = _editor.Text;
            var caretOffset = _editor.CaretOffset;

            if (caretOffset >= 0 && caretOffset <= text.Length)
            {
                var openingBracketOffset = -1;
                var closingBracketOffset = -1;

                if (caretOffset < text.Length)
                {
                    var  openingBracket = text[caretOffset];
                    char closingBracket;

                    if (OpeningBrackets.TryGetValue(openingBracket, out closingBracket))
                    {
                        openingBracketOffset = caretOffset;
                        closingBracketOffset = FindClosingBracketOffset(text, openingBracketOffset, openingBracket,
                                                                        closingBracket);
                    }
                }

                if (!(openingBracketOffset >= 0 && closingBracketOffset >= 0) && caretOffset > 0)
                {
                    var  closingBracket = text[caretOffset - 1];
                    char openingBracket;

                    if (ClosingBrackets.TryGetValue(closingBracket, out openingBracket))
                    {
                        closingBracketOffset = caretOffset - 1;
                        openingBracketOffset = FindOpeningBracketOffset(text, closingBracketOffset, openingBracket,
                                                                        closingBracket);
                    }
                }

                if (openingBracketOffset >= 0 && closingBracketOffset >= 0)
                {
                    var builder = new BackgroundGeometryBuilder {
                        CornerRadius = 1, AlignToMiddleOfPixels = true
                    };
                    builder.AddSegment(textView, new TextSegment {
                        StartOffset = openingBracketOffset, Length = 1
                    });
                    builder.CloseFigure(); // сегменты не связаны друг с другом
                    builder.AddSegment(textView, new TextSegment {
                        StartOffset = closingBracketOffset, Length = 1
                    });

                    var geometry = builder.CreateGeometry();

                    if (geometry != null)
                    {
                        drawingContext.DrawGeometry(CurrentBracketBrush, null, geometry);
                    }
                }
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            //check arguments are valid
            if (textView == null)
            {
                throw new ArgumentNullException(nameof(textView));
            }
            if (drawingContext == null)
            {
                throw new ArgumentNullException(nameof(drawingContext));
            }

            if (this.result == null)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder
            {
                CornerRadius       = 1,
                AlignToWholePixels = true,
                BorderThickness    = 1
            };

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