예제 #1
0
            public void Draw(TextView textView, DrawingContext drawingContext)
            {
                if (_editor.Document == null || CurrentCodeSectionManager == null || CurrentCodeSectionManager.CompilerErrorCollection == null)
                {
                    return;
                }

                textView.EnsureVisualLines();
                for (int i = 0; i < CurrentCodeSectionManager.CompilerErrorCollection.Count; ++i)
                {
                    var error      = CurrentCodeSectionManager.CompilerErrorCollection[i];
                    int lineNumber = error.Line - CurrentCodeSectionStartLine;
                    if (lineNumber > 0 && lineNumber < _editor.LineCount)
                    {
                        var line = _editor.Document.GetLineByNumber(lineNumber);
                        foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, line))
                        {
                            var rect2 = new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height));
                            if (rect2.Height > 1 && rect2.Width > 1)
                            {
                                drawingContext.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(0x20, 0xff, 0, 0)), new Pen(new SolidColorBrush(Color.FromArgb(0xa0, 0xff, 0, 0)), 1), rect2, 3, 3);
                            }
                            var column = error.Column - CurrentCodeSectionManager.GetSectionIndendationSize(CurrentCodeSectionId);

                            DrawColumnIndicator(drawingContext, new Point(rect2.Left + column * 7 + 3, rect2.Top - 1));
                        }
                    }
                }
            }
예제 #2
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.FileFolderRef == null)
            {
                return;
            }
            textView.EnsureVisualLines();
            var color = new SolidColorBrush(ConfigHost.Coloring.BreakPoint.TextHighlightColor);

            color.Freeze();
            foreach (var bp in Workspace.Instance.BreakpointManager[this.FileFolderRef])
            {
                if (!bp.IsEnabled)
                {
                    continue;
                }
                if (bp.Line >= this.Document.LineCount)
                {
                    Workspace.Instance.BreakpointManager.RemoveBreakpoint(bp);
                    continue;
                }
                var line    = this.Document.GetLineByNumber(bp.Line);
                var segment = new TextSegment {
                    StartOffset = line.Offset, EndOffset = line.EndOffset
                };
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {
                    drawingContext.DrawRectangle(color, null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #3
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();
            var color = new SolidColorBrush(ConfigHost.Coloring.BreakPoint.TextHighlightColor);

            color.Freeze();
            var invalidBps = new List <DataContext.BreakpointsPaneUtil.Breakpoint>();

            foreach (var bp in this.SolutionFileRef.BreakPoints)
            {
                if (bp.Line < 0)
                {
                    Logger.Log(NLog.LogLevel.Warn, $"Removed invalid breakpoint in file '{this.SolutionFileRef.FileName}'.");
                    invalidBps.Add(bp);
                    continue;
                }
                var line    = this.Document.GetLineByNumber(bp.Line);
                var segment = new TextSegment {
                    StartOffset = line.Offset, EndOffset = line.EndOffset
                };
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {
                    drawingContext.DrawRectangle(color, null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
            foreach (var bp in invalidBps)
            {
                this.SolutionFileRef.BreakPoints.Remove(bp);
            }
        }
예제 #4
0
        public void Visual_Line_Should_Create_One_Text_Lines_When_Not_Wrapping()
        {
            using var app = UnitTestApplication.Start(TestServices.StyledWindow);

            TextView textView = new TextView();

            TextDocument document = new TextDocument("hello world".ToCharArray());

            textView.Document = document;
            textView.EnsureVisualLines();
            ((ILogicalScrollable)textView).CanHorizontallyScroll = false;
            textView.Width = MockGlyphTypeface.GlyphAdvance * 500;

            Window window = new Window();

            window.Content = textView;
            window.Show();

            VisualLine visualLine = textView.GetOrConstructVisualLine(document.Lines[0]);

            Assert.AreEqual(1, visualLine.TextLines.Count);
            Assert.AreEqual("hello world", ((TextLineImpl)visualLine.TextLines[0]).LineRuns[0].StringRange.ToString());

            window.Close();
        }
        /// <summary>
        /// Draw the background line highlighting of the current line.
        /// </summary>
        /// <param name="textView"></param>
        /// <param name="drawingContext"></param>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this._Editor == null)
            {
                return;
            }

            if (this._Editor.Document == null)
            {
                return;
            }

            if (_Editor.EditorCurrentLineBorderThickness == 0 && _Editor.EditorCurrentLineBackground == null)
            {
                return;
            }

            Pen borderPen = null;

            if (_Editor.EditorCurrentLineBorder != null)
            {
                borderPen = new Pen(_Editor.EditorCurrentLineBorder, _Editor.EditorCurrentLineBorderThickness);
                borderPen.Freeze();
            }

            textView.EnsureVisualLines();
            var currentLine = _Editor.Document.GetLineByOffset(_Editor.CaretOffset);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(_Editor.EditorCurrentLineBackground, borderPen,
                                             new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
            }
        }
예제 #6
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView.Document == null /*|| !_isFocused.Value*/)
            {
                _commentsPanel.HighlightLine(0);
                return;
            }

            DocumentLine line = _editor.Document.GetLineByOffset(_editor.CaretOffset);

            _commentsPanel.HighlightLine(line.LineNumber);

            textView.EnsureVisualLines();
            foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, new TextSegment()
            {
                StartOffset = line.Offset
            }))
            {
                drawingContext.DrawRectangle(
                    _brush, // Строка
                    _pen,   // Рамка
                    new Rect(r.Location, new Size(Math.Max(_editor.ExtentWidth, _editor.ViewportWidth), r.Height))
                    );
            }
        }
예제 #7
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null || _offsetsToMark.Count == 0)
            {
                return;
            }

            textView.EnsureVisualLines();

            foreach (var mark in _offsetsToMark)
            {
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(
                             textView, new TextSegment {
                    StartOffset = mark.Offset, Length = mark.Length
                }))
                {
                    drawingContext.DrawRoundedRectangle(
                        mark.Brush,
                        null,
                        new Rect(r.Location, r.Size),
                        3, 3
                        );
                }
            }

            //http://danielgrunwald.de/coding/AvalonEdit/rendering.php
            //http://stackoverflow.com/questions/5072761/avalonedit-highlight-current-line-even-when-not-focused
            //DocumentLine currentLine = _editor.Document.GetLineByOffset((int)_offsetToMark);
            //foreach (Rect rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            //{
            //    drawingContext.DrawRectangle(
            //        new SolidColorBrush(Color.FromArgb(0x40, 0, 0, 0xFF)), null,
            //        new Rect(rect.Location, new Size(textView.ActualWidth - 32, rect.Height)));
            //}
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Error Tokens

            var errorsToVisualize = _solution.ErrorService.GetErrorsFromDocument(_codeitem);

            foreach(var err in errorsToVisualize) {
                if(err.Range != null) {
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, err.Range)) {
                        //drawingContext.DrawRectangle(null, _errorPen, r);
                        drawingContext.DrawLine(_errorPen, r.BottomLeft, r.BottomRight);
                    }
                } else {

                    var line = _editor.Document.GetLineByNumber(err.StartLine);
                    if(line != null) {
                        var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };

                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                            drawingContext.DrawRectangle(_errorBrush, _errorPen, r);
                        }
                    }
                }
            }

            #endregion
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this._editor.Document == null)
            {
                return;
            }

            try
            {
                textView.EnsureVisualLines();
                var currentLine = this._editor.Document.GetLineByOffset(this._editor.CaretOffset);
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    if (textView.ActualWidth - 32 > 0 && rect.Height > 0)
                    {
                        var Size = new Size(textView.ActualWidth - 32, rect.Height);
                        var Rect = new Rect(rect.Location, Size);
                        drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(50, 250, 250, 100)), null, Rect);
                    }
                }
            }
            catch (Exception error)
            {
                Framework.EventBus.Publish(error);
            }
        }
예제 #10
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
                return;

            textView.EnsureVisualLines();
            var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);
            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(
                    new SolidColorBrush(Color.FromArgb(0x40, 0, 0, 0xFF)), null,
                    new Rect(rect.Location, new Size(textView.ActualWidth - 32, rect.Height)));
            }
        }
        /// <summary>
        /// Draw the background line highlighting of the current line.
        /// </summary>
        /// <param name="textView"></param>
        /// <param name="drawingContext"></param>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.mEditor.Document == null)
            {
                return;
            }
            textView.EnsureVisualLines();
            var currentLine = mEditor.Document.GetLineByOffset(mEditor.CaretOffset);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(new SolidColorBrush(this.BackgroundColorBrush.Color), null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            foreach (var lineToHighlight in HighlightedLines.Where(i => textView.Document.LineCount >= i))
            {
                if (lineToHighlight <= 0)
                    continue;

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, textView.Document.GetLineByNumber(lineToHighlight), true))
                {
                    drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(100, 255, 184, 0)), null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, new TextSegment()
            {
                StartOffset = editor.Document.GetLineByOffset(editor.CaretOffset).Offset
            }))
            {
                drawingContext.DrawRoundedRectangle(
                    new SolidColorBrush(Color.FromArgb(30, 218, 165, 32)),
                    new Pen(new SolidColorBrush(Color.FromArgb(250, 0xff, 0xff, 0xff)), 1),
                    new Rect(r.Location, new Size(textView.ActualWidth, r.Height)),
                    3, 3);
            }
        }
예제 #14
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null || Line < 1)
            {
                return;
            }

            textView.EnsureVisualLines();
            var highlight   = Brushes.LightGray;
            var currentLine = _editor.Document.GetLineByNumber(Line);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(highlight, null, new Rect(rect.Location, new Size(rect.Width, rect.Height)));
            }
        }
예제 #15
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.HighlightedBreakpointLine.HasValue)
            {
                textView.EnsureVisualLines();

                var line  = _editor.Document.GetLineByNumber(_editor.HighlightedBreakpointLine.Value);
                var rects = BackgroundGeometryBuilder.GetRectsForSegment(textView, line);

                foreach (var rect in rects)
                {
                    drawingContext.DrawRectangle(_background, new Pen(_background, 1),
                                                 new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #16
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();
            foreach (var rect1 in BackgroundGeometryBuilder.GetRectsForSegment(textView, line))
            {
                Rect rect = rect1;
                rect.Width = Math.Max(rect1.Width, 5000.0); // _editor.Width-10;

                drawingContext.DrawRectangle(brush, null, new Rect(rect.Location, new Size(rect.Width, rect.Height)));
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document != null)
            {
                textView.EnsureVisualLines();

                var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);
                var lineWidth   = textView.ActualWidth + _editor.HorizontalOffset;

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    drawingContext.DrawRectangle(null, CurrentLinePen,
                                                 new Rect(rect.Location, new Size(lineWidth, rect.Height)));
                }
            }
        }
예제 #18
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (m_textEditor.Document == null || m_textBlocks == null)
            return;

              textView.EnsureVisualLines();

              foreach (TextBlock textBlock in m_textBlocks)
              {
            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, textBlock))
            {
              drawingContext.DrawRectangle(
            new SolidColorBrush(textBlock.Color), new Pen(new SolidColorBrush(textBlock.BorderColor), 1),
            rect);
            }
              }
        }
예제 #19
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();

            //var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);

            if (_xmlEditor.xDoc == null)
            {
                return;
            }


            if (textView.ActualWidth > 32)
            {
                if (HighlightSegments != null)
                {
                    foreach (ISegment obj in HighlightSegments)
                    {
                        foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, obj))
                        {
                            drawingContext.DrawRectangle(
                                new SolidColorBrush(HighlightColor), null,
                                new Rect(rect.Location, rect.Size));
                        }
                    }
                }
                if (UnderlineSegments != null)
                {
                    foreach (ISegment obj in UnderlineSegments)
                    {
                        foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, obj))
                        {
                            drawingContext.DrawLine(
                                new Pen(new SolidColorBrush(_underlineColor), 1.0),
                                new Point(rect.BottomLeft.X, rect.BottomLeft.Y),
                                new Point(rect.BottomRight.X, rect.BottomRight.Y));
                        }
                    }
                }
            }
        }
예제 #20
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            foreach (var lineToHighlight in HighlightedLines.Where(i => textView.Document.LineCount >= i))
            {
                if (lineToHighlight <= 0)
                {
                    continue;
                }

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, textView.Document.GetLineByNumber(lineToHighlight), true))
                {
                    drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(100, 255, 184, 0)), null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #21
0
 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     textView.EnsureVisualLines();
     if (_line.IsDeleted) return;
     var segment = new TextSegment
     {
         StartOffset = _line.Offset,
         EndOffset = _line.EndOffset
     };
     // ReSharper disable once RedundantArgumentDefaultValue
     foreach (var current in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment, false))
     {
         drawingContext.DrawRoundedRectangle(new SolidColorBrush(EditorOptions.Instance.HighlightedLineColor),
             new Pen(Brushes.Red, 0.0),
             new Rect(current.Location, new Size(textView.ActualWidth, current.Height)), 3.0, 3.0);
     }
 }
예제 #22
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();
            var line    = TextEditor.Document.GetLineByOffset(TextEditor.Caret.Offset);
            var segment = new TextSegment {
                StartOffset = line.Offset, EndOffset = line.EndOffset
            };

            foreach (System.Windows.Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
            {
                drawingContext.DrawRoundedRectangle(
                    new SolidColorBrush(Color.FromArgb(45, 180, 180, 180)),
                    new Pen(new SolidColorBrush(Color.FromArgb(0, 255, 255, 255)), 1),
                    new System.Windows.Rect(r.Location, new System.Windows.Size(textView.ActualWidth, r.Height)),
                    3, 3
                    );
            }
        }
예제 #23
0
        private static void DrawLine(TextView textView, DrawingContext drawingContext, int?line, Brush brush)
        {
            if (line == null || line == 0)
            {
                return;
            }

            textView.EnsureVisualLines();
            var startOffset = textView.Document.GetLineByNumber(line.Value).Offset;
            var textSegment = new ICSharpCode.AvalonEdit.Document.TextSegment {
                StartOffset = startOffset
            };

            foreach (var rectangle in BackgroundGeometryBuilder.GetRectsForSegment(textView, textSegment))
            {
                drawingContext.DrawRectangle(brush, EdgePen, new Rect(rectangle.Location, new Size(textView.ActualWidth, rectangle.Height)));
            }
        }
예제 #24
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();
            var color = new SolidColorBrush(ConfigHost.Coloring.BreakPoint.TextHighlightColor);

            color.Freeze();
            foreach (var bp in this.SolutionFileRef.BreakPoints)
            {
                var line    = this.Document.GetLineByNumber(bp.Line);
                var segment = new TextSegment {
                    StartOffset = line.Offset, EndOffset = line.EndOffset
                };
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {
                    drawingContext.DrawRectangle(color, null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #25
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (editor.Document == null || textView.ActualWidth <= 0)
            {
                return;
            }
            //
            Size size;

            textView.EnsureVisualLines();
            var currentLine = editor.Document.GetLineByOffset(editor.CaretOffset);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                size = new Size(textView.ActualWidth, rect.Height);
                drawingContext.DrawRectangle(brush, null, new Rect(rect.Location, size));
            }
        }
예제 #26
0
        /// <see cref="IBackgroundRenderer.Draw"/>
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();
            var currentLine = textView.Document.GetLineByOffset(_textArea.Caret.Offset);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(
                    new SolidColorBrush(Color.FromArgb(255, 0xFF, 0xFF, 0xE0)),
                    new Pen(new SolidColorBrush(Color.FromArgb(255, 0xF2, 0xEA, 0xEA)), 1),
                    new Rect(rect.Location, new Size(textView.ActualWidth - 2, rect.Height)));
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            //currently not used
            return;

            if (_editor.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();

            var line = _editor.Document.GetLineByNumber(LineToHighlight);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, line))
            {
                drawingContext.DrawRectangle(Brushes.LightYellow, null, new Rect(rect.Location, new Size(rect.Width, rect.Height)));
            }
        }
예제 #28
0
            public void Draw(TextView textView, DrawingContext drawingContext)
            {
                if (_editor.Document == null)
                {
                    return;
                }

                textView.EnsureVisualLines();
                var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    var rect2 = new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height));
                    if (rect2.Height > 1 && rect2.Width > 1)
                    {
                        drawingContext.DrawRectangle(_brush, null, rect2);
                    }
                }
            }
예제 #29
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView.ActualWidth == 0)
            {
                return;
            }

            textView.EnsureVisualLines();
            if (HighLightLine != null)
            {
                try
                {
                    foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, HighLightLine))
                    {
                        drawingContext.DrawRectangle(
                            new SolidColorBrush(Color.FromArgb(0x40, 0, 0, 0xFF)), null,
                            new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                    }
                }
                catch
                {
                    //Do Nothing - can happen when lines are deleted but grid still exist and shows rows
                }
            }

            // Draw line marker - this one is simple red line below the text
            foreach (ISegment seg in Segments)
            {
                IEnumerable <Rect> rects = BackgroundGeometryBuilder.GetRectsForSegment(textView, seg);
                try
                {
                    foreach (var rect in rects)
                    {
                        drawingContext.DrawLine(GetRedPen(), rect.BottomLeft, rect.BottomRight);
                        // We can draw other shapes too like below
                    }
                }
                catch
                {
                    //do nothing - can happen when lines are deleted but grid still exist and shows rows
                }
            }
        }
예제 #30
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();
            DocumentLine currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);

            //do not call GetRectsForSegment for long lines; performance is terrible
            if (currentLine.Length < 1000)
            {
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    drawingContext.DrawRectangle(
                        _brush, null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #31
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null || LineNumber == 0)
            {
                return;
            }

            textView.EnsureVisualLines();
            SolidColorBrush highlight = new(Green ? Color.FromArgb(100, 0, 176, 80) : Color.FromArgb(100, 255, 0, 0));

            DocumentLine currentLine = _editor.Document.GetLineByNumber(LineNumber);

            foreach (Rect rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(highlight, null, new Rect(new Point(0, rect.Location.Y), new Size(9999, rect.Height)));
                //Debug.WriteLine (rect);
                _breakPointArea.Children.Add(GenArrow(rect.Height, rect.Location.Y));
                break;
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Current Line

            if(lastLine != _editor.TextArea.Caret.Line) {
                var line = _editor.Document.GetLineByOffset(_editor.CaretOffset);
                var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };
                foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                    drawingContext.DrawRoundedRectangle(_lineSelection, _borderPen, new Rect(r.Location, new Size(textView.ActualWidth, r.Height)), 3, 3);
                }
            }

            #endregion

            #region Highlight Brackets

            if(_editor.TextArea.Caret.Offset > 1 && TokenHelper.BRAKETS.ContainsKey(_editor.TextArea.Document.GetCharAt(_editor.TextArea.Caret.Offset - 1))) {
                var offset = _editor.TextArea.Caret.Offset;
                var seg = _projectitem.SegmentService.QueryCodeSegmentAt(offset);
                if(seg != null && TokenHelper.BRAKETS.ContainsValue(seg.Token)) {
                    var other = seg.FindOtherBracked(true);

                    var col = other != null ? _braketMatch : _braketMatchFail;
                    var braketsegment = new TextSegment { StartOffset = seg.Range.Offset, EndOffset = seg.Range.EndOffset };
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                        drawingContext.DrawRectangle(col, _borderPen, r);
                    }

                    if(other != null) {
                        braketsegment = new TextSegment { StartOffset = other.Range.Offset, EndOffset = other.Range.EndOffset };
                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                            drawingContext.DrawRectangle(_braketMatch, _borderPen, r);
                        }
                    }
                }
            }

            #endregion
        }
예제 #33
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
            {
                return;
            }
            textView.EnsureVisualLines();
            var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);

            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(
                    new SolidColorBrush(Color.FromArgb(200, 50, 50, 50)), null,
                    new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));

                int borderThinkness = 2;
                drawingContext.DrawRectangle(
                    new SolidColorBrush(Color.FromArgb(200, 0, 0, 0)), null,
                    new Rect(new Point(rect.Location.X + borderThinkness, rect.Location.Y + borderThinkness), new Size(textView.ActualWidth - 2 * borderThinkness, rect.Height - 2 * borderThinkness)));
            }
        }
예제 #34
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();
            if (_line.IsDeleted)
            {
                return;
            }
            var segment = new TextSegment
            {
                StartOffset = _line.Offset,
                EndOffset   = _line.EndOffset
            };

            // ReSharper disable once RedundantArgumentDefaultValue
            foreach (var current in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment, false))
            {
                drawingContext.DrawRoundedRectangle(new SolidColorBrush(EditorOptions.Instance.HighlightedLineColor),
                                                    new Pen(Brushes.Red, 0.0),
                                                    new Rect(current.Location, new Size(textView.ActualWidth, current.Height)), 3.0, 3.0);
            }
        }
예제 #35
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (m_editor.Document == null)
            {
                return;
            }

            textView.EnsureVisualLines();

            foreach (var setting in RenderSettings)
            {
                var currentLine = m_editor.Document.GetLineByNumber(setting.LineNumber);

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    double drawingWidth = textView.ScrollOffset.X + textView.ActualWidth;
                    drawingContext.DrawRectangle(
                        new SolidColorBrush(setting.BgColor), null,
                        new Rect(rect.Location, new Size(drawingWidth, rect.Height)));
                }
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (this.Editor.Document == null)
            {
                return;
            }
            textView.EnsureVisualLines();
            var line    = this.Editor.Document.GetLineByOffset(this.Editor.CaretOffset);
            var segment = new TextSegment {
                StartOffset = line.Offset, EndOffset = line.EndOffset
            };
            var color = new SolidColorBrush(ConfigHost.Coloring.SelectedLine.Background);

            color.Freeze();
            var pen = new Pen(new SolidColorBrush(ConfigHost.Coloring.SelectedLine.Border), 1);

            pen.Freeze();
            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
            {
                drawingContext.DrawRectangle(color, pen, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
            }
        }
예제 #37
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {

            textView.EnsureVisualLines();
            bool odd = true;
            if (!G.AppSettings.isFixedBackgroundLines)
            if (textView.VisualLines[0].FirstDocumentLine.LineNumber % 2 == 0)
               odd = false;            
            for (int i = 0; i < textView.VisualLines.Count; i++)
            {
                //textView.LineTransformers.Add(IVisualLineTransformer)
                //textView.Options
                var segment = new TextSegment
                {
                    StartOffset = textView.VisualLines[i].FirstDocumentLine.Offset,
                    EndOffset = textView.VisualLines[i].LastDocumentLine.EndOffset
                };
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {

                    if (!odd)
                    //if (textView.VisualLines[i].FirstDocumentLine.LineNumber % 2 == 0)
                        drawingContext.DrawRectangle(scbEven,
                                                        border,
                                                        new Rect(r.Location, new Size(textView.ActualWidth, r.Height))
                                                        );
                    else
                        
                        drawingContext.DrawRectangle(scbOdd,
                                                            border,
                                                            new Rect(r.Location, new Size(textView.ActualWidth, r.Height))
                                                            );
                    if (odd) odd = false; else odd = true;
                }
            }    //foreach
        }
예제 #38
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (m_textEditor.Document == null)
            return;

              textView.EnsureVisualLines();

              var currentLine = m_textEditor.Document.GetLineByOffset(m_textEditor.CaretOffset);
              foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
              {
            drawingContext.DrawRectangle(
              new SolidColorBrush(Color.FromArgb(0xFF, 0x10, 0x10, 0x10)), null,
              new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
            Brush edgeBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x60, 0x60, 0x60));
            drawingContext.DrawRectangle(
              edgeBrush, null,
              new Rect(rect.Location, new Size(textView.ActualWidth, 1)));
            Point point = rect.Location;
            point.Offset(0, rect.Height);
            drawingContext.DrawRectangle(
              edgeBrush, null,
              new Rect(point, new Size(textView.ActualWidth, 1)));
              }
        }
예제 #39
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
                return;

            for (int i=start_line; i<start_line+no_lines; i++)
            {
                if (!(i > 0)) return;
                textView.EnsureVisualLines();
                var currentLine = _editor.Document.GetLineByNumber(i);
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    drawingContext.DrawRectangle(
                        new SolidColorBrush(Color.FromArgb(0x20, 0, 0xFF, 0)), null,
                        new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
예제 #40
0
            public void Draw(TextView textView, DrawingContext drawingContext)
            {
                if (textView.Document == null) return;

                textView.EnsureVisualLines();

                var firstLine = textView.VisualLines.First().FirstDocumentLine.LineNumber;
                int nextBlockLine = int.MaxValue;
                int blockIndex;
                Color backColor;
                MergeAlternate alt;
                MergeLocation colorLocation;

                for (blockIndex = 1; blockIndex < _view._starts.Count; blockIndex++)
                {
                  if (_view._starts[blockIndex].LineNumber > firstLine)
                  {
                nextBlockLine = _view._starts[blockIndex].LineNumber;
                blockIndex--;
                break;
                  }
                }
                if (blockIndex >= _view._starts.Count) blockIndex = _view._starts.Count - 1;

                foreach (var visLine in textView.VisualLines)
                {
                  if (visLine.FirstDocumentLine.LineNumber >= nextBlockLine)
                  {
                blockIndex++;
                nextBlockLine = (blockIndex < (_view._starts.Count - 1) ? _view._starts[blockIndex + 1].LineNumber : int.MaxValue);
                  }

                  alt = _view._starts[blockIndex].Alternate;
                  if (_view._starts[blockIndex].Alternate.Parent.Alternates.Count > 1
                && (_view.Location == MergeLocation.Output
                  || _view.Location == MergeLocation.Parent
                  || (alt.Location & MergeLocation.Parent) == 0))
                  {

                colorLocation = alt.Location & ~MergeLocation.Output;
                if (_view.Location == MergeLocation.Output)
                {
                  if ((colorLocation & MergeLocation.Right) != 0)
                  {
                backColor = GetColor(MergeLocation.Right);
                  }
                  else if ((colorLocation & MergeLocation.Parent) != 0)
                  {
                backColor = GetColor(MergeLocation.Parent);
                  }
                  else
                  {
                backColor = GetColor(MergeLocation.Left);
                  }
                }
                else
                {
                  backColor = GetColor(_view.Location);
                  if (colorLocation == (MergeLocation.Left | MergeLocation.Right)) backColor = GetColor(MergeLocation.Right);
                }

                var backgroundGeometryBuilder = new BackgroundGeometryBuilder();
                var y = visLine.VisualTop - textView.ScrollOffset.Y;
                backgroundGeometryBuilder.AddRectangle(textView, new Rect(0.0, y, textView.ActualWidth, visLine.Height));
                var geometry = backgroundGeometryBuilder.CreateGeometry();
                if (geometry != null)
                {
                  drawingContext.DrawGeometry(new SolidColorBrush(backColor), null, geometry);
                }
                  }
                }
            }
예제 #41
0
      public void Draw(TextView textView, DrawingContext drawingContext)
      {
        if (textView.Document == null) return;

        textView.EnsureVisualLines();

        Color backColor;
        foreach (var visLine in textView.VisualLines)
        {
          backColor = default(Color);
          switch (GetDiffType(visLine.FirstDocumentLine.LineNumber))
          {
            case DiffType.Add:
              backColor = this.AddColor;
              break;
            case DiffType.Change:
              backColor = Color.FromRgb(0xcc, 0xcc, 0xff);
              break;
          }

          if (backColor != default(Color))
          {
            var backgroundGeometryBuilder = new BackgroundGeometryBuilder();
            var y = visLine.VisualTop - textView.ScrollOffset.Y;
            backgroundGeometryBuilder.AddRectangle(textView, new Rect(0.0, y, textView.ActualWidth, visLine.Height));
            var geometry = backgroundGeometryBuilder.CreateGeometry();
            if (geometry != null)
            {
              drawingContext.DrawGeometry(new SolidColorBrush(backColor), null, geometry);
            }
          }
        }
      }
예제 #42
0
        public void Draw(TextView textView, DrawingContext ctx)
        {
            textView.EnsureVisualLines();

            // update first and last line
            viewportFirstLine = editor.TextArea.TextView.GetDocumentLineByVisualTop(editor.TextArea.TextView.ScrollOffset.Y);
            viewportLastLine = editor.TextArea.TextView.GetDocumentLineByVisualTop(editor.TextArea.TextView.ScrollOffset.Y + editor.ActualHeight);

            #region Draw tabs

            if (Settings.Instance.ShowTabsInEditor)
            {
                foreach (Match match in Regex.Matches(editor.Text, "\t"))
                {
                    if (!IsOffsetInsideViewport(match.Index, match.Index + 1))
                        continue;

                    var rects = BackgroundGeometryBuilder.GetRectsForSegment(editor.TextArea.TextView, new TextSegment {
                        StartOffset = match.Index,
                        Length = 1,
                    });

                    if (rects.Count() == 0)
                        continue;

                    var rect = rects.First();
                    var x1 = rect.X + 3;
                    var y1 = rect.Y + rect.Height / 2;

                    var x2 = rect.X + rect.Width - 3;
                    var y2 = y1;

                    if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 || x1 == x2)
                        continue;

                    var pen = new Pen
                    {
                        Brush = tabsColor,
                        Thickness = 0.3
                    };

                    ctx.DrawLine(pen, new Point(x1, y1), new Point(x2, y2));
                }
            }

            #endregion

            #region Draw spaces

            if (Settings.Instance.ShowSpacesInEditor)
            {
                foreach (Match match in Regex.Matches(editor.Text, " "))
                {
                    if (!IsOffsetInsideViewport(match.Index, match.Index + 1))
                        continue;

                    var point = GetPositionFromOffset(editor, VisualYPosition.LineMiddle, match.Index);

                    var x1 = point.X - editor.TextArea.TextView.ScrollOffset.X + 2;
                    var y1 = point.Y - editor.TextArea.TextView.ScrollOffset.Y;

                    var x2 = point.X - editor.TextArea.TextView.ScrollOffset.X + 4;
                    var y2 = point.Y - editor.TextArea.TextView.ScrollOffset.Y;

                    if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 || x1 == x2)
                        continue;

                    var pen = new Pen
                    {
                        Brush = spacesColor,
                        Thickness = 1
                    };

                    ctx.DrawLine(pen, new Point(x1, y1), new Point(x2, y2));
                }
            }

            #endregion

            #region Draw highlighted line

            if (Theme.Instance.HighlightLineOfCaret && editor.TextArea.IsFocused)
            {
                var line = editor.Document.GetLineByOffset(editor.CaretOffset);
                var start = GetPositionFromOffset(editor, VisualYPosition.LineTop, line.Offset);
                var end = GetPositionFromOffset(editor, VisualYPosition.LineBottom, line.Offset);

                ctx.DrawRoundedRectangle(lineOfCaret, new Pen(), new Rect(start.X, start.Y - editor.TextArea.TextView.ScrollOffset.Y, textView.ActualWidth, end.Y - start.Y), 3, 3);
            }

            #endregion

            #region Draw blocks

            foreach (var block in blocks)
            {
                if (!IsOffsetInsideViewport(block.Offset, block.Offset + block.Length))
                    continue;

                var startPosition = GetPositionFromOffset(editor, VisualYPosition.LineTop, block.Offset);
                var endPosition = GetPositionFromOffset(editor, VisualYPosition.LineBottom, block.Offset + block.Length);

                var x = startPosition.X - editor.TextArea.TextView.ScrollOffset.X;
                var y = startPosition.Y - editor.TextArea.TextView.ScrollOffset.Y;

                var width = endPosition.X - startPosition.X;
                var height = endPosition.Y - startPosition.Y;

                if (width <= 0 || height <= 0)
                    continue;

                ctx.DrawRoundedRectangle(new SolidColorBrush(block.Color), new Pen(), new Rect(x, y, width, height), 3, 3);
            }

            #endregion
        }
예제 #43
0
		private static void DrawLine(TextView textView, DrawingContext drawingContext, int? line, Brush brush)
		{
			if (line == null || line == 0)
			{
				return;
			}

			textView.EnsureVisualLines();
			var startOffset = textView.Document.GetLineByNumber(line.Value).Offset;
			var textSegment = new ICSharpCode.AvalonEdit.Document.TextSegment { StartOffset = startOffset };
			foreach (var rectangle in BackgroundGeometryBuilder.GetRectsForSegment(textView, textSegment))
			{
				drawingContext.DrawRectangle(brush, EdgePen, new Rect(rectangle.Location, new Size(textView.ActualWidth, rectangle.Height)));
			}
		}
예제 #44
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
          
            try
            {
                textView.EnsureVisualLines();
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                bool odd = true;
                if (!G.AppSettings.isFixedBackgroundLines)
                    if (textView.VisualLines.Count>0)
                    if (textView.VisualLines[0].FirstDocumentLine.LineNumber % 2 == 0)
                        odd = false;
                for (int i = 0; i < textView.VisualLines.Count; i++)
                {
                    var segment2 = new TextSegment
                    {
                        StartOffset = textView.VisualLines[i].FirstDocumentLine.Offset,
                        EndOffset = textView.VisualLines[i].LastDocumentLine.EndOffset
                    };
                    foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment2))
                    {
                        if (!odd)
                            drawingContext.DrawRectangle(scbEven, border,
                                                           new Rect(r.Location, new Size(textView.ActualWidth, r.Height)));//draw even line
                        else drawingContext.DrawRectangle(scbOdd, border,
                                                                new Rect(r.Location, new Size(textView.ActualWidth, r.Height)));//draw odd line
                        if (G.AppSettings.isShowUnderline)
                        {
                            string str = editor.Document.GetText(textView.VisualLines[i].FirstDocumentLine.Offset, textView.VisualLines[i].FirstDocumentLine.Length);
                            //if (str.Contains("<frame_end>") || str.Contains("<bmp_end>"))
                            if (Contains(str, G.AppSettings.underlineThisWords))
                            {
                                double halfPenWidth = lpen.Thickness / 2;
                                GuidelineSet guidelines = new GuidelineSet();
                                guidelines.GuidelinesX.Add(r.Left + halfPenWidth);
                                guidelines.GuidelinesX.Add(r.Right + halfPenWidth);
                                guidelines.GuidelinesY.Add(r.Top + halfPenWidth);
                                guidelines.GuidelinesY.Add(r.Bottom + halfPenWidth);
                                drawingContext.PushGuidelineSet(guidelines);
                                drawingContext.DrawLine(lpen, new Point(r.Left, r.Bottom), new Point(textView.ActualWidth, r.Bottom)); //draw underline                            
                            }
                        }
                        if (odd) odd = false; else odd = true;
                    }     //foreach
                }    //for
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                var line = editor.Document.GetLineByOffset(editor.CaretOffset);
                var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {
                    drawingContext.DrawRectangle(lgbLine, border,
                                                 new Rect(r.Location, new Size(textView.ActualWidth, r.Height))); //Draw current cursor line
                    if (G.AppSettings.isShowUnderline)
                    {
                        string str2 = editor.Document.GetText(segment);

                        if (Contains(str2, G.AppSettings.underlineThisWords))
                        {
                            double halfPenWidth = lpen.Thickness / 2;
                            GuidelineSet guidelines = new GuidelineSet();
                            guidelines.GuidelinesX.Add(r.Left + halfPenWidth);
                            guidelines.GuidelinesX.Add(r.Right + halfPenWidth);
                            guidelines.GuidelinesY.Add(r.Top + halfPenWidth);
                            guidelines.GuidelinesY.Add(r.Bottom + halfPenWidth);
                            drawingContext.PushGuidelineSet(guidelines);
                            drawingContext.DrawLine(lpen, new Point(r.Left, r.Bottom), new Point(textView.ActualWidth, r.Bottom)); //correct underline
                        }
                    }
                }
            }
            catch (Exception ex) { new wException(ex).ShowDialog(); }
        }//Draw end