public override void Paint(Graphics g, Rectangle rect)
        {
            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return;
            }
            HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
            int            fontHeight             = textArea.TextView.FontHeight;
            Brush          fillBrush = textArea.Enabled ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor) : SystemBrushes.InactiveBorder;
            Brush          drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color);

            for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y)
            {
                int       ypos = drawingPosition.Y + fontHeight * y - textArea.TextView.VisibleLineDrawingRemainder;
                Rectangle backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight);
                if (!rect.IntersectsWith(backgroundRectangle))
                {
                    continue;
                }
                g.FillRectangle(fillBrush, backgroundRectangle);
                int 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);
                }
            }
        }
示例#2
0
        public static float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)
        {
            if (string.IsNullOrEmpty(word))
            {
                return(0f);
            }
            SizeF 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;
            }
            HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

            for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y)
            {
                Rectangle 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(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);
                    }

                    int currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y);
                    if (currentLine < textArea.Document.TotalNumberOfLines)
                    {
                        PaintFoldMarker(g, currentLine, markerRectangle);
                    }
                }
            }
        }
        void DrawLine(Graphics g, LineSegment line, float yPos, RectangleF margin)
        {
            float xPos       = 0;
            float fontHeight = Font.GetHeight(g);

//			bool  gotNonWhitespace = false;
            curTabIndent = 0;

            FontContainer fontContainer = TextEditorProperties.FontContainer;

            foreach (TextWord word in line.Words)
            {
                switch (word.Type)
                {
                case TextWordType.Space:
                    Advance(ref xPos, ref yPos, margin.Width, primaryTextArea.TextArea.TextView.SpaceWidth, fontHeight);
//						if (!gotNonWhitespace) {
//							curTabIndent = xPos;
//						}
                    break;

                case TextWordType.Tab:
                    Advance(ref xPos, ref yPos, margin.Width, TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth, fontHeight);
//						if (!gotNonWhitespace) {
//							curTabIndent = xPos;
//						}
                    break;

                case TextWordType.Word:
//						if (!gotNonWhitespace) {
//							gotNonWhitespace = true;
//							curTabIndent    += TabIndent * primaryTextArea.TextArea.TextView.GetWidth(' ');
//						}
                    g.DrawString(word.Word, word.GetFont(fontContainer), BrushRegistry.GetBrush(word.Color), xPos + margin.X, yPos);
                    SizeF drawingSize = g.MeasureString(word.Word, word.GetFont(fontContainer), new SizeF(margin.Width, fontHeight * 100), printingStringFormat);
                    Advance(ref xPos, ref yPos, margin.Width, drawingSize.Width, fontHeight);
                    break;
                }
            }
        }