Exemple #1
0
        internal static void DrawRow(
            Table table, RowSetup rowSetup, List <CellPlaceholder> rowPlaceholder, List <ColumnSetup> columnSetups, bool tableIsColumnPrimary)
        {
            var row = new TableRow();

            rowSetup.UnderlyingTableRow = row;
            table.Rows.Add(row);

            row.CssClass = rowSetup.CssClass;
            if (rowSetup.ClickScript != null)
            {
                rowSetup.ClickScript.SetUpClickableControl(row);
            }

            for (var i = 0; i < rowPlaceholder.Count; i++)
            {
                if (rowPlaceholder[i] is EwfTableCell)
                {
                    row.Cells.Add(buildCell(rowPlaceholder[i] as EwfTableCell, rowSetup, columnSetups[i], tableIsColumnPrimary));
                }
            }

            if ((!rowSetup.ToolTip.IsNullOrWhiteSpace() || rowSetup.ToolTipControl != null) && row.Cells.Count > 0)
            {
                // NOTE: This comment is no longer accurate.
                // It is very important that we add the tool tip to the cell so that the tool tip is hidden if the row is hidden.
                // We cannot add the tool tip to the row because rows can't have children of that type.
                new ToolTip(rowSetup.ToolTipControl ?? ToolTip.GetToolTipTextControl(rowSetup.ToolTip), row);
            }
        }
Exemple #2
0
        private static TableCell buildCell(EwfTableCell ewfCell, RowSetup rowSetup, ColumnSetup columnSetup, bool tableIsColumnPrimary)
        {
            var colSpan = tableIsColumnPrimary ? ewfCell.Setup.ItemSpan : ewfCell.Setup.FieldSpan;
            var rowSpan = tableIsColumnPrimary ? ewfCell.Setup.FieldSpan : ewfCell.Setup.ItemSpan;

            var underlyingCell = (rowSetup.IsHeader || columnSetup.IsHeader) ? new TableHeaderCell() : new TableCell();

            underlyingCell.AddControlsReturnThis(ewfCell.Controls);
            if (colSpan == 1)
            {
                underlyingCell.Width = columnSetup.Width;
            }
            underlyingCell.CssClass = StringTools.ConcatenateWithDelimiter(
                " ",
                EwfTable.CssElementCreator.AllCellAlignmentsClass,
                columnSetup.CssClassOnAllCells,
                StringTools.ConcatenateWithDelimiter(" ", ewfCell.Setup.Classes.ToArray()));
            if (ewfCell.Setup.ClickScript != null)
            {
                ewfCell.Setup.ClickScript.SetUpClickableControl(underlyingCell);
            }

            if (!ewfCell.Setup.ToolTip.IsNullOrWhiteSpace() || ewfCell.Setup.ToolTipControl != null || !columnSetup.ToolTipOnCells.IsNullOrWhiteSpace())
            {
                var toolTipControl = ewfCell.Setup.ToolTipControl ??
                                     ToolTip.GetToolTipTextControl(!ewfCell.Setup.ToolTip.IsNullOrWhiteSpace() ? ewfCell.Setup.ToolTip : columnSetup.ToolTipOnCells);
                // NOTE: This comment is no longer accurate.
                // It is very important that we add the tool tip to the cell so that the tool tip is hidden if the row/cell is hidden.
                new ToolTip(toolTipControl, underlyingCell);
            }

            if (colSpan != 1)
            {
                underlyingCell.ColumnSpan = colSpan;
            }
            if (rowSpan != 1)
            {
                underlyingCell.RowSpan = rowSpan;
            }
            return(underlyingCell);
        }
Exemple #3
0
        /// <summary>
        /// Adds a row to this table.
        /// </summary>
        public void AddRow(RowSetup rowSetup, params EwfTableCell[] cells)
        {
            // If SetUpColumns was never called, implicitly set up the columns based on this first row.
            if (columnSetups == null)
            {
                columnSetups = cells.Select(c => new ColumnSetup()).ToList();
            }

            rowSetups.Add(rowSetup);
            if (!rowSetup.IsHeader)
            {
                dataRowCount++;
            }

            var defaultCsvLine = cells.Select(cell => (cell as CellPlaceholder).SimpleText).ToList();

            if (rowSetup.CsvLine == null)
            {
                rowSetup.CsvLine = defaultCsvLine;
            }

            // Verify that this row has the right number of cells.
            try {
                if (cells.Sum(c => c.Setup.FieldSpan) + previousRowColumnSpans.Sum(rcSpan => rcSpan.ColumnSpan) != columnSetups.Count)
                {
                    throw new ApplicationException("Row to be added has the wrong number of cells.");
                }

                // Despite that it would make no sense to do this and all latest browsers will draw tables incorrectly when this happens, I cannot find official documentation
                // saying that it is wrong. NOTE: This check isn't as good as the logic we are going to add to EwfTableItemRemainingData (to ensure that the item has at
                // least one cell) because it doesn't catch a case like two cells that each have a row span greater than one and together span all columns.
                if (cells.Any(c => c.Setup.ItemSpan > 1 && c.Setup.FieldSpan == columnSetups.Count))
                {
                    throw new ApplicationException("Cell may not take up all columns and span multiple rows.");
                }
            }
            catch (ApplicationException e) {
                if (!ConfigurationStatics.IsDevelopmentInstallation)
                {
                    TelemetryStatics.ReportError(e);
                }
                else
                {
                    throw;
                }
            }
            foreach (var rowColumnSpanPair in previousRowColumnSpans)
            {
                rowColumnSpanPair.RowSpan--;
            }

            previousRowColumnSpans =
                (previousRowColumnSpans.Where(rowSpan => rowSpan.RowSpan > 0)
                 .Concat(
                     cells.Where(c => c.Setup.ItemSpan != 1)
                     .Select(rowSpanCell => new RowColumnSpanPair {
                RowSpan = rowSpanCell.Setup.ItemSpan - 1, ColumnSpan = rowSpanCell.Setup.FieldSpan
            }))).ToList();

            var cellPlaceHolders = new List <CellPlaceholder>(cells);

            TableOps.DrawRow(table, rowSetup, cellPlaceHolders, columnSetups, false);
        }
Exemple #4
0
 /// <summary>
 /// Adds a row of controls to this table.
 /// </summary>
 public void AddRow(RowSetup rowSetup, params Control[] controls)
 {
     AddRow(rowSetup, controls.Select(c => (EwfTableCell)c).ToArray());
 }
Exemple #5
0
 /// <summary>
 /// Adds a text-only row to this table.
 /// </summary>
 public void AddTextRow(RowSetup rowSetup, params string[] cellText)
 {
     AddRow(rowSetup, cellText.Select(ct => (EwfTableCell)ct).ToArray());
 }
        private static TableCell buildCell( EwfTableCell ewfCell, RowSetup rowSetup, ColumnSetup columnSetup, bool tableIsColumnPrimary )
        {
            var colSpan = tableIsColumnPrimary ? ewfCell.Setup.ItemSpan : ewfCell.Setup.FieldSpan;
            var rowSpan = tableIsColumnPrimary ? ewfCell.Setup.FieldSpan : ewfCell.Setup.ItemSpan;

            var underlyingCell = ( rowSetup.IsHeader || columnSetup.IsHeader ) ? new TableHeaderCell() : new TableCell();
            underlyingCell.AddControlsReturnThis( ewfCell.Controls );
            if( colSpan == 1 )
                underlyingCell.Width = columnSetup.Width;
            underlyingCell.CssClass = StringTools.ConcatenateWithDelimiter(
                " ",
                EwfTable.CssElementCreator.AllCellAlignmentsClass,
                columnSetup.CssClassOnAllCells,
                StringTools.ConcatenateWithDelimiter( " ", ewfCell.Setup.Classes.ToArray() ) );
            if( ewfCell.Setup.ClickScript != null )
                ewfCell.Setup.ClickScript.SetUpClickableControl( underlyingCell );

            if( !ewfCell.Setup.ToolTip.IsNullOrWhiteSpace() || ewfCell.Setup.ToolTipControl != null || !columnSetup.ToolTipOnCells.IsNullOrWhiteSpace() ) {
                var toolTipControl = ewfCell.Setup.ToolTipControl ??
                                     ToolTip.GetToolTipTextControl( !ewfCell.Setup.ToolTip.IsNullOrWhiteSpace() ? ewfCell.Setup.ToolTip : columnSetup.ToolTipOnCells );
                // NOTE: This comment is no longer accurate.
                // It is very important that we add the tool tip to the cell so that the tool tip is hidden if the row/cell is hidden.
                new ToolTip( toolTipControl, underlyingCell );
            }

            if( colSpan != 1 )
                underlyingCell.ColumnSpan = colSpan;
            if( rowSpan != 1 )
                underlyingCell.RowSpan = rowSpan;
            return underlyingCell;
        }
        internal static void DrawRow(
            Table table, RowSetup rowSetup, List<CellPlaceholder> rowPlaceholder, List<ColumnSetup> columnSetups, bool tableIsColumnPrimary)
        {
            var row = new TableRow();
            rowSetup.UnderlyingTableRow = row;
            table.Rows.Add( row );

            row.CssClass = rowSetup.CssClass;
            if( rowSetup.ClickScript != null )
                rowSetup.ClickScript.SetUpClickableControl( row );

            for( var i = 0; i < rowPlaceholder.Count; i++ ) {
                if( rowPlaceholder[ i ] is EwfTableCell )
                    row.Cells.Add( buildCell( rowPlaceholder[ i ] as EwfTableCell, rowSetup, columnSetups[ i ], tableIsColumnPrimary ) );
            }

            if( ( !rowSetup.ToolTip.IsNullOrWhiteSpace() || rowSetup.ToolTipControl != null ) && row.Cells.Count > 0 ) {
                // NOTE: This comment is no longer accurate.
                // It is very important that we add the tool tip to the cell so that the tool tip is hidden if the row is hidden.
                // We cannot add the tool tip to the row because rows can't have children of that type.
                new ToolTip( rowSetup.ToolTipControl ?? ToolTip.GetToolTipTextControl( rowSetup.ToolTip ), row );
            }
        }
Exemple #8
0
 /// <summary>
 /// Adds a text-only row to this table.
 /// </summary>
 public void AddTextRow(RowSetup rowSetup, params string[] cellText)
 {
     AddRow(rowSetup, cellText.Select(ct => ct.ToCell()).ToArray());
 }