/// <summary> /// Calculates the top border width for the first row that is rendered or formatted. /// </summary> /// <param name="row">The row index.</param> XUnit CalcMaxTopBorderWidth(int row) { XUnit maxWidth = 0; if (this.table.Rows.Count > row) { int cellIdx = this.mergedCells.BinarySearch(this.table[row, 0], new CellComparer()); Cell rowCell = this.mergedCells[cellIdx]; while (cellIdx < this.mergedCells.Count) { rowCell = this.mergedCells[cellIdx]; if (rowCell.Row.Index > row) { break; } if (!rowCell.IsNull("Borders")) { BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, this.gfx); XUnit width = 0; width = bordersRenderer.GetWidth(BorderType.Top); if (width > maxWidth) { maxWidth = width; } } ++cellIdx; } } return(maxWidth); }
void RenderDiagonalBorders(Borders mergedBorders, Rectangle innerRect) { BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx); bordersRenderer.RenderDiagonally(BorderType.DiagonalDown, innerRect.X, innerRect.Y, innerRect.Width, innerRect.Height); bordersRenderer.RenderDiagonally(BorderType.DiagonalUp, innerRect.X, innerRect.Y, innerRect.Width, innerRect.Height); }
/// <summary> /// Calculates bottom border width of a cell. /// </summary> /// <param name="cell">The cell the bottom border of the row that is probed.</param> /// <returns>The calculated border width.</returns> XUnit CalcBottomBorderWidth(Cell cell) { Borders borders = this.mergedCells.GetEffectiveBorders(cell); if (borders != null) { BordersRenderer bordersRenderer = new BordersRenderer(borders, this.gfx); return(bordersRenderer.GetWidth(BorderType.Bottom)); } return(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)); }
void RenderBorders(Cell cell, Rectangle innerRect) { XUnit leftPos = innerRect.X; XUnit rightPos = leftPos + innerRect.Width; XUnit topPos = innerRect.Y; XUnit bottomPos = innerRect.Y + innerRect.Height; Borders mergedBorders = this.mergedCells.GetEffectiveBorders(cell); BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx); XUnit bottomWidth = bordersRenderer.GetWidth(BorderType.Bottom); XUnit leftWidth = bordersRenderer.GetWidth(BorderType.Left); XUnit topWidth = bordersRenderer.GetWidth(BorderType.Top); XUnit rightWidth = bordersRenderer.GetWidth(BorderType.Right); bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos); bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos); bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos); bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos); RenderDiagonalBorders(mergedBorders, innerRect); }