/// <summary> /// The write table. /// </summary> /// <param name="t"> /// The t. /// </param> public void WriteTable(Table t) { var p = new System.Windows.Documents.Paragraph(); var figure = new Figure(); var table = new System.Windows.Documents.Table(); // if (t.HasHeader()) // { // var trg1 = new TableRowGroup(); // SetStyle(trg1, Style.TableHeaderStyle); // var r = new TableRow(); // foreach (var c in columns) // { // var cell = new TableCell(); // var run = new Run() { Text = c.Header }; // cell.Blocks.Add(new System.Windows.Documents.Paragraph(run)); // r.Cells.Add(cell); // } // trg1.Rows.Add(r); // table.RowGroups.Add(trg1); // } var trg2 = new TableRowGroup(); // SetStyle(trg2, Style.TableTextStyle); foreach (var row in t.Rows) { var r = new TableRow(); if (row.IsHeader) { SetStyle(r, row.IsHeader ? this.Style.TableHeaderStyle : this.Style.TableTextStyle); } for (int j = 0; j < t.Columns.Count; j++) { TableCell c = row.Cells[j]; var cell = new System.Windows.Documents.TableCell(); var run = new Run { Text = c.Content }; cell.Blocks.Add(new System.Windows.Documents.Paragraph(run)); r.Cells.Add(cell); } trg2.Rows.Add(r); } table.RowGroups.Add(trg2); figure.Blocks.Add(this.CreateParagraph(t.Caption, this.Style.FigureTextStyle)); figure.Blocks.Add(table); p.Inlines.Add(figure); this.doc.Blocks.Add(p); }
/// <summary> /// The update items. /// </summary> public void UpdateItems() { this.Rows.Clear(); this.Columns.Clear(); if (this.Fields == null || this.Fields.Count == 0) { return; } string[,] cells = this.ToArray(); int rows = cells.GetUpperBound(0) + 1; int columns = cells.GetUpperBound(1) + 1; for (int i = 0; i < rows; i++) { var tr = new TableRow(); if (this.ItemsInRows) { tr.IsHeader = i == 0; } this.Rows.Add(tr); for (int j = 0; j < columns; j++) { var tc = new TableCell(); tc.Content = cells[i, j]; tr.Cells.Add(tc); } } for (int j = 0; j < columns; j++) { var tc = new TableColumn(); if (this.ItemsInRows) { ItemsTableField f = this.Fields[j]; tc.Alignment = f.Alignment; tc.Width = f.Width; } else { tc.IsHeader = j == 0; tc.Alignment = this.Alignment; } this.Columns.Add(tc); } }