Example #1
0
        private void drawTokenText(Graphics gc, EventToken token, TokenTextItem item)
        {
            int dispRow = item.Row;
            int dispCol = item.Col;
            int dispWidth = item.Width;
            bool continued = item.Continued;

            bool colHangOver = (LeftColumn > 0 && LeftColumn + DisplayedColumnCount > ColumnCount);
            bool rowHangOver = (TopRow > 0 && TopRow + DisplayedRowCount > RowCount);
            int xLeft = colHangOver ? (ViewRectangle.Width - DisplayedColumnCount * _colWidth) : 0;
            int yTop = rowHangOver ? (ViewRectangle.Height - TrueScaleHeight - DisplayedRowCount * _rowHeight) : 0;

            int x1 = _colWidth * dispCol + xLeft;
            int y1 = TrueScaleHeight + _rowHeight * dispRow + yTop;
            if (x1 < 0)
                x1 = 0;

            string text = (continued ? "<< " : "") + token.Name;
            gc.DrawString(text, (continued ? _italic : _bold),
                token.IsHighlighted ? _fontHighlight : _fontColor,
                new RectangleF(x1 + 2, y1 + 2, dispWidth * _colWidth - 4, _rowHeight - 4),
                new StringFormat() { FormatFlags = StringFormatFlags.NoWrap });
        }
Example #2
0
        private void drawTokens(Graphics gc)
        {
            gc.Clip = new Region(new Rectangle(0, TrueScaleHeight, ViewRectangle.Width, ViewRectangle.Height - TrueScaleHeight));

            bool colHangOver = (LeftColumn > 0 && LeftColumn + DisplayedColumnCount > ColumnCount);
            bool rowHangOver = (TopRow > 0 && TopRow + DisplayedRowCount > RowCount);
            int colOffset = colHangOver ? -1 : 0;
            int rowOffset = rowHangOver ? -1 : 0;

            Dictionary<EventToken, TokenTextItem> textItems = new Dictionary<EventToken, TokenTextItem>();

            EventToken[] prevBlock = GetInstantTokens(LeftColumn - 1);
            EventToken[] block = GetInstantTokens(LeftColumn);
            for (int c = 0; c < DisplayedColumnCount; c++)
            {
                int trueCol = LeftColumn + c + colOffset;
                EventToken[] nextBlock = GetInstantTokens(trueCol + 1);
                for (int r = 0; r < DisplayedRowCount; r++)
                {
                    int trueRow = TopRow + r + rowOffset;
                    EventToken token = (block.Length > trueRow) ? block[trueRow] : null;
                    if (token != null)
                    {
                        EventToken prevToken = (prevBlock.Length > trueRow) ? prevBlock[trueRow] : null;
                        EventToken nextToken = (nextBlock.Length > trueRow) ? nextBlock[trueRow] : null;

                        drawLeftToken(gc, r, c, token, (prevToken == null || prevToken != token));
                        drawRightToken(gc, r, c, token, (nextToken == null || nextToken != token));
                        if (prevToken == null || prevToken != token)
                            textItems[token] = new TokenTextItem() { Row = r, Col = c, Width = 1, Continued = false };
                        else if (c == 0)
                            textItems[token] = new TokenTextItem() { Row = r, Col = c, Width = 1, Continued = true };
                        else
                            textItems[token].Width++;
                    }
                }
                prevBlock = block;
                block = nextBlock;
            }

            foreach (var item in textItems)
            {
                drawTokenText(gc, item.Key, item.Value);
            }
        }