public void AddRow(GraphicsElementTableRow row) { row.OffsetX = OffsetX; Rows.Add(row); lRowCount = Rows.Count; int rowcolcnt = row.GetMaxColumn(); if (lColumnCount < rowcolcnt) { lColumnCount = rowcolcnt; } }
private void lUpdateColumnWidthsAndRowHeights() { if (Rows.Count > 0) { int[] coloffsets = new int[lColumnCount]; // set the base column widths foreach (GraphicsElementTableRow tmprow in Rows) { if (tmprow.Cells.Count > 0) { foreach (GraphicsElementTableCell tmpcell in tmprow.Cells) { if ((tmpcell.ColSpan == 1) && (ColumnWidths[tmpcell.Column] < tmpcell.Width)) { ColumnWidths[tmpcell.Column] = tmpcell.Width; } } } } // adjust the column widths for cells that span multiple columns foreach (GraphicsElementTableRow tmprow in Rows) { if (tmprow.Cells.Count > 0) { foreach (GraphicsElementTableCell tmpcell in tmprow.Cells) { if (tmpcell.ColSpan > 1) { int tmpcnt = 0; int tmpwidth = 0; do { tmpwidth += ColumnWidths[tmpcell.Column + tmpcnt]; tmpcnt++; } while (tmpcnt < tmpcell.ColSpan); if (tmpwidth < tmpcell.Width) { ColumnWidths[tmpcell.Column + (tmpcell.ColSpan - 1)] = tmpcell.Width - tmpwidth; // GWH FUTURE ENHANCEMENT--SPREAD THE EXTRA WIDTH OVER MULTIPLE COLUMNS TO MAKE THE COLUMNS APPEAR MORE EVEN } else { tmpcell.Width = tmpwidth; } } } } } // set column offsets int colndx = 0; Width = 0; while (colndx < ColumnWidths.Length) { coloffsets[colndx] = Width; Width += ColumnWidths[colndx]; colndx++; } // update all cell's column widths and offsetx positions int offsty = 0; foreach (GraphicsElementTableRow tmprow in Rows) { if (tmprow.Cells.Count > 0) { foreach (GraphicsElementTableCell tmpcell in tmprow.Cells) { if (tmpcell.ColSpan == 1) { tmpcell.Width = ColumnWidths[tmpcell.Column]; } if (tmpcell.RowSpan == 1) { tmpcell.Height = tmprow.Height; } } } offsty += tmprow.Height; } // update multi-row cell heights int rowndx = 0; while (rowndx < Rows.Count) { GraphicsElementTableRow tmprow = Rows[rowndx]; if (tmprow.Cells.Count > 0) { int baserowht = tmprow.Height; foreach (GraphicsElementTableCell tmpcell in tmprow.Cells) { if (tmpcell.RowSpan > 1) { int tmprowndx = 0; int tmprowht = 0; while (tmprowndx < tmpcell.RowSpan) { tmprowht += Rows[rowndx + tmprowndx].Height; tmprowndx++; } if (tmpcell.Height > tmprowht) { Rows[rowndx + (tmpcell.RowSpan - 1)].Height += tmpcell.Height - tmprowht; } } else if (tmpcell.Height < baserowht) { tmpcell.Height = baserowht; } } } rowndx++; } // update cell offsets and the total table height Height = 0; foreach (GraphicsElementTableRow tmprow in Rows) { if (tmprow.Cells.Count > 0) { foreach (GraphicsElementTableCell tmpcell in tmprow.Cells) { tmpcell.OffsetX = coloffsets[tmpcell.Column]; tmpcell.OffsetY = Height; } } tmprow.OffsetY = Height; Height += tmprow.Height; } } }