public DefinitionsController(string id, int leftWidth, int rightWidth, int checkWidth) { // Publish the supplied identifier for the definitions controller this.Id = id; // Build the display name and description labels which will be presented in the // header row for the definitions controller // A padding label is added to provide seperation from standard controls on the form // The display name and description labels will be hidden until values are supplied to them via properties Label padding = new Label(); padding.Font.Size = 2; this.displayName.CssClass = CssClass.TextCssClass; this.description.CssClass = CssClass.TextCssClass; this.displayName.Font.Bold = true; padding.Width = 600; this.displayName.Width = 600; this.description.Width = 600; this.displayName.Visible = false; this.description.Visible = false; // Build the Add, Delete, Move Up, and Move Down link buttons and add event handlers this.add.Text = ActivitySettings.LinkButtonAdd; this.delete.Text = ActivitySettings.LinkButtonDelete; this.moveUp.Text = ActivitySettings.LinkButtonMoveUp; this.moveDown.Text = ActivitySettings.LinkButtonMoveDown; this.add.CssClass = CssClass.TextCssClass; this.delete.CssClass = CssClass.TextCssClass; this.moveUp.CssClass = CssClass.TextCssClass; this.moveDown.CssClass = CssClass.TextCssClass; this.add.Font.Bold = true; this.delete.Font.Bold = true; this.moveUp.Font.Bold = true; this.moveDown.Font.Bold = true; this.add.Click += this.Add_Click; this.delete.Click += this.Delete_Click; this.moveUp.Click += this.MoveUp_Click; this.moveDown.Click += this.MoveDown_Click; // Build the command table TableRow commandRow = new TableRow(); Table commandTable = new Table { BorderWidth = 0, CellPadding = 0 }; commandTable.Rows.Add(commandRow); TableCell addCell = new TableCell { Height = 20, Width = 30, VerticalAlign = VerticalAlign.Bottom }; addCell.Controls.Add(this.add); commandRow.Cells.Add(addCell); TableCell deleteCell = new TableCell { Height = 20, Width = 45, VerticalAlign = VerticalAlign.Bottom }; deleteCell.Controls.Add(this.delete); commandRow.Cells.Add(deleteCell); TableCell moveUpCell = new TableCell { Height = 20, Width = 58, VerticalAlign = VerticalAlign.Bottom }; moveUpCell.Controls.Add(this.moveUp); commandRow.Cells.Add(moveUpCell); TableCell moveDownCell = new TableCell { Height = 20, Width = 70, VerticalAlign = VerticalAlign.Bottom }; moveDownCell.Controls.Add(this.moveDown); commandRow.Cells.Add(moveDownCell); // Build the controls which will be added to the header // for the update definitions table this.leftLabel.CssClass = CssClass.TextCssClass; this.rightLabel.CssClass = CssClass.TextCssClass; this.checkLabel.CssClass = CssClass.TextCssClass; this.leftLabel.Width = leftWidth; this.rightLabel.Width = rightWidth; this.checkLabel.Width = checkWidth; // Build the table cells and rows which will constitute the command bar (add/delete) // and header for the update definitions table // Add the controls to the appropriate cells and the cells to the appropriate rows // Add both rows to the update definitions table TableCell commandCell = new TableCell(); TableCell leftCell = new TableCell(); TableCell rightCell = new TableCell(); TableCell checkCell = new TableCell(); commandCell.ColumnSpan = 3; TableRow commands = new TableRow(); TableRow definitionsHeader = new TableRow(); commandCell.Controls.Add(commandTable); leftCell.Controls.Add(this.leftLabel); rightCell.Controls.Add(this.rightLabel); checkCell.Controls.Add(this.checkLabel); commands.Cells.Add(commandCell); definitionsHeader.Cells.Add(new TableCell()); definitionsHeader.Cells.Add(leftCell); definitionsHeader.Cells.Add(rightCell); definitionsHeader.Cells.Add(checkCell); TableCell textCell = new TableCell { ColumnSpan = 3 }; textCell.Controls.Add(padding); textCell.Controls.Add(this.displayName); textCell.Controls.Add(this.description); this.headerRow.Cells.Add(textCell); // Build a new definitions table and add it to the table row which is to be returned // This table row will be added to the form generated by the form controller and, consequently, // the cell which holds the table must be configured to span the standard 3 columns for that form Table definitionsTable = new Table { BorderWidth = 0, CellPadding = 2 }; TableCell definitionsCell = new TableCell { ColumnSpan = 3 }; definitionsCell.Controls.Add(definitionsTable); this.tableRow.Cells.Add(definitionsCell); definitionsTable.Rows.Add(commands); definitionsTable.Rows.Add(definitionsHeader); // Create 1000 new update definitions listings for the form // Because the constructor for this class is called multiple times during user input, // all controls must be pre-added and there is no way to support the dynamic adding of update // definition listings via the add button // Consequently, all listings will be added in a hidden state, except for one, and the add/delete // buttons will be used to manage the visibility of the associated table rows for (int i = 0; i < 1000; i++) { DefinitionListing listing = new DefinitionListing(id, this.definitionListings.Count, leftWidth, rightWidth, checkWidth); this.definitionListings.Add(listing); definitionsTable.Rows.Add(listing.TableRow); } this.definitionListings[0].Active = true; }