示例#1
0
        public override void Paint(Graphics g, Rectangle rect)
        {
            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return;
            }
            var lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
            var defaultColor           = textArea.Document.HighlightingStrategy.GetColorFor("Default");


            for (var y = 0;
                 y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) /
                 textArea.TextView.FontHeight + 1;
                 ++y)
            {
                var markerRectangle = new Rectangle(DrawingPosition.X,
                                                    DrawingPosition.Top + y * textArea.TextView.FontHeight -
                                                    textArea.TextView.VisibleLineDrawingRemainder,
                                                    DrawingPosition.Width,
                                                    textArea.TextView.FontHeight);

                if (rect.IntersectsWith(markerRectangle))
                {
                    // draw dotted separator line
                    if (textArea.Document.TextEditorProperties.ShowLineNumbers)
                    {
                        g.FillRectangle(
                            BrushRegistry.GetBrush(defaultColor.HasBackground
                                ? defaultColor.BackgroundColor
                                : textArea.BackColor),
                            markerRectangle);
                    }

                    //g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder),
                    //                markerRectangle);

                    //g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color),
                    //           base.drawingPosition.X,
                    //           markerRectangle.Y,
                    //           base.drawingPosition.X,
                    //           markerRectangle.Bottom);
                    else
                    {
                        g.FillRectangle(
                            BrushRegistry.GetBrush(textArea.Enabled
                                ? lineNumberPainterColor.BackgroundColor
                                : SystemColors.InactiveBorder), markerRectangle);
                    }

                    var currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y);
                    if (currentLine < textArea.Document.TotalNumberOfLines)
                    {
                        PaintFoldMarker(g, currentLine, markerRectangle);
                    }
                }
            }
        }
示例#2
0
        public static float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)
        {
            if (word == null || word.Length == 0)
            {
                return(0f);
            }
            var wordSize = g.MeasureString(word, font, 32768, sf);

            g.DrawString(word,
                         font,
                         BrushRegistry.GetBrush(foreColor),
                         position,
                         sf);
            return(wordSize.Width);
        }
示例#3
0
        public override void Paint(Graphics g, Rectangle rect)
        {
            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return;
            }
            var lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
            var fontHeight             = textArea.TextView.FontHeight;
            var fillBrush = textArea.Enabled
                ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor)
                : SystemBrushes.InactiveBorder;
            var drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color);

            for (var y = 0;
                 y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1;
                 ++y)
            {
                var ypos = drawingPosition.Y + fontHeight * y - textArea.TextView.VisibleLineDrawingRemainder;
                var backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight);
                if (rect.IntersectsWith(backgroundRectangle))
                {
                    g.FillRectangle(fillBrush, backgroundRectangle);
                    var curLine =
                        textArea.Document.GetFirstLogicalLine(
                            textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);

                    if (curLine < textArea.Document.TotalNumberOfLines)
                    {
                        g.DrawString((curLine + 1).ToString(),
                                     lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer),
                                     drawBrush,
                                     backgroundRectangle,
                                     numberStringFormat);
                    }
                }
            }
        }