Esempio n. 1
0
        private List<TableColumn> BuildColumns(IEnumerable<DataRow> dataRows, out List<ColumnType> columnTypes)
        {
            var headers = new List<TableColumn>();
            columnTypes = new List<ColumnType>();
            foreach (DataColumn dataColumn in dataRows.ElementAt(0).Table.Columns)
            {
                var formatter = new TableHeaderHelper();

                var header = string.Empty;
                if (dataColumn.ExtendedProperties.Count == 0)
                {
                    columnTypes.Add(ColumnType.Text);
                    header = dataColumn.ColumnName;
                }
                else
                {
                    var role = (ColumnRole)(dataColumn.ExtendedProperties["NBi::Role"] ?? ColumnRole.Key);
                    var type = (ColumnType)(dataColumn.ExtendedProperties["NBi::Type"] ?? ColumnType.Text);
                    var tolerance = (Tolerance)(dataColumn.ExtendedProperties["NBi::Tolerance"]);
                    var rounding = (Rounding)(dataColumn.ExtendedProperties["NBi::Rounding"]);
                    columnTypes.Add(type);

                    header = formatter.GetText(role, type, tolerance, rounding);
                }
                headers.Add(new TableColumn() { HeaderCell = new TableCell() { Text = header } });
            }

            return headers;
        }
Esempio n. 2
0
        private List <TableColumnExtended> BuildColumns(IEnumerable <DataRow> dataRows, out List <ColumnType> columnTypes)
        {
            var headers = new List <TableColumnExtended>();

            columnTypes = new List <ColumnType>();
            foreach (DataColumn dataColumn in dataRows.ElementAt(0).Table.Columns)
            {
                var formatter   = new TableHeaderHelper();
                var tableColumn = new TableColumnExtended();
                var headerCell  = new TableCellExtended()
                {
                };
                switch (style)
                {
                case ComparisonStyle.ByIndex:
                    headerCell.Text = string.Format("#{0} ({1})", headers.Count, dataColumn.ColumnName);
                    break;

                case ComparisonStyle.ByName:
                    headerCell.Text = string.Format("{0}", dataColumn.ColumnName);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                tableColumn.HeaderCell = headerCell;

                if (dataColumn.ExtendedProperties.Count > 0)
                {
                    var role      = (ColumnRole)(dataColumn.ExtendedProperties["NBi::Role"] ?? ColumnRole.Key);
                    var type      = (ColumnType)(dataColumn.ExtendedProperties["NBi::Type"] ?? ColumnType.Text);
                    var tolerance = (Tolerance)(dataColumn.ExtendedProperties["NBi::Tolerance"]);
                    var rounding  = (Rounding)(dataColumn.ExtendedProperties["NBi::Rounding"]);
                    columnTypes.Add(type);

                    var subHeader     = formatter.GetText(role, type, tolerance, rounding);
                    var subHeaderCell = new TableCellExtended()
                    {
                        Text = subHeader
                    };
                    tableColumn.SubHeaderCell = subHeaderCell;
                }
                else
                {
                    columnTypes.Add(ColumnType.Text);
                }

                headers.Add(tableColumn);
            }

            return(headers);
        }
Esempio n. 3
0
        private List <TableColumn> BuildColumns(IEnumerable <DataRow> dataRows, out List <ColumnType> columnTypes)
        {
            var headers = new List <TableColumn>();

            columnTypes = new List <ColumnType>();
            foreach (DataColumn dataColumn in dataRows.ElementAt(0).Table.Columns)
            {
                var formatter = new TableHeaderHelper();

                var header = string.Empty;
                if (dataColumn.ExtendedProperties.Count == 0)
                {
                    columnTypes.Add(ColumnType.Text);
                    header = dataColumn.ColumnName;
                }
                else
                {
                    var role      = (ColumnRole)(dataColumn.ExtendedProperties["NBi::Role"] ?? ColumnRole.Key);
                    var type      = (ColumnType)(dataColumn.ExtendedProperties["NBi::Type"] ?? ColumnType.Text);
                    var tolerance = (Tolerance)(dataColumn.ExtendedProperties["NBi::Tolerance"]);
                    var rounding  = (Rounding)(dataColumn.ExtendedProperties["NBi::Rounding"]);
                    columnTypes.Add(type);

                    header = formatter.GetText(role, type, tolerance, rounding);
                }
                headers.Add(new TableColumn()
                {
                    HeaderCell = new TableCell()
                    {
                        Text = header
                    }
                });
            }

            return(headers);
        }