Exemplo n.º 1
0
        void DrawFoldMarker(Graphics g, RectangleF rectangle, bool isOpened, bool isSelected)
        {
            HighlightColor foldMarkerColor  = textArea.Document.HighlightingStrategy.GetColorFor("FoldMarker");
            HighlightColor foldLineColor    = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
            HighlightColor selectedFoldLine = textArea.Document.HighlightingStrategy.GetColorFor("SelectedFoldLine");

            Rectangle intRect = new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);

            g.FillRectangle(BrushRegistry.GetBrush(foldMarkerColor.BackgroundColor), intRect);
            g.DrawRectangle(BrushRegistry.GetPen(isSelected ? selectedFoldLine.Color : foldMarkerColor.Color), intRect);

            int space = (int)Math.Round(((double)rectangle.Height) / 8d) + 1;
            int mid   = intRect.Height / 2 + intRect.Height % 2;

            g.DrawLine(BrushRegistry.GetPen(foldLineColor.BackgroundColor),
                       rectangle.X + space,
                       rectangle.Y + mid,
                       rectangle.X + rectangle.Width - space,
                       rectangle.Y + mid);

            if (!isOpened)
            {
                g.DrawLine(BrushRegistry.GetPen(foldLineColor.BackgroundColor),
                           rectangle.X + mid,
                           rectangle.Y + space,
                           rectangle.X + mid,
                           rectangle.Y + rectangle.Height - space);
            }
        }
Exemplo n.º 2
0
        public static float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)
        {
            if (word == null || word.Length == 0)
            {
                return(0f);
            }
            SizeF wordSize = g.MeasureString(word, font, 32768, sf);

            g.DrawString(word,
                         font,
                         BrushRegistry.GetBrush(foreColor),
                         position,
                         sf);
            return(wordSize.Width);
        }
Exemplo n.º 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");
            HighlightColor foldLineColor          = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");


            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),
                                        new Rectangle(markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));

                        g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color, lineNumberPainterColor.BackgroundColor),
                                   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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        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;
                }
            }
        }