Ejemplo n.º 1
0
        private void DrawLine(Graphics g, LineSegment line, float yPos, RectangleF margin)
        {
            float num    = 0f;
            float height = this.Font.GetHeight(g);

            this.curTabIndent = 0f;
            foreach (TextWord textWord in line.Words)
            {
                switch (textWord.Type)
                {
                case TextWordType.Word:
                {
                    g.DrawString(textWord.Word, textWord.Font, BrushRegistry.GetBrush(textWord.Color), num + margin.X, yPos);
                    SizeF sizeF = g.MeasureString(textWord.Word, textWord.Font, new SizeF(margin.Width, height * 100f), this.printingStringFormat);
                    this.Advance(ref num, ref yPos, margin.Width, sizeF.Width, height);
                    break;
                }

                case TextWordType.Space:
                    this.Advance(ref num, ref yPos, margin.Width, this.primaryTextArea.TextArea.TextView.GetWidth(' '), height);
                    break;

                case TextWordType.Tab:
                    this.Advance(ref num, ref yPos, margin.Width, (float)base.TabIndent * this.primaryTextArea.TextArea.TextView.GetWidth(' '), height);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private float DrawEOLMarker(Graphics g, Color color, Brush backBrush, float x, float y)
        {
            float width = this.GetWidth(g, '¶');

            g.FillRectangle(backBrush, new RectangleF(x, y, width, (float)this.fontHeight));
            HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("EOLMarkers");

            g.DrawString("¶", colorFor.Font, BrushRegistry.GetBrush(color), x, y, this.measureStringFormat);
            return(width);
        }
Ejemplo n.º 3
0
        private float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor, Brush backBrush)
        {
            if (word == null || word.Length == 0)
            {
                return(0f);
            }
            float width = g.MeasureString(word, font, 32768, this.measureStringFormat).Width;

            g.FillRectangle(backBrush, new RectangleF(position.X, position.Y, (float)Math.Ceiling((double)width), (float)this.FontHeight));
            g.DrawString(word, font, BrushRegistry.GetBrush(foreColor), position.X, position.Y, this.measureStringFormat);
            return(width);
        }
Ejemplo n.º 4
0
 private Brush GetMarkerBrushAt(int offset, int length, out ArrayList markers)
 {
     markers = base.Document.MarkerStrategy.GetMarkers(offset, length);
     foreach (TextMarker textMarker in markers)
     {
         if (textMarker.TextMarkerType == TextMarkerType.SolidBlock)
         {
             return(BrushRegistry.GetBrush(textMarker.Color));
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
        private Brush GetBgColorBrush(int lineNumber)
        {
            if (this.DrawLineMarkerAtLine(lineNumber))
            {
                HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("CaretMarker");
                return(BrushRegistry.GetBrush(colorFor.Color));
            }
            HighlightBackground highlightBackground = (HighlightBackground)this.textArea.Document.HighlightingStrategy.GetColorFor("DefaultBackground");
            Color color = highlightBackground.BackgroundColor;

            if (this.textArea.MotherTextAreaControl.TextEditorProperties.UseCustomLine)
            {
                color = this.textArea.Document.CustomLineManager.GetCustomColor(lineNumber, color);
            }
            return(BrushRegistry.GetBrush(color));
        }
Ejemplo n.º 6
0
        private void DrawFoldMarker(Graphics g, RectangleF rectangle, bool isOpened, bool isSelected)
        {
            HighlightColor colorFor  = this.textArea.Document.HighlightingStrategy.GetColorFor("FoldMarker");
            HighlightColor colorFor2 = this.textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
            HighlightColor colorFor3 = this.textArea.Document.HighlightingStrategy.GetColorFor("SelectedFoldLine");
            Rectangle      rect      = new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);

            g.FillRectangle(BrushRegistry.GetBrush(colorFor.BackgroundColor), rect);
            g.DrawRectangle(BrushRegistry.GetPen(isSelected ? colorFor3.Color : colorFor.Color), rect);
            int num  = (int)Math.Round((double)rectangle.Height / 8.0) + 1;
            int num2 = rect.Height / 2 + rect.Height % 2;

            g.DrawLine(BrushRegistry.GetPen(colorFor2.BackgroundColor), rectangle.X + (float)num, rectangle.Y + (float)num2, rectangle.X + rectangle.Width - (float)num, rectangle.Y + (float)num2);
            if (!isOpened)
            {
                g.DrawLine(BrushRegistry.GetPen(colorFor2.BackgroundColor), rectangle.X + (float)num2, rectangle.Y + (float)num, rectangle.X + (float)num2, rectangle.Y + rectangle.Height - (float)num);
            }
        }
Ejemplo n.º 7
0
        private float PaintFoldingText(Graphics g, int lineNumber, float physicalXPos, Rectangle lineRectangle, string text, bool drawSelected)
        {
            HighlightColor colorFor   = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection");
            Brush          brush      = drawSelected ? BrushRegistry.GetBrush(colorFor.BackgroundColor) : this.GetBgColorBrush(lineNumber);
            Brush          brush2     = this.textArea.Enabled ? brush : SystemBrushes.InactiveBorder;
            float          width      = g.MeasureString(text, this.textArea.Font, 2147483647, this.measureStringFormat).Width;
            RectangleF     rectangleF = new RectangleF(physicalXPos, (float)lineRectangle.Y, width, (float)(lineRectangle.Height - 1));

            g.FillRectangle(brush2, rectangleF);
            this.physicalColumn += text.Length;
            g.DrawString(text, this.textArea.Font, BrushRegistry.GetBrush(drawSelected ? colorFor.Color : Color.Gray), rectangleF, this.measureStringFormat);
            g.DrawRectangle(BrushRegistry.GetPen(drawSelected ? Color.DarkGray : Color.Gray), rectangleF.X, rectangleF.Y, rectangleF.Width, rectangleF.Height);
            float num = (float)Math.Ceiling((double)(physicalXPos + width));

            if ((double)(num - (physicalXPos + width)) < 0.5)
            {
                num += 1f;
            }
            return(num);
        }
Ejemplo n.º 8
0
        private void DrawTabMarker(Graphics g, Color color, float x, float y)
        {
            HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers");

            g.DrawString("»", colorFor.Font, BrushRegistry.GetBrush(color), x, y, this.measureStringFormat);
        }
Ejemplo n.º 9
0
 private void DrawBracketHighlight(Graphics g, Rectangle rect)
 {
     g.FillRectangle(BrushRegistry.GetBrush(Color.FromArgb(50, 0, 0, 255)), rect);
     g.DrawRectangle(Pens.Blue, rect);
 }
Ejemplo n.º 10
0
        private float PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, float physicalXPos)
        {
            bool           flag            = this.DrawLineMarkerAtLine(lineNumber);
            Brush          bgColorBrush    = this.GetBgColorBrush(lineNumber);
            Brush          brush           = this.textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;
            HighlightColor colorFor        = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection");
            ColumnRange    selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
            HighlightColor colorFor2       = this.textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers");
            HighlightColor colorFor3       = this.textArea.Document.HighlightingStrategy.GetColorFor("SpaceMarkers");
            float          width           = this.GetWidth(g, ' ');
            LineSegment    lineSegment     = this.textArea.Document.GetLineSegment(lineNumber);
            int            num             = startColumn;
            Brush          brush2          = BrushRegistry.GetBrush(colorFor.BackgroundColor);
            Brush          brush3          = brush;

            if (lineSegment.Words != null)
            {
                int num2 = 0;
                int num3 = 0;
                while (num2 < lineSegment.Words.Count && num3 < startColumn)
                {
                    TextWord textWord = (TextWord)lineSegment.Words[num2];
                    if (textWord.Type == TextWordType.Tab)
                    {
                        num3++;
                    }
                    else
                    {
                        if (textWord.Type == TextWordType.Space)
                        {
                            num3++;
                        }
                        else
                        {
                            num3 += textWord.Length;
                        }
                    }
                    num2++;
                }
                int num4 = num2;
                while (num4 < lineSegment.Words.Count && num < endColumn)
                {
                    ArrayList markers = base.Document.MarkerStrategy.GetMarkers(lineSegment.Offset + num3);
                    foreach (TextMarker textMarker in markers)
                    {
                        if (textMarker.TextMarkerType == TextMarkerType.SolidBlock)
                        {
                            brush3 = BrushRegistry.GetBrush(textMarker.Color);
                            break;
                        }
                    }
                    TextWord textWord2 = (TextWord)lineSegment.Words[num4];
                    switch (textWord2.Type)
                    {
                    case TextWordType.Word:
                    {
                        string word          = textWord2.Word;
                        float  num5          = physicalXPos;
                        Brush  markerBrushAt = this.GetMarkerBrushAt(lineSegment.Offset + num, word.Length, out markers);
                        Brush  backBrush;
                        if (!flag && markerBrushAt != null)
                        {
                            backBrush = markerBrushAt;
                        }
                        else
                        {
                            if (!flag && textWord2.SyntaxColor.HasBackground)
                            {
                                backBrush = BrushRegistry.GetBrush(textWord2.SyntaxColor.BackgroundColor);
                            }
                            else
                            {
                                backBrush = brush3;
                            }
                        }
                        if (ColumnRange.WholeColumn.Equals(selectionAtLine) || (selectionAtLine.EndColumn - 1 >= word.Length + num && selectionAtLine.StartColumn <= num))
                        {
                            physicalXPos += this.DrawDocumentWord(g, word, new PointF(physicalXPos, (float)lineRectangle.Y), textWord2.Font, colorFor.HasForgeground ? colorFor.Color : textWord2.Color, brush2);
                        }
                        else
                        {
                            if (ColumnRange.NoColumn.Equals(selectionAtLine))
                            {
                                physicalXPos += this.DrawDocumentWord(g, word, new PointF(physicalXPos, (float)lineRectangle.Y), textWord2.Font, textWord2.Color, backBrush);
                            }
                            else
                            {
                                int num6 = Math.Min(word.Length, Math.Max(0, selectionAtLine.StartColumn - num));
                                int num7 = Math.Max(num6, Math.Min(word.Length, selectionAtLine.EndColumn - num));
                                physicalXPos += this.DrawDocumentWord(g, word.Substring(0, num6), new PointF(physicalXPos, (float)lineRectangle.Y), textWord2.Font, textWord2.Color, backBrush);
                                physicalXPos += this.DrawDocumentWord(g, word.Substring(num6, num7 - num6), new PointF(physicalXPos, (float)lineRectangle.Y), textWord2.Font, colorFor.HasForgeground ? colorFor.Color : textWord2.Color, brush2);
                                physicalXPos += this.DrawDocumentWord(g, word.Substring(num7), new PointF(physicalXPos, (float)lineRectangle.Y), textWord2.Font, textWord2.Color, backBrush);
                            }
                        }
                        foreach (TextMarker textMarker2 in markers)
                        {
                            if (textMarker2.TextMarkerType != TextMarkerType.SolidBlock)
                            {
                                this.DrawMarker(g, textMarker2, new RectangleF(num5, (float)lineRectangle.Y, physicalXPos - num5, (float)lineRectangle.Height));
                            }
                        }
                        if (this.highlight != null && ((this.highlight.OpenBrace.Y == lineNumber && this.highlight.OpenBrace.X == num) || (this.highlight.CloseBrace.Y == lineNumber && this.highlight.CloseBrace.X == num)))
                        {
                            this.DrawBracketHighlight(g, new Rectangle((int)num5, lineRectangle.Y, (int)(physicalXPos - num5) - 1, lineRectangle.Height - 1));
                        }
                        this.physicalColumn += word.Length;
                        num += word.Length;
                        break;
                    }

                    case TextWordType.Space:
                    {
                        RectangleF rectangleF = new RectangleF(physicalXPos, (float)lineRectangle.Y, (float)Math.Ceiling((double)width), (float)lineRectangle.Height);
                        Brush      brush4;
                        if (ColumnRange.WholeColumn.Equals(selectionAtLine) || (num >= selectionAtLine.StartColumn && num < selectionAtLine.EndColumn))
                        {
                            brush4 = brush2;
                        }
                        else
                        {
                            Brush markerBrushAt2 = this.GetMarkerBrushAt(lineSegment.Offset + num, 1, out markers);
                            if (!flag && markerBrushAt2 != null)
                            {
                                brush4 = markerBrushAt2;
                            }
                            else
                            {
                                if (!flag && textWord2.SyntaxColor != null && textWord2.SyntaxColor.HasBackground)
                                {
                                    brush4 = BrushRegistry.GetBrush(textWord2.SyntaxColor.BackgroundColor);
                                }
                                else
                                {
                                    brush4 = brush3;
                                }
                            }
                        }
                        g.FillRectangle(brush4, rectangleF);
                        if (base.TextEditorProperties.ShowSpaces)
                        {
                            this.DrawSpaceMarker(g, colorFor3.Color, physicalXPos, (float)lineRectangle.Y);
                        }
                        foreach (TextMarker marker in markers)
                        {
                            this.DrawMarker(g, marker, rectangleF);
                        }
                        physicalXPos += width;
                        num++;
                        this.physicalColumn++;
                        break;
                    }

                    case TextWordType.Tab:
                    {
                        int num8 = this.physicalColumn;
                        this.physicalColumn += base.TextEditorProperties.TabIndent;
                        this.physicalColumn  = this.physicalColumn / base.TextEditorProperties.TabIndent * base.TextEditorProperties.TabIndent;
                        float      num9        = (float)(this.physicalColumn - num8) * width;
                        RectangleF rectangleF2 = new RectangleF(physicalXPos, (float)lineRectangle.Y, (float)Math.Ceiling((double)num9), (float)lineRectangle.Height);
                        Brush      brush4;
                        if (ColumnRange.WholeColumn.Equals(selectionAtLine) || (num >= selectionAtLine.StartColumn && num <= selectionAtLine.EndColumn - 1))
                        {
                            brush4 = brush2;
                        }
                        else
                        {
                            Brush markerBrushAt3 = this.GetMarkerBrushAt(lineSegment.Offset + num, 1, out markers);
                            if (!flag && markerBrushAt3 != null)
                            {
                                brush4 = markerBrushAt3;
                            }
                            else
                            {
                                if (!flag && textWord2.SyntaxColor != null && textWord2.SyntaxColor.HasBackground)
                                {
                                    brush4 = BrushRegistry.GetBrush(textWord2.SyntaxColor.BackgroundColor);
                                }
                                else
                                {
                                    brush4 = brush3;
                                }
                            }
                        }
                        g.FillRectangle(brush4, rectangleF2);
                        if (base.TextEditorProperties.ShowTabs)
                        {
                            this.DrawTabMarker(g, colorFor2.Color, physicalXPos, (float)lineRectangle.Y);
                        }
                        foreach (TextMarker marker2 in markers)
                        {
                            this.DrawMarker(g, marker2, rectangleF2);
                        }
                        physicalXPos += num9;
                        num++;
                        break;
                    }
                    }
                    num4++;
                }
            }
            return(physicalXPos);
        }
Ejemplo n.º 11
0
        private void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle)
        {
            Brush bgColorBrush = this.GetBgColorBrush(lineNumber);
            Brush brush        = this.textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;

            if (lineNumber >= this.textArea.Document.TotalNumberOfLines)
            {
                g.FillRectangle(brush, lineRectangle);
                if (base.TextEditorProperties.ShowInvalidLines)
                {
                    this.DrawInvalidLineMarker(g, (float)lineRectangle.Left, (float)lineRectangle.Top);
                }
                if (base.TextEditorProperties.ShowVerticalRuler)
                {
                    this.DrawVerticalRuler(g, lineRectangle);
                }
                return;
            }
            float num  = (float)lineRectangle.X;
            int   num2 = 0;

            this.physicalColumn = 0;
            if (base.TextEditorProperties.EnableFolding)
            {
                while (true)
                {
                    ArrayList foldedFoldingsWithStartAfterColumn = this.textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, num2 - 1);
                    if (foldedFoldingsWithStartAfterColumn == null || foldedFoldingsWithStartAfterColumn.Count <= 0)
                    {
                        break;
                    }
                    FoldMarker foldMarker = (FoldMarker)foldedFoldingsWithStartAfterColumn[0];
                    foreach (FoldMarker foldMarker2 in foldedFoldingsWithStartAfterColumn)
                    {
                        if (foldMarker2.StartColumn < foldMarker.StartColumn)
                        {
                            foldMarker = foldMarker2;
                        }
                    }
                    foldedFoldingsWithStartAfterColumn.Clear();
                    num        = this.PaintLinePart(g, lineNumber, num2, foldMarker.StartColumn, lineRectangle, num);
                    num2       = foldMarker.EndColumn;
                    lineNumber = foldMarker.EndLine;
                    ColumnRange selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                    bool        drawSelected    = ColumnRange.WholeColumn.Equals(selectionAtLine) || (foldMarker.StartColumn >= selectionAtLine.StartColumn && foldMarker.EndColumn <= selectionAtLine.EndColumn);
                    num = this.PaintFoldingText(g, lineNumber, num, lineRectangle, foldMarker.FoldText, drawSelected);
                }
                if (lineNumber < this.textArea.Document.TotalNumberOfLines)
                {
                    num = this.PaintLinePart(g, lineNumber, num2, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, num);
                }
            }
            else
            {
                num = this.PaintLinePart(g, lineNumber, 0, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, num);
            }
            if (lineNumber < this.textArea.Document.TotalNumberOfLines)
            {
                ColumnRange    selectionAtLine2 = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                LineSegment    lineSegment      = this.textArea.Document.GetLineSegment(lineNumber);
                HighlightColor colorFor         = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection");
                float          width            = this.GetWidth(g, ' ');
                bool           flag             = selectionAtLine2.EndColumn > lineSegment.Length || ColumnRange.WholeColumn.Equals(selectionAtLine2);
                if (base.TextEditorProperties.ShowEOLMarker)
                {
                    HighlightColor colorFor2 = this.textArea.Document.HighlightingStrategy.GetColorFor("EOLMarkers");
                    num += this.DrawEOLMarker(g, colorFor2.Color, flag ? bgColorBrush : brush, num, (float)lineRectangle.Y);
                }
                else
                {
                    if (flag)
                    {
                        g.FillRectangle(BrushRegistry.GetBrush(colorFor.BackgroundColor), new RectangleF(num, (float)lineRectangle.Y, width, (float)lineRectangle.Height));
                        num += width;
                    }
                }
                Brush brush2 = (flag && base.TextEditorProperties.AllowCaretBeyondEOL) ? bgColorBrush : brush;
                g.FillRectangle(brush2, new RectangleF(num, (float)lineRectangle.Y, (float)lineRectangle.Width - num + (float)lineRectangle.X, (float)lineRectangle.Height));
            }
            if (base.TextEditorProperties.ShowVerticalRuler)
            {
                this.DrawVerticalRuler(g, lineRectangle);
            }
        }