public GridLayer(RenderElement owner, CellSizeStyle cellSizeStyle, GridTable gridTable) : base(owner) { this.cellSizeStyle = cellSizeStyle; this.gridTable = gridTable; gridRows = gridTable.Rows; gridCols = gridTable.Columns; int columnWidth = owner.Width; int nColumns = gridTable.ColumnCount; if (nColumns > 0) { columnWidth = columnWidth / nColumns; uniformCellWidth = columnWidth; if (columnWidth < 1) { columnWidth = 1; } } //------------------------------------------------------------ int cx = 0; for (int c = 0; c < nColumns; c++) { GridColumn col = gridCols.GetColumn(c); col.Width = columnWidth; col.Left = cx; cx += columnWidth; } //------------------------------------------------------------ int nRows = gridTable.RowCount; if (nRows > 0) { int rowHeight = owner.Height / nRows; int cy = 0; for (int r = 0; r < nRows; r++) { GridRow row = gridRows.GetRow(r); row.Height = rowHeight; row.Top = cy; cy += rowHeight; } uniformCellHeight = rowHeight; } //------------------------------------------------------------ }
public GridLayer(int width, int height, CellSizeStyle cellSizeStyle, GridTable gridTable) { _cellSizeStyle = cellSizeStyle; _gridTable = gridTable; _gridRows = gridTable.Rows; _gridCols = gridTable.Columns; int nColumns = gridTable.ColumnCount; if (cellSizeStyle == CellSizeStyle.ColumnAndRow) { int cx = 0; for (int c = 0; c < nColumns; c++) { GridColumn col = _gridCols.GetColumn(c); int col_w = col.Width; col.Left = cx; cx += col_w; } //------------------------------------------------------------ int nRows = gridTable.RowCount; if (nRows > 0) { int cy = 0; int row_h = 1; for (int r = 0; r < nRows; r++) { GridRow row = _gridRows.GetRow(r); row_h = row.Height; row.Height = row_h; row.Top = cy; cy += row_h; } _uniformCellHeight = row_h; } } else { int columnWidth = width; if (nColumns > 0) { columnWidth = columnWidth / nColumns; _uniformCellWidth = columnWidth; if (columnWidth < 1) { columnWidth = 1; } } //------------------------------------------------------------ int cx = 0; for (int c = 0; c < nColumns; c++) { GridColumn col = _gridCols.GetColumn(c); col.Width = columnWidth; col.Left = cx; cx += columnWidth; } //------------------------------------------------------------ int nRows = gridTable.RowCount; if (nRows > 0) { int rowHeight = height / nRows; int cy = 0; for (int r = 0; r < nRows; r++) { GridRow row = _gridRows.GetRow(r); row.Height = rowHeight; row.Top = cy; cy += rowHeight; } _uniformCellHeight = rowHeight; } } //------------------------------------------------------------ }