public void ClosedOpen_Valid(string familyName)
        {
            var range = ColumnRange.ClosedOpen(familyName, "a", "z");

            Assert.Equal(familyName, range.FamilyName);
            Assert.Equal("a", range.StartQualifierClosed.ToStringUtf8());
            Assert.True(range.StartQualifierOpen.IsEmpty);
            Assert.True(range.EndQualifierClosed.IsEmpty);
            Assert.Equal("z", range.EndQualifierOpen.ToStringUtf8());

            range = ColumnRange.ClosedOpen(familyName, null, new BigtableByteString(0x12, 0xFE));
            Assert.Equal(familyName, range.FamilyName);
            Assert.True(range.StartQualifierClosed.IsEmpty);
            Assert.True(range.StartQualifierOpen.IsEmpty);
            Assert.True(range.EndQualifierClosed.IsEmpty);
            Assert.Equal(new byte[] { 0x12, 0xFE }, range.EndQualifierOpen.ToByteArray());

            range = ColumnRange.ClosedOpen(familyName, ByteString.CopyFrom(0x00, 0x01, 0xFF), null);
            Assert.Equal(familyName, range.FamilyName);
            Assert.Equal(new byte[] { 0x00, 0x01, 0xFF }, range.StartQualifierClosed.ToByteArray());
            Assert.True(range.StartQualifierOpen.IsEmpty);
            Assert.True(range.EndQualifierClosed.IsEmpty);
            Assert.True(range.EndQualifierOpen.IsEmpty);

            range = ColumnRange.ClosedOpen(familyName, null, null);
            Assert.Equal(familyName, range.FamilyName);
            Assert.True(range.StartQualifierClosed.IsEmpty);
            Assert.True(range.StartQualifierOpen.IsEmpty);
            Assert.True(range.EndQualifierClosed.IsEmpty);
            Assert.True(range.EndQualifierOpen.IsEmpty);
        }
        // [END bigtable_filters_limit_col_qualifier_regex]

        // [START bigtable_filters_limit_col_range]
        /// <summary>
        /// /// Read using a qualifer range filter from an existing table.
        ///</summary>
        /// <param name="projectId">Your Google Cloud Project ID.</param>
        /// <param name="instanceId">Your Google Cloud Bigtable Instance ID.</param>
        /// <param name="tableId">Your Google Cloud Bigtable table ID.</param>

        public string filterLimitColRange(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
        {
            // A filter that matches cells whose column qualifiers are between data_plan_01gb and
            // data_plan_10gb in the column family cell_plan
            RowFilter filter = RowFilters.ColumnRange(ColumnRange.ClosedOpen("cell_plan", "data_plan_01gb", "data_plan_10gb"));

            return(readFilter(projectId, instanceId, tableId, filter));
        }
        public void ColumnRange()
        {
            var range = new ColumnRange
            {
                StartQualifierClosed = ByteString.CopyFromUtf8("a"),
                EndQualifierOpen     = ByteString.CopyFromUtf8("z")
            };
            var filter = RowFilters.ColumnRange(range);

            Assert.Equal(range, filter.ColumnRangeFilter);
        }
Example #4
0
        float PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, float physicalXPos)
        {
            bool  drawLineMarker  = DrawLineMarkerAtLine(lineNumber);
            Brush bgColorBrush    = GetBgColorBrush(lineNumber);
            Brush backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;

            HighlightColor selectionColor   = textArea.Document.HighlightingStrategy.GetColorFor("Selection");
            ColumnRange    selectionRange   = textArea.SelectionManager.GetSelectionAtLine(lineNumber);
            HighlightColor tabMarkerColor   = textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers");
            HighlightColor spaceMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor("SpaceMarkers");

            float spaceWidth = GetWidth(g, ' ');

            LineSegment currentLine = textArea.Document.GetLineSegment(lineNumber);

            int logicalColumn = startColumn;

            Brush selectionBackgroundBrush  = BrushRegistry.GetBrush(selectionColor.BackgroundColor);
            Brush unselectedBackgroundBrush = backgroundBrush;

            if (currentLine.Words != null)
            {
                int startword = 0;
                // search the first word after startColumn and update physicalColumn if a word is Tab
                int wordOffset = 0;
                for (; startword < currentLine.Words.Count; ++startword)
                {
                    if (wordOffset >= startColumn)
                    {
                        break;
                    }
                    TextWord currentWord = ((TextWord)currentLine.Words[startword]);
                    if (currentWord.Type == TextWordType.Tab)
                    {
                        ++wordOffset;
                    }
                    else if (currentWord.Type == TextWordType.Space)
                    {
                        ++wordOffset;
                    }
                    else
                    {
                        wordOffset += currentWord.Length;
                    }
                }


                for (int i = startword; i < currentLine.Words.Count; ++i)
                {
                    // if already all words before endColumn are drawen: break
                    if (logicalColumn >= endColumn)
                    {
                        break;
                    }

                    ArrayList markers = Document.MarkerStrategy.GetMarkers(currentLine.Offset + wordOffset);
                    foreach (TextMarker marker in markers)
                    {
                        if (marker.TextMarkerType == TextMarkerType.SolidBlock)
                        {
//							if (unselectedBackgroundBrush != null) {
//								unselectedBackgroundBrush.Dispose();
//							}
                            unselectedBackgroundBrush = BrushRegistry.GetBrush(marker.Color);
                            break;
                        }
                    }
                    // Clear old marker arrary


                    // TODO: cut the word if startColumn or endColimn is in the word;
                    // needed for foldings wich can start or end in the middle of a word
                    TextWord currentWord = ((TextWord)currentLine.Words[i]);
                    switch (currentWord.Type)
                    {
                    case TextWordType.Space:
                        RectangleF spaceRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(spaceWidth), lineRectangle.Height);

                        Brush spaceBackgroundBrush;

                        if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn < selectionRange.EndColumn)
                        {
                            spaceBackgroundBrush = selectionBackgroundBrush;
                        }
                        else
                        {
                            Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1);
                            if (!drawLineMarker && markerBrush != null)
                            {
                                spaceBackgroundBrush = markerBrush;
                            }
                            else if (!drawLineMarker && currentWord.SyntaxColor != null && currentWord.SyntaxColor.HasBackground)
                            {
                                spaceBackgroundBrush = BrushRegistry.GetBrush(currentWord.SyntaxColor.BackgroundColor);
                            }
                            else
                            {
                                spaceBackgroundBrush = unselectedBackgroundBrush;
                            }
                        }
                        g.FillRectangle(spaceBackgroundBrush, spaceRectangle);

                        if (TextEditorProperties.ShowSpaces)
                        {
                            DrawSpaceMarker(g, spaceMarkerColor.Color, physicalXPos, lineRectangle.Y);
                        }
                        foreach (TextMarker marker in markers)
                        {
                            DrawMarker(g, marker, spaceRectangle);
                        }

                        physicalXPos += spaceWidth;

                        ++logicalColumn;
                        ++physicalColumn;
                        break;

                    case TextWordType.Tab:

                        int oldPhysicalColumn = physicalColumn;
                        physicalColumn += TextEditorProperties.TabIndent;
                        physicalColumn  = (physicalColumn / TextEditorProperties.TabIndent) * TextEditorProperties.TabIndent;
                        float      tabWidth     = (physicalColumn - oldPhysicalColumn) * spaceWidth;
                        RectangleF tabRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(tabWidth), lineRectangle.Height);

                        if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn <= selectionRange.EndColumn - 1)
                        {
                            spaceBackgroundBrush = selectionBackgroundBrush;
                        }
                        else
                        {
                            Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1);
                            if (!drawLineMarker && markerBrush != null)
                            {
                                spaceBackgroundBrush = markerBrush;
                            }
                            else if (!drawLineMarker && currentWord.SyntaxColor != null && currentWord.SyntaxColor.HasBackground)
                            {
                                spaceBackgroundBrush = BrushRegistry.GetBrush(currentWord.SyntaxColor.BackgroundColor);
                            }
                            else
                            {
                                spaceBackgroundBrush = unselectedBackgroundBrush;
                            }
                        }
                        g.FillRectangle(spaceBackgroundBrush, tabRectangle);

                        if (TextEditorProperties.ShowTabs)
                        {
                            DrawTabMarker(g, tabMarkerColor.Color, physicalXPos, lineRectangle.Y);
                        }

                        foreach (TextMarker marker in markers)
                        {
                            DrawMarker(g, marker, tabRectangle);
                        }

                        physicalXPos += tabWidth;

                        ++logicalColumn;
                        break;

                    case TextWordType.Word:
                        string word    = currentWord.Word;
                        float  lastPos = physicalXPos;

                        Brush bgMarkerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, word.Length);
                        Brush wordBackgroundBrush;
                        if (!drawLineMarker && bgMarkerBrush != null)
                        {
                            wordBackgroundBrush = bgMarkerBrush;
                        }
                        else if (!drawLineMarker && currentWord.SyntaxColor.HasBackground)
                        {
                            wordBackgroundBrush = BrushRegistry.GetBrush(currentWord.SyntaxColor.BackgroundColor);
                        }
                        else
                        {
                            wordBackgroundBrush = unselectedBackgroundBrush;
                        }


                        if (ColumnRange.WholeColumn.Equals(selectionRange) || selectionRange.EndColumn - 1 >= word.Length + logicalColumn &&
                            selectionRange.StartColumn <= logicalColumn)
                        {
                            physicalXPos += DrawDocumentWord(g,
                                                             word,
                                                             new PointF(physicalXPos, lineRectangle.Y),
                                                             currentWord.Font,
                                                             selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color,
                                                             selectionBackgroundBrush);
                        }
                        else
                        {
                            if (ColumnRange.NoColumn.Equals(selectionRange) /* || selectionRange.StartColumn > logicalColumn + word.Length || selectionRange.EndColumn  - 1 <= logicalColumn */)
                            {
                                physicalXPos += DrawDocumentWord(g,
                                                                 word,
                                                                 new PointF(physicalXPos, lineRectangle.Y),
                                                                 currentWord.Font,
                                                                 currentWord.Color,
                                                                 wordBackgroundBrush);
                            }
                            else
                            {
                                int offset1 = Math.Min(word.Length, Math.Max(0, selectionRange.StartColumn - logicalColumn));
                                int offset2 = Math.Max(offset1, Math.Min(word.Length, selectionRange.EndColumn - logicalColumn));

                                physicalXPos += DrawDocumentWord(g,
                                                                 word.Substring(0, offset1),
                                                                 new PointF(physicalXPos, lineRectangle.Y),
                                                                 currentWord.Font,
                                                                 currentWord.Color,
                                                                 wordBackgroundBrush);

                                physicalXPos += DrawDocumentWord(g,
                                                                 word.Substring(offset1, offset2 - offset1),
                                                                 new PointF(physicalXPos, lineRectangle.Y),
                                                                 currentWord.Font,
                                                                 selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color,
                                                                 selectionBackgroundBrush);

                                physicalXPos += DrawDocumentWord(g,
                                                                 word.Substring(offset2),
                                                                 new PointF(physicalXPos, lineRectangle.Y),
                                                                 currentWord.Font,
                                                                 currentWord.Color,
                                                                 wordBackgroundBrush);
                            }
                        }
//							if (markerBrush != null) {
//								markerBrush.Dispose();
//							}
                        foreach (TextMarker marker in markers)
                        {
                            if (marker.TextMarkerType != TextMarkerType.SolidBlock)
                            {
                                DrawMarker(g, marker, new RectangleF(lastPos, lineRectangle.Y, (physicalXPos - lastPos), lineRectangle.Height));
                            }
                        }

                        // draw bracket highlight
                        if (highlight != null)
                        {
                            if (highlight.OpenBrace.Y == lineNumber && highlight.OpenBrace.X == logicalColumn ||
                                highlight.CloseBrace.Y == lineNumber && highlight.CloseBrace.X == logicalColumn)
                            {
                                DrawBracketHighlight(g, new Rectangle((int)lastPos, lineRectangle.Y, (int)(physicalXPos - lastPos) - 1, lineRectangle.Height - 1));
                            }
                        }
                        physicalColumn += word.Length;
                        logicalColumn  += word.Length;
                        break;
                    }
                    markers.Clear();
                }
            }

//			if (bgColorBrush != null) {
//				bgColorBrush.Dispose();
//				bgColorBrush = null;
//			}
//
//			if (selectionBackgroundBrush != null) {
//				selectionBackgroundBrush.Dispose();
//				selectionBackgroundBrush = null;
//			}
//
//			if (unselectedBackgroundBrush != null) {
//				unselectedBackgroundBrush.Dispose();
//				unselectedBackgroundBrush = null;
//			}

            return(physicalXPos);
        }
Example #5
0
        void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle)
        {
            Debug.Assert(lineNumber >= 0);
            Brush bgColorBrush    = GetBgColorBrush(lineNumber);
            Brush backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;

            if (lineNumber >= textArea.Document.TotalNumberOfLines)
            {
                g.FillRectangle(backgroundBrush, lineRectangle);
                if (TextEditorProperties.ShowInvalidLines)
                {
                    DrawInvalidLineMarker(g, lineRectangle.Left, lineRectangle.Top);
                }
                if (TextEditorProperties.ShowVerticalRuler)
                {
                    DrawVerticalRuler(g, lineRectangle);
                }
//				bgColorBrush.Dispose();
                return;
            }

            float physicalXPos = lineRectangle.X;
            // there can't be a folding wich starts in an above line and ends here, because the line is a new one,
            // there must be a return before this line.
            int column = 0;

            physicalColumn = 0;
            if (TextEditorProperties.EnableFolding)
            {
                while (true)
                {
                    ArrayList starts = textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, column - 1);
                    if (starts == null || starts.Count <= 0)
                    {
                        if (lineNumber < textArea.Document.TotalNumberOfLines)
                        {
                            physicalXPos = PaintLinePart(g, lineNumber, column, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos);
                        }
                        break;
                    }
                    // search the first starting folding
                    FoldMarker firstFolding = (FoldMarker)starts[0];
                    foreach (FoldMarker fm in starts)
                    {
                        if (fm.StartColumn < firstFolding.StartColumn)
                        {
                            firstFolding = fm;
                        }
                    }
                    starts.Clear();

                    physicalXPos = PaintLinePart(g, lineNumber, column, firstFolding.StartColumn, lineRectangle, physicalXPos);
                    column       = firstFolding.EndColumn;
                    lineNumber   = firstFolding.EndLine;

                    ColumnRange selectionRange2 = textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                    bool        drawSelected    = ColumnRange.WholeColumn.Equals(selectionRange2) || firstFolding.StartColumn >= selectionRange2.StartColumn && firstFolding.EndColumn <= selectionRange2.EndColumn;

                    physicalXPos = PaintFoldingText(g, lineNumber, physicalXPos, lineRectangle, firstFolding.FoldText, drawSelected);
                }
            }
            else
            {
                physicalXPos = PaintLinePart(g, lineNumber, 0, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos);
            }

            if (lineNumber < textArea.Document.TotalNumberOfLines)
            {
                // Paint things after end of line
                ColumnRange    selectionRange = textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                LineSegment    currentLine    = textArea.Document.GetLineSegment(lineNumber);
                HighlightColor selectionColor = textArea.Document.HighlightingStrategy.GetColorFor("Selection");

                float spaceWidth         = GetWidth(g, ' ');
                bool  selectionBeyondEOL = selectionRange.EndColumn > currentLine.Length || ColumnRange.WholeColumn.Equals(selectionRange);

                if (TextEditorProperties.ShowEOLMarker)
                {
                    HighlightColor eolMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor("EOLMarkers");
                    physicalXPos += DrawEOLMarker(g, eolMarkerColor.Color, selectionBeyondEOL ? bgColorBrush : backgroundBrush, physicalXPos, lineRectangle.Y);
                }
                else
                {
                    if (selectionBeyondEOL)
                    {
                        g.FillRectangle(BrushRegistry.GetBrush(selectionColor.BackgroundColor), new RectangleF(physicalXPos, lineRectangle.Y, spaceWidth, lineRectangle.Height));
                        physicalXPos += spaceWidth;
                    }
                }

                Brush fillBrush = selectionBeyondEOL && TextEditorProperties.AllowCaretBeyondEOL ? bgColorBrush : backgroundBrush;
                g.FillRectangle(fillBrush,
                                new RectangleF(physicalXPos, lineRectangle.Y, lineRectangle.Width - physicalXPos + lineRectangle.X, lineRectangle.Height));
            }
            if (TextEditorProperties.ShowVerticalRuler)
            {
                DrawVerticalRuler(g, lineRectangle);
            }
//			bgColorBrush.Dispose();
        }
Example #6
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);
        }
Example #7
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);
            }
        }
 public void ClosedOpen_Invalid_FamilyName(string familyName)
 {
     Assert.Throws <ArgumentException>(() => ColumnRange.ClosedOpen(familyName, "a", "z"));
 }
Example #9
0
        private int PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, int physicalXPos)
        {
            IList <TextMarker> textMarkers;
            Color              color;
            RectangleF         rectangleF;
            IList <TextMarker> markers;
            bool           flag            = this.DrawLineMarkerAtLine(lineNumber);
            Brush          brush           = (this.textArea.Enabled ? this.GetBgColorBrush(lineNumber) : SystemBrushes.InactiveBorder);
            HighlightColor colorFor        = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection");
            ColumnRange    selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
            HighlightColor highlightColor  = this.textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers");
            HighlightColor colorFor1       = this.textArea.Document.HighlightingStrategy.GetColorFor("SpaceMarkers");
            LineSegment    lineSegment     = this.textArea.Document.GetLineSegment(lineNumber);
            Brush          brush1          = BrushRegistry.GetBrush(colorFor.BackgroundColor);

            if (lineSegment.Words == null)
            {
                return(physicalXPos);
            }
            int           length        = 0;
            TextWord      textWord      = null;
            FontContainer fontContainer = base.TextEditorProperties.FontContainer;

            for (int i = 0; i < lineSegment.Words.Count; i++)
            {
                TextWord item = lineSegment.Words[i];
                if (length >= startColumn)
                {
                    while (length < endColumn && physicalXPos < lineRectangle.Right)
                    {
                        int          num  = length + item.Length - 1;
                        TextWordType type = item.Type;
                        if (type != TextWordType.Space)
                        {
                            color = (type != TextWordType.Tab ? item.Color : highlightColor.Color);
                        }
                        else
                        {
                            color = colorFor1.Color;
                        }
                        Brush markerBrushAt = this.GetMarkerBrushAt(lineSegment.Offset + length, item.Length, ref color, out textMarkers);
                        if (item.Length > 1)
                        {
                            int num1 = 2147483647;
                            if (this.highlight != null)
                            {
                                if (this.highlight.OpenBrace.Y == lineNumber && this.highlight.OpenBrace.X >= length && this.highlight.OpenBrace.X <= num)
                                {
                                    TextLocation openBrace = this.highlight.OpenBrace;
                                    num1 = Math.Min(num1, openBrace.X - length);
                                }
                                if (this.highlight.CloseBrace.Y == lineNumber && this.highlight.CloseBrace.X >= length && this.highlight.CloseBrace.X <= num)
                                {
                                    TextLocation closeBrace = this.highlight.CloseBrace;
                                    num1 = Math.Min(num1, closeBrace.X - length);
                                }
                                if (num1 == 0)
                                {
                                    num1 = 1;
                                }
                            }
                            if (endColumn < num)
                            {
                                num1 = Math.Min(num1, endColumn - length);
                            }
                            if (selectionAtLine.StartColumn > length && selectionAtLine.StartColumn <= num)
                            {
                                num1 = Math.Min(num1, selectionAtLine.StartColumn - length);
                            }
                            else if (selectionAtLine.EndColumn > length && selectionAtLine.EndColumn <= num)
                            {
                                num1 = Math.Min(num1, selectionAtLine.EndColumn - length);
                            }
                            foreach (TextMarker textMarker in textMarkers)
                            {
                                int offset    = textMarker.Offset - lineSegment.Offset;
                                int endOffset = textMarker.EndOffset - lineSegment.Offset + 1;
                                if (offset <= length || offset > num)
                                {
                                    if (endOffset <= length || endOffset > num)
                                    {
                                        continue;
                                    }
                                    num1 = Math.Min(num1, endOffset - length);
                                }
                                else
                                {
                                    num1 = Math.Min(num1, offset - length);
                                }
                            }
                            if (num1 != 2147483647)
                            {
                                if (textWord != null)
                                {
                                    throw new ApplicationException("split part invalid: first part cannot be splitted further");
                                }
                                textWord = TextWord.Split(ref item, num1);
                                continue;
                            }
                        }
                        if (ColumnRange.WholeColumn.Equals(selectionAtLine) || selectionAtLine.StartColumn <= length && selectionAtLine.EndColumn > num)
                        {
                            markerBrushAt = brush1;
                            if (colorFor.HasForeground)
                            {
                                color = colorFor.Color;
                            }
                        }
                        else if (flag)
                        {
                            markerBrushAt = brush;
                        }
                        if (markerBrushAt == null)
                        {
                            markerBrushAt = (item.SyntaxColor == null || !item.SyntaxColor.HasBackground ? brush : BrushRegistry.GetBrush(item.SyntaxColor.BackgroundColor));
                        }
                        if (item.Type == TextWordType.Space)
                        {
                            this.physicalColumn++;
                            rectangleF = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.SpaceWidth, (float)lineRectangle.Height);
                            g.FillRectangle(markerBrushAt, rectangleF);
                            if (base.TextEditorProperties.ShowSpaces)
                            {
                                this.DrawSpaceMarker(g, color, physicalXPos, lineRectangle.Y);
                            }
                            physicalXPos += this.SpaceWidth;
                        }
                        else if (item.Type != TextWordType.Tab)
                        {
                            int num2 = this.DrawDocumentWord(g, item.Word, new Point(physicalXPos, lineRectangle.Y), item.GetFont(fontContainer), color, markerBrushAt);
                            rectangleF    = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)num2, (float)lineRectangle.Height);
                            physicalXPos += num2;
                        }
                        else
                        {
                            this.physicalColumn += base.TextEditorProperties.TabIndent;
                            this.physicalColumn  = this.physicalColumn / base.TextEditorProperties.TabIndent * base.TextEditorProperties.TabIndent;
                            int wideSpaceWidth = (physicalXPos + 4 - lineRectangle.X) / this.WideSpaceWidth / base.TextEditorProperties.TabIndent * this.WideSpaceWidth * base.TextEditorProperties.TabIndent + lineRectangle.X;
                            wideSpaceWidth = wideSpaceWidth + this.WideSpaceWidth * base.TextEditorProperties.TabIndent;
                            rectangleF     = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)(wideSpaceWidth - physicalXPos), (float)lineRectangle.Height);
                            g.FillRectangle(markerBrushAt, rectangleF);
                            if (base.TextEditorProperties.ShowTabs)
                            {
                                this.DrawTabMarker(g, color, physicalXPos, lineRectangle.Y);
                            }
                            physicalXPos = wideSpaceWidth;
                        }
                        foreach (TextMarker textMarker1 in textMarkers)
                        {
                            if (textMarker1.TextMarkerType == TextMarkerType.SolidBlock)
                            {
                                continue;
                            }
                            this.DrawMarker(g, textMarker1, rectangleF);
                        }
                        if (this.highlight != null && (this.highlight.OpenBrace.Y == lineNumber && this.highlight.OpenBrace.X == length || this.highlight.CloseBrace.Y == lineNumber && this.highlight.CloseBrace.X == length))
                        {
                            this.DrawBracketHighlight(g, new Rectangle((int)rectangleF.X, lineRectangle.Y, (int)rectangleF.Width - 1, lineRectangle.Height - 1));
                        }
                        length += item.Length;
                        if (textWord == null)
                        {
                            goto label0;
                        }
                        item     = textWord;
                        textWord = null;
                    }
                    if (physicalXPos < lineRectangle.Right && endColumn >= lineSegment.Length)
                    {
                        markers = base.Document.MarkerStrategy.GetMarkers(lineSegment.Offset + lineSegment.Length);
                        foreach (TextMarker marker in markers)
                        {
                            if (marker.TextMarkerType == TextMarkerType.SolidBlock)
                            {
                                continue;
                            }
                            this.DrawMarker(g, marker, new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height));
                        }
                    }
                    return(physicalXPos);
                }
                else
                {
                    length += item.Length;
                }
                label0 :;
            }
            if (physicalXPos < lineRectangle.Right && endColumn >= lineSegment.Length)
            {
                markers = base.Document.MarkerStrategy.GetMarkers(lineSegment.Offset + lineSegment.Length);
                foreach (TextMarker marker1 in markers)
                {
                    if (marker1.TextMarkerType == TextMarkerType.SolidBlock)
                    {
                        continue;
                    }
                    this.DrawMarker(g, marker1, new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height));
                }
            }
            return(physicalXPos);
        }
Example #10
0
        private void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle)
        {
            bool  flag;
            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, lineRectangle.Left, lineRectangle.Top);
                }
                if (base.TextEditorProperties.ShowVerticalRuler)
                {
                    this.DrawVerticalRuler(g, lineRectangle);
                }
                return;
            }
            int x         = lineRectangle.X;
            int endColumn = 0;

            this.physicalColumn = 0;
            if (!base.TextEditorProperties.EnableFolding)
            {
                x = this.PaintLinePart(g, lineNumber, 0, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, x);
            }
            else
            {
                while (true)
                {
                    List <FoldMarker> foldedFoldingsWithStartAfterColumn = this.textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, endColumn - 1);
                    if (foldedFoldingsWithStartAfterColumn == null || foldedFoldingsWithStartAfterColumn.Count <= 0)
                    {
                        break;
                    }
                    FoldMarker item = foldedFoldingsWithStartAfterColumn[0];
                    foreach (FoldMarker foldMarker in foldedFoldingsWithStartAfterColumn)
                    {
                        if (foldMarker.StartColumn >= item.StartColumn)
                        {
                            continue;
                        }
                        item = foldMarker;
                    }
                    foldedFoldingsWithStartAfterColumn.Clear();
                    x          = this.PaintLinePart(g, lineNumber, endColumn, item.StartColumn, lineRectangle, x);
                    endColumn  = item.EndColumn;
                    lineNumber = item.EndLine;
                    if (lineNumber >= this.textArea.Document.TotalNumberOfLines)
                    {
                        goto Label0;
                    }
                    ColumnRange selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                    if (ColumnRange.WholeColumn.Equals(selectionAtLine))
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = (item.StartColumn < selectionAtLine.StartColumn ? false : item.EndColumn <= selectionAtLine.EndColumn);
                    }
                    bool flag1 = flag;
                    x = this.PaintFoldingText(g, lineNumber, x, lineRectangle, item.FoldText, flag1);
                }
                if (lineNumber < this.textArea.Document.TotalNumberOfLines)
                {
                    x = this.PaintLinePart(g, lineNumber, endColumn, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, x);
                }
            }
Label0:
            if (lineNumber < this.textArea.Document.TotalNumberOfLines)
            {
                ColumnRange    columnRange = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber);
                LineSegment    lineSegment = this.textArea.Document.GetLineSegment(lineNumber);
                HighlightColor colorFor    = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection");
                bool           flag2       = (columnRange.EndColumn > lineSegment.Length ? true : ColumnRange.WholeColumn.Equals(columnRange));
                if (base.TextEditorProperties.ShowEOLMarker)
                {
                    HighlightColor highlightColor = this.textArea.Document.HighlightingStrategy.GetColorFor("EOLMarkers");
                    x = x + this.DrawEOLMarker(g, highlightColor.Color, (flag2 ? bgColorBrush : brush), x, lineRectangle.Y);
                }
                else if (flag2)
                {
                    g.FillRectangle(BrushRegistry.GetBrush(colorFor.BackgroundColor), new RectangleF((float)x, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height));
                    x += this.WideSpaceWidth;
                }
                Brush brush1 = (!flag2 || !base.TextEditorProperties.AllowCaretBeyondEOL ? brush : bgColorBrush);
                g.FillRectangle(brush1, new RectangleF((float)x, (float)lineRectangle.Y, (float)(lineRectangle.Width - x + lineRectangle.X), (float)lineRectangle.Height));
            }
            if (base.TextEditorProperties.ShowVerticalRuler)
            {
                this.DrawVerticalRuler(g, lineRectangle);
            }
        }