Exemplo n.º 1
0
        private void createChildControlsAndWireUpEvents()
        {
            captionTable          = TableStatics.CreateUnderlyingTable();
            captionTable.CssClass = "ewfStandardDynamicTableCaption";
            captionTable.Visible  = false;
            var row = new TableRow();

            var captionCell = new TableCell();

            captionCell.Controls.Add(captionStack = ControlStack.Create(false));
            row.Cells.Add(captionCell);

            var actionLinksCell = new TableCell {
                CssClass = "ewfAddItemLink"
            };

            actionLinksCell.Controls.Add(actionLinkStack = ControlStack.Create(false));
            row.Cells.Add(actionLinksCell);

            captionTable.Rows.Add(row);
            Controls.Add(captionTable);

            table = TableStatics.CreateUnderlyingTable();
            Controls.Add(table);

            PreRender += ewfTable_PreRender;

            dataModifications = FormState.Current.DataModifications;
        }
        /// <summary>
        /// Creates a new instance of a Control Line with the given controls.
        /// </summary>
        public ControlLine(params Control[] controls)
        {
            var table = TableStatics.CreateUnderlyingTable();

            table.Rows.Add(row = new TableRow());
            base.Controls.Add(table);
            AddControls(controls);
            VerticalAlignment = TableCellVerticalAlignment.NotSpecified;
        }
Exemplo n.º 3
0
        private void ewfTable_PreRender(object sender, EventArgs e)
        {
            // NOTE: This should all move to ControlTreeDataLoader.LoadData, but it can't right now because so many pages add table rows from PreRender.
            TableStatics.AlternateRowColors(table, rowSetups);

            // NOTE: We should be able to get rid of this row hiding when we port everything over to use AddAllDataToTable.
            var dataRowIndex = 0;

            for (var rowIndex = 0; rowIndex < rowSetups.Count; rowIndex++)
            {
                table.Rows[rowIndex].Visible = dataRowIndex++ < CurrentDataRowLimit;
            }
        }
Exemplo n.º 4
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);

            TableStatics.DrawRow(table, rowSetup, cellPlaceHolders, columnSetups, false);
        }