Beispiel #1
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);
        }
Beispiel #2
0
 private void DrawBracketHighlight(Graphics g, Rectangle rect)
 {
     g.FillRectangle(BrushRegistry.GetBrush(Color.FromArgb(50, 0, 0, 255)), rect);
     g.DrawRectangle(Pens.Blue, rect);
 }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private void PaintFoldMarker(Graphics g, int lineNumber, Rectangle drawingRectangle)
        {
            HighlightColor colorFor                   = this.textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
            HighlightColor colorFor2                  = this.textArea.Document.HighlightingStrategy.GetColorFor("SelectedFoldLine");
            ArrayList      foldingsWithStart          = this.textArea.Document.FoldingManager.GetFoldingsWithStart(lineNumber);
            ArrayList      foldingsContainsLineNumber = this.textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(lineNumber);
            ArrayList      foldingsWithEnd            = this.textArea.Document.FoldingManager.GetFoldingsWithEnd(lineNumber);
            bool           flag  = foldingsWithStart.Count > 0;
            bool           flag2 = foldingsContainsLineNumber.Count > 0;
            bool           flag3 = foldingsWithEnd.Count > 0;
            bool           flag4 = this.SelectedFoldingFrom(foldingsWithStart);
            bool           flag5 = this.SelectedFoldingFrom(foldingsContainsLineNumber);
            bool           flag6 = this.SelectedFoldingFrom(foldingsWithEnd);
            int            num   = (int)Math.Round((double)((float)this.textArea.TextView.FontHeight * 0.57f));

            num -= num % 2;
            int num2 = drawingRectangle.Y + (drawingRectangle.Height - num) / 2;
            int num3 = drawingRectangle.X + (drawingRectangle.Width - num) / 2 + num / 2;

            if (flag)
            {
                bool flag7 = true;
                bool flag8 = false;
                foreach (FoldMarker foldMarker in foldingsWithStart)
                {
                    if (foldMarker.IsFolded)
                    {
                        flag7 = false;
                    }
                    else
                    {
                        flag8 = (foldMarker.EndLine > foldMarker.StartLine);
                    }
                }
                bool flag9 = false;
                foreach (FoldMarker foldMarker2 in foldingsWithEnd)
                {
                    if (foldMarker2.EndLine > foldMarker2.StartLine && !foldMarker2.IsFolded)
                    {
                        flag9 = true;
                    }
                }
                this.DrawFoldMarker(g, new RectangleF((float)(drawingRectangle.X + (drawingRectangle.Width - num) / 2), (float)num2, (float)num, (float)num), flag7, flag4);
                if (flag2 || flag9)
                {
                    g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, num2 - 1);
                }
                if (flag2 || flag8)
                {
                    g.DrawLine(BrushRegistry.GetPen((flag6 || (flag4 && flag7) || flag5) ? colorFor2.Color : colorFor.Color), num3, num2 + num + 1, num3, drawingRectangle.Bottom);
                    return;
                }
            }
            else
            {
                if (flag3)
                {
                    int num4 = drawingRectangle.Top + drawingRectangle.Height / 2;
                    g.DrawLine(BrushRegistry.GetPen((flag5 || flag6) ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, num4);
                    g.DrawLine(BrushRegistry.GetPen((flag5 || flag6) ? colorFor2.Color : colorFor.Color), num3, num4, num3 + num / 2, num4);
                    if (flag2)
                    {
                        g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, num4 + 1, num3, drawingRectangle.Bottom);
                        return;
                    }
                }
                else
                {
                    if (flag2)
                    {
                        g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, drawingRectangle.Bottom);
                    }
                }
            }
        }