private static Widget ProcessTableClose(Token token, BuilderContext ctx)
            {
                var maxColumnCount = ctx.rows.Max(row => row.Count);

                ctx.rows.ForEach(row =>
                {
                    while (row.Count < maxColumnCount)
                    {
                        var cellContainer = row.Last();
                        row.Add(
                            new Container(
                                padding: cellContainer.padding,
                                decoration: cellContainer.decoration
                                )
                            );
                    }
                });
                var tableRows = ctx.rows.Select(row => new TableRow(children: row.Cast <Widget>().ToList())).ToList();
                var table     = new Container(
                    margin: EdgeInsets.only(top: 16f, bottom: 24f),
                    child: new Table(
                        border: TableBorder.all(
                            width: 1f,
                            color: new Color(0xffe0e0e0)
                            ),
                        defaultColumnWidth: new FlexColumnWidth(1.0f),
                        children: tableRows
                        )
                    );

                ctx.ClearColumn();
                return(table);
            }
示例#2
0
 public TableMeasurer(Table table, RenderContext options)
     : base(table, options)
 {
     _explicitWidth = table.Width;
     _border        = table.Border;
     _padRightCell  = table.PadRightCell;
 }
示例#3
0
    /// <summary>
    /// Sets the border.
    /// </summary>
    /// <typeparam name="T">An object type with a border.</typeparam>
    /// <param name="obj">The object to set the border for.</param>
    /// <param name="border">The border to use.</param>
    /// <returns>The same instance so that multiple calls can be chained.</returns>
    public static T Border <T>(this T obj, TableBorder border)
        where T : class, IHasTableBorder
    {
        if (obj is null)
        {
            throw new ArgumentNullException(nameof(obj));
        }

        obj.Border = border;
        return(obj);
    }
示例#4
0
        /// <summary>
        /// Gets the safe border for a border.
        /// </summary>
        /// <param name="border">The border to get the safe border for.</param>
        /// <param name="safe">Whether or not to return the safe border.</param>
        /// <returns>The safe border if one exist, otherwise the original border.</returns>
        public static TableBorder GetSafeBorder(this TableBorder border, bool safe)
        {
            if (border is null)
            {
                throw new ArgumentNullException(nameof(border));
            }

            if (safe && border.SafeBorder != null)
            {
                border = border.SafeBorder;
            }

            return(border);
        }
示例#5
0
 public static MarkdownStyleSheet defaultStyle()
 {
     return(new MarkdownStyleSheet(
                CTextStyle.PXLargeBlue,
                CTextStyle.PXLarge,
                CTextStyle.PCodeStyle,
                CTextStyle.H4,
                CTextStyle.H5,
                CTextStyle.PXLarge,
                CTextStyle.PXLarge,
                CTextStyle.PXLarge,
                CTextStyle.PXLarge,
                CTextStyle.PXLarge.copyWith(fontStyle: FontStyle.italic),
                CTextStyle.PXLarge.copyWith(fontWeight: FontWeight.bold),
                new TextStyle(decoration: TextDecoration.lineThrough),
                CTextStyle.PXLargeBody4,
                CTextStyle.PXLarge,
                CTextStyle.PXLarge,
                8.0f,
                24.0f,
                CTextStyle.PXLarge,
                new TextStyle(fontWeight: FontWeight.w600),
                CTextStyle.PXLarge,
                TextAlign.center,
                TableBorder.all(color: CColors.Grey, width: 0),
                new FlexColumnWidth(),
                EdgeInsets.fromLTRB(16, 8, 16, 8),
                tableCellsDecoration: new BoxDecoration(color: CColors.Grey),
                blockquotePadding: EdgeInsets.all(16.0f),
                blockquoteDecoration: new BoxDecoration(
                    border: new Border(
                        left: new BorderSide(
                            color: CColors.Separator,
                            8
                            ))
                    ),
                codeblockPadding: EdgeInsets.all(30.0f),
                codeblockDecoration: new BoxDecoration(
                    color: Color.fromRGBO(110, 198, 255, 0.12f)
                    ),
                horizontalRuleDecoration: new BoxDecoration(
                    border: new Border(
                        top: new BorderSide(width: 5.0f, color: CColors.Grey)
                        )
                    )));
 }
示例#6
0
        private void TableStyle(Document document)
        {
            #region #CreateNewTableStyle
            document.BeginUpdate();
            //Create a new table style
            TableStyle tStyleMain = document.TableStyles.CreateNew();

            //Specify style options
            TableBorder insideHorizontalBorder = tStyleMain.TableBorders.InsideHorizontalBorder;
            insideHorizontalBorder.LineStyle = TableBorderLineStyle.Single;
            insideHorizontalBorder.LineColor = Color.White;

            TableBorder insideVerticalBorder = tStyleMain.TableBorders.InsideVerticalBorder;
            insideVerticalBorder.LineStyle = TableBorderLineStyle.Single;
            insideVerticalBorder.LineColor = Color.White;
            tStyleMain.CellBackgroundColor = Color.FromArgb(227, 238, 220);
            tStyleMain.Name = "MyTableStyle";

            //Add the style to the document collection
            document.TableStyles.Add(tStyleMain);

            //Create conditional styles (styles for specific table elements)
            TableConditionalStyle myNewStyleForOddRows = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.OddRowBanding);
            myNewStyleForOddRows.CellBackgroundColor = Color.FromArgb(196, 220, 182);

            TableConditionalStyle myNewStyleForBottomRightCell = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.BottomRightCell);
            myNewStyleForBottomRightCell.CellBackgroundColor = Color.FromArgb(188, 214, 201);
            document.EndUpdate();

            document.BeginUpdate();

            // Apply a previously defined style to the table
            document.Tables[0].Style = tStyleMain;
            document.EndUpdate();
            #endregion #CreateNewTableStyle
        }
示例#7
0
        public static MvcHtmlString MakeTable(this HtmlHelper helper, string tableId, string tableName, string[] colNames, IEnumerable <object> model, TableColor color = TableColor.Black, TableBorder border = TableBorder.None, bool tableFadeInDown = true, bool tableRowsBounceIn = true)
        {
            if (!ShowChanged)
            {
                ShowHeader = true;
                ShowFooter = true;
                Searcher   = true;
                Button     = true;
                RowCount   = true;
            }

            if (!PrimaryDataChanged)
            {
                CurrentPage      = 1;
                CountItemsInPage = 10;
                MaxPageInline    = 5;
            }

            if (!IconsSet)
            {
                Excel      = "../Content/MyTable/Images/excel.ico";
                Reload     = "../Content/MyTable/Images/SoftwareUpdate.png";
                Pdf        = "../Content/MyTable/Images/pdf.ico";
                Printer    = "../Content/MyTable/Images/Imprimante2.png";
                Search     = "../Content/MyTable/Images/Search.png";
                HeaderIcon = "../Content/MyTable/Images/Information.png";
            }

            TableId = tableId;

            var str = string.Empty;

            str += MakeHiddenInputs(model.Count() + 2);

            var returnToDic = ReturnToDic(model, colNames);

            var firstItem = returnToDic.ElementAt(0);

            var tablefadeInDown = string.Empty;

            if (tableFadeInDown)
            {
                tablefadeInDown = "table-fadeInDown";
            }

            var tablerowsbounceIn = string.Empty;

            if (tableRowsBounceIn)
            {
                tablerowsbounceIn = "table-rows-bounceIn";
            }

            str += $"<table id='{tableId}' class='new-table {color.ToString().ToLower()}-table {border.ToString().ToLower()}-bordered {tablefadeInDown} {tablerowsbounceIn}'>";

            if (ShowHeader)
            {
                str += MakeHeader(firstItem.Count, tableName);
            }

            str += "<tbody><tr>";

            foreach (var item in firstItem)
            {
                str += $"<td>{item.Key}</td>";
            }

            foreach (var item in returnToDic)
            {
                str += "<tr>";
                foreach (var itemVal in item)
                {
                    str += $"<td>{itemVal.Value}</td>";
                }

                str += "</tr>";
            }


            str += "</tbody>";

            if (ShowFooter)
            {
                str += MakeFooter(firstItem.Count, colNames);
            }

            str += "</table>";

            return(MvcHtmlString.Create(str));
        }
示例#8
0
        public Table(
            Key key = null,
            List <TableRow> children = null,
            Dictionary <int, TableColumnWidth> columnWidths = null,
            TableColumnWidth defaultColumnWidth             = null,
            TableBorder border = null,
            TableCellVerticalAlignment defaultVerticalAlignment = TableCellVerticalAlignment.top,
            TextBaseline?textBaseline = null
            ) : base(key: key)
        {
            children                      = children ?? new List <TableRow>();
            defaultColumnWidth            = defaultColumnWidth ?? new FlexColumnWidth(1.0f);
            this.children                 = children;
            this.columnWidths             = columnWidths;
            this.defaultColumnWidth       = defaultColumnWidth;
            this.border                   = border;
            this.defaultVerticalAlignment = defaultVerticalAlignment;
            this.textBaseline             = textBaseline;
            D.assert(() => {
                if (children.Any((TableRow row) => {
                    return(row.children.Any((Widget cell) => { return cell == null; }));
                }))
                {
                    throw new UIWidgetsError(
                        "One of the children of one of the rows of the table was null.\n" +
                        "The children of a TableRow must not be null."
                        );
                }

                return(true);
            });
            D.assert(() => {
                if (children.Any((TableRow row1) => {
                    return(row1.key != null &&
                           children.Any((TableRow row2) => { return row1 != row2 && row1.key == row2.key; }));
                }))
                {
                    throw new UIWidgetsError(
                        "Two or more TableRow children of this Table had the same key.\n" +
                        "All the keyed TableRow children of a Table must have different Keys."
                        );
                }

                return(true);
            });
            D.assert(() => {
                if (children.isNotEmpty())
                {
                    int cellCount = this.children.First().children.Count;
                    if (children.Any((TableRow row) => { return(row.children.Count != cellCount); }))
                    {
                        throw new UIWidgetsError(
                            "Table contains irregular row lengths.\n" +
                            "Every TableRow in a Table must have the same number of children, so that every cell is filled. " +
                            "Otherwise, the table will contain holes."
                            );
                    }
                }

                return(true);
            });
            _rowDecorations = null;
            if (children.Any((TableRow row) => { return(row.decoration != null); }))
            {
                _rowDecorations = new List <Decoration>();
                foreach (TableRow row in children)
                {
                    _rowDecorations.Add(row.decoration);
                }
            }

            D.assert(() => {
                List <Widget> flatChildren = new List <Widget>();
                foreach (TableRow row in children)
                {
                    flatChildren.AddRange(row.children);
                }

                if (WidgetsD.debugChildrenHaveDuplicateKeys(this, flatChildren))
                {
                    throw new UIWidgetsError(
                        "Two or more cells in this Table contain widgets with the same key.\n" +
                        "Every widget child of every TableRow in a Table must have different keys. The cells of a Table are " +
                        "flattened out for processing, so separate cells cannot have duplicate keys even if they are in " +
                        "different rows."
                        );
                }

                return(true);
            });
        }
示例#9
0
 public TableDefinitionView(int columnCount, int rowCount, float columnWidth, float rowHeight, TableBorder border)
 {
     _border  = border;
     _columns = new TableDefinitionArray(columnCount, columnWidth, GetColumnLines(border));
     _rows    = new TableDefinitionArray(rowCount, rowHeight, GetRowLines(border));
 }
示例#10
0
        public MarkdownStyleSheet(
            TextStyle a,
            TextStyle p,
            TextStyle code,
            TextStyle h1,
            TextStyle h2,
            TextStyle h3,
            TextStyle h4,
            TextStyle h5,
            TextStyle h6,
            TextStyle em,
            TextStyle strong,
            TextStyle del,
            TextStyle blockquote,
            TextStyle img,
            TextStyle checkbox,
            float blockSpacing,
            float listIndent,
            TextStyle listBullet,
            TextStyle tableHead,
            TextStyle tableBody,
            TextAlign tableHeadAlign,
            TableBorder tableBorder,
            TableColumnWidth tableColumnWidth,
            EdgeInsets tableCellsPadding,
            Decoration tableCellsDecoration,
            EdgeInsets blockquotePadding,
            Decoration blockquoteDecoration,
            EdgeInsets codeblockPadding,
            Decoration codeblockDecoration,
            Decoration horizontalRuleDecoration,
            float textScaleFactor = 1.0f
            )
        {
            this.a                        = a;
            this.p                        = p;
            this.code                     = code;
            this.h1                       = h1;
            this.h2                       = h2;
            this.h3                       = h3;
            this.h4                       = h4;
            this.h5                       = h5;
            this.h6                       = h6;
            this.em                       = em;
            this.strong                   = strong;
            this.del                      = del;
            this.blockquote               = blockquote;
            this.img                      = img;
            this.checkbox                 = checkbox;
            this.blockSpacing             = blockSpacing;
            this.listIndent               = listIndent;
            this.listBullet               = listBullet;
            this.tableHead                = tableHead;
            this.tableBody                = tableBody;
            this.tableHeadAlign           = tableHeadAlign;
            this.tableBorder              = tableBorder;
            this.tableColumnWidth         = tableColumnWidth;
            this.tableCellsPadding        = tableCellsPadding;
            this.tableCellsDecoration     = tableCellsDecoration;
            this.blockquotePadding        = blockquotePadding;
            this.blockquoteDecoration     = blockquoteDecoration;
            this.codeblockPadding         = codeblockPadding;
            this.codeblockDecoration      = codeblockDecoration;
            this.horizontalRuleDecoration = horizontalRuleDecoration;
            this.textScaleFactor          = textScaleFactor;

            this._styles = new Dictionary <string, TextStyle>()
            {
                { "a", a },
                { "p", p },
                { "li", p },
                { "code", code },
                { "pre", p },
                { "h1", h1 },
                { "h2", h2 },
                { "h3", h3 },
                { "h4", h4 },
                { "h5", h5 },
                { "h6", h6 },
                { "em", em },
                { "strong", strong },
                { "del", del },
                { "blockquote", blockquote },
                { "img", img },
                { "table", p },
                { "th", tableHead },
                { "tr", tableHead },
                { "td", tableHead },
            };
        }
示例#11
0
 public static MarkdownStyleSheet fromTheme(ThemeData theme)
 {
     return(new MarkdownStyleSheet(
                a: new TextStyle(true, Colors.blue),
                p: theme.textTheme.body1,
                code: theme.textTheme.body1.copyWith(
                    null,
                    null,
                    Colors.grey.shade200,
                    "monospace",
                    null,
                    theme.textTheme.body1.fontSize * 0.85f,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null
                    ),
                h1: theme.textTheme.headline,
                h2: theme.textTheme.title,
                h3: theme.textTheme.subhead,
                h4: theme.textTheme.body2,
                h5: theme.textTheme.body2,
                h6: theme.textTheme.body2,
                em: new TextStyle(fontStyle: FontStyle.italic),
                strong: new TextStyle(fontWeight: FontWeight.bold),
                del: new TextStyle(decoration: TextDecoration.lineThrough),
                blockquote: theme.textTheme.body1,
                img: theme.textTheme.body1,
                checkbox: theme.textTheme.body1.copyWith(
                    color: theme.primaryColor
                    ),
                blockSpacing: 8.0f,
                listIndent: 24.0f,
                listBullet: theme.textTheme.body1,
                tableHead: new TextStyle(fontWeight: FontWeight.w600),
                tableBody: theme.textTheme.body1,
                tableHeadAlign: TextAlign.center,
                tableBorder: TableBorder.all(color: Colors.grey.shade300, width: 0),
                tableColumnWidth: new FlexColumnWidth(),
                tableCellsPadding: EdgeInsets.fromLTRB(16, 8, 16, 8),
                tableCellsDecoration: new BoxDecoration(color: Colors.grey.shade50),
                blockquotePadding: EdgeInsets.all(8.0f),
                blockquoteDecoration: new BoxDecoration(
                    color: Colors.blue.shade100,
                    borderRadius: BorderRadius.circular(2.0f)
                    ),
                codeblockPadding: EdgeInsets.all(8.0f),
                codeblockDecoration: new BoxDecoration(
                    color: Colors.grey.shade200,
                    borderRadius: BorderRadius.circular(2.0f)
                    ),
                horizontalRuleDecoration: new BoxDecoration(
                    border: new Border(
                        top: new BorderSide(width: 5.0f, color: Colors.grey.shade300)
                        )
                    )
                ));
 }
示例#12
0
 public Table(IAnsiConsole console, TableBorder?theme = null, bool includeCount = false)
 {
     _console      = console;
     _includeCount = includeCount;
     _tableBorder  = theme ?? TableBorder.Rounded;
 }