コード例 #1
0
        /// <summary>
        /// Creates the next bottom border position.
        /// </summary>
        void CreateNextBottomBorderPosition()
        {
            int           lastIdx                 = bottomBorderMap.Count - 1;
            int           lastBorderRow           = (int)bottomBorderMap.GetKey(lastIdx);
            XUnit         lastPos                 = (XUnit)bottomBorderMap.GetByIndex(lastIdx);
            Cell          minMergedCell           = GetMinMergedCell(lastBorderRow);
            FormattedCell minMergedFormattedCell  = (FormattedCell)this.formattedCells[minMergedCell];
            XUnit         maxBottomBorderPosition = lastPos + minMergedFormattedCell.InnerHeight;

            maxBottomBorderPosition += CalcBottomBorderWidth(minMergedCell);

            foreach (Cell cell in this.mergedCells)
            {
                if (cell.Row.Index > minMergedCell.Row.Index + minMergedCell.MergeDown)
                {
                    break;
                }

                if (cell.Row.Index + cell.MergeDown == minMergedCell.Row.Index + minMergedCell.MergeDown)
                {
                    FormattedCell formattedCell   = (FormattedCell)this.formattedCells[cell];
                    XUnit         topBorderPos    = (XUnit)this.bottomBorderMap[cell.Row.Index];
                    XUnit         bottomBorderPos = topBorderPos + formattedCell.InnerHeight;
                    bottomBorderPos += CalcBottomBorderWidth(cell);
                    if (bottomBorderPos > maxBottomBorderPosition)
                    {
                        maxBottomBorderPosition = bottomBorderPos;
                    }
                }
            }
            this.bottomBorderMap.Add(minMergedCell.Row.Index + minMergedCell.MergeDown + 1, maxBottomBorderPosition);
        }
コード例 #2
0
 void FormatCells()
 {
     this.formattedCells = new SortedList <Cell, FormattedCell>(new CellComparer());
     foreach (Cell cell in this.mergedCells)
     {
         FormattedCell formattedCell = new FormattedCell(cell, this.documentRenderer, this.mergedCells.GetEffectiveBorders(cell), this.fieldInfos, 0, 0);
         formattedCell.Format(this.gfx);
         this.formattedCells.Add(cell, formattedCell);
     }
 }
コード例 #3
0
        Rectangle GetInnerRect(XUnit startingHeight, Cell cell)
        {
            BordersRenderer bordersRenderer = new BordersRenderer(this.mergedCells.GetEffectiveBorders(cell), this.gfx);
            FormattedCell   formattedCell   = (FormattedCell)this.formattedCells[cell];
            XUnit           width           = formattedCell.InnerWidth;

            XUnit y = this.startY;

            if (cell.Row.Index > this.lastHeaderRow)
            {
                y += startingHeight;
            }
            else
            {
                y += CalcMaxTopBorderWidth(0);
            }

            XUnit upperBorderPos = (XUnit)this.bottomBorderMap[cell.Row.Index];

            y += upperBorderPos;
            if (cell.Row.Index > this.lastHeaderRow)
            {
                y -= (XUnit)this.bottomBorderMap[this.startRow];
            }

            XUnit lowerBorderPos = (XUnit)this.bottomBorderMap[cell.Row.Index + cell.MergeDown + 1];


            XUnit height = lowerBorderPos - upperBorderPos;

            height -= bordersRenderer.GetWidth(BorderType.Bottom);

            XUnit x = this.startX;

            for (int clmIdx = 0; clmIdx < cell.Column.Index; ++clmIdx)
            {
                x += this.table.Columns[clmIdx].Width;
            }
            x += LeftBorderOffset;

            return(new Rectangle(x, y, width, height));
        }
コード例 #4
0
        /// <summary>
        /// Creates the next bottom border position.
        /// </summary>
        void CreateNextBottomBorderPosition()
        {
            int           lastIdx                 = bottomBorderMap.Count - 1;
            int           lastBorderRow           = (int)bottomBorderMap.Keys[lastIdx];
            XUnit         lastPos                 = (XUnit)bottomBorderMap.Values[lastIdx];
            Cell          minMergedCell           = GetMinMergedCell(lastBorderRow);
            FormattedCell minMergedFormattedCell  = (FormattedCell)this.formattedCells[minMergedCell];
            XUnit         maxBottomBorderPosition = lastPos + minMergedFormattedCell.InnerHeight;

            maxBottomBorderPosition += CalcBottomBorderWidth(minMergedCell);

            // Note: Caching the indices does speed up this function for large tables greatly.
            var minMergedCellRowIndex  = minMergedCell.Row.Index;
            var minMergedCellMergeDown = minMergedCell.MergeDown;
            var mergedIndexPlusDown    = minMergedCellRowIndex + minMergedCellMergeDown;

            foreach (Cell cell in this.mergedCells)
            {
                var rowIndex = cell.Row.Index;
                if (rowIndex > mergedIndexPlusDown)
                {
                    break;
                }

                if (rowIndex + cell.MergeDown == mergedIndexPlusDown)
                {
                    FormattedCell formattedCell   = (FormattedCell)this.formattedCells[cell];
                    XUnit         topBorderPos    = (XUnit)this.bottomBorderMap[rowIndex];
                    XUnit         bottomBorderPos = topBorderPos + formattedCell.InnerHeight;
                    bottomBorderPos += CalcBottomBorderWidth(cell);
                    if (bottomBorderPos > maxBottomBorderPosition)
                    {
                        maxBottomBorderPosition = bottomBorderPos;
                    }
                }
            }
            this.bottomBorderMap.Add(mergedIndexPlusDown + 1, maxBottomBorderPosition);
        }
コード例 #5
0
        void RenderContent(Cell cell, Rectangle innerRect)
        {
            FormattedCell formattedCell = (FormattedCell)this.formattedCells[cell];

            RenderInfo[] renderInfos = formattedCell.GetRenderInfos();

            if (renderInfos == null)
            {
                return;
            }

            VerticalAlignment verticalAlignment = cell.VerticalAlignment;
            XUnit             contentHeight     = formattedCell.ContentHeight;
            XUnit             innerHeight       = innerRect.Height;
            XUnit             targetX           = innerRect.X + cell.Column.LeftPadding;

            XUnit targetY;

            if (verticalAlignment == VerticalAlignment.Bottom)
            {
                targetY  = innerRect.Y + innerRect.Height;
                targetY -= cell.Row.BottomPadding;
                targetY -= contentHeight;
            }
            else if (verticalAlignment == VerticalAlignment.Center)
            {
                targetY  = innerRect.Y + cell.Row.TopPadding;
                targetY += innerRect.Y + innerRect.Height - cell.Row.BottomPadding;
                targetY -= contentHeight;
                targetY /= 2;
            }
            else
            {
                targetY = innerRect.Y + cell.Row.TopPadding;
            }

            RenderByInfos(targetX, targetY, renderInfos);
        }