Esempio n. 1
0
        /// <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 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);
        }