private int GetCellContentHeight(IFastGridCell cell)
        {
            if (cell == null)
            {
                return(0);
            }
            var font = GetFont(false, false);
            var res  = font.TextHeight;

            for (var i = 0; i < cell.BlockCount; i++)
            {
                var block = cell.GetBlock(i);
                if (block.BlockType != FastGridBlockType.Text)
                {
                    continue;
                }
                var text = block.TextData;
                if (text == null)
                {
                    continue;
                }
                var hi = font.GetTextHeight(text);
                if (hi > res)
                {
                    res = hi;
                }
            }
            return(res);
        }
        private int GetCellContentWidth(IFastGridCell cell, int?maxSize = null)
        {
            if (cell == null)
            {
                return(0);
            }
            var count = cell.BlockCount;

            var witdh = 0;

            for (var i = 0; i < count; i++)
            {
                var block = cell.GetBlock(i);
                if (block == null)
                {
                    continue;
                }
                if (i > 0)
                {
                    witdh += BlockPadding;
                }

                switch (block.BlockType)
                {
                case FastGridBlockType.Text:
                    var text = block.TextData;
                    var font = GetFont(block.IsBold, block.IsItalic);
                    witdh += font.GetTextWidth(text, maxSize);
                    break;

                case FastGridBlockType.Image:
                    witdh += block.ImageWidth;
                    break;
                }
            }
            return(witdh);
        }
        private void RenderCell(IFastGridCell cell, IntRect rect, Color?selectedTextColor, Color bgColor, FastGridCellAddress cellAddr)
        {
            var isHoverCell = !cellAddr.IsEmpty && cellAddr == _mouseOverCell;

            if (isHoverCell)
            {
                _mouseOverCellIsTrimmed = false;
                CurrentCellActiveRegions.Clear();
                CurrentHoverRegion = null;
            }

            if (cell == null)
            {
                return;
            }
            var rectContent = GetContentRect(rect);

            _drawBuffer.DrawRectangle(rect, GridLineColor);
            _drawBuffer.FillRectangle(rect.GrowSymmetrical(-1, -1), bgColor);

            var count      = cell.BlockCount;
            var rightCount = cell.RightAlignBlockCount;
            var leftCount  = count - rightCount;
            var leftPos    = rectContent.Left;
            var rightPos   = rectContent.Right;

            for (var i = count - 1; i >= count - rightCount; i--)
            {
                var block = cell.GetBlock(i);
                if (block == null)
                {
                    continue;
                }
                if (i < count - 1)
                {
                    rightPos -= BlockPadding;
                }
                var blockWi = RenderBlock(leftPos, rightPos, selectedTextColor, bgColor, rectContent, block, cellAddr, false, isHoverCell);
                rightPos -= blockWi;
            }

            for (var i = 0; i < leftCount && leftPos < rightPos; i++)
            {
                var block = cell.GetBlock(i);
                if (block == null)
                {
                    continue;
                }
                if (i > 0)
                {
                    leftPos += BlockPadding;
                }
                var blockWi = RenderBlock(leftPos, rightPos, selectedTextColor, bgColor, rectContent, block, cellAddr, true, isHoverCell);
                leftPos += blockWi;
            }
            switch (cell.Decoration)
            {
            case CellDecoration.StrikeOutHorizontal:
                _drawBuffer.DrawLine(rect.Left, rect.Top + rect.Height / 2, rect.Right, rect.Top + rect.Height / 2, cell.DecorationColor ?? Colors.Black);
                break;
            }
            if (isHoverCell)
            {
                _mouseOverCellIsTrimmed = leftPos > rightPos;
            }
        }