/// <summary> /// Generate Button on TableLayout with space cell type. /// </summary> /// <param name="buttons"></param> private void GenerateButton(WorkflowButtonList buttons) { if (ButtonList.Count == 0) { return; } int maxRow = 0; int maxCol = 0; // Find max row and column index on button list. Cell maxButtonCell = ButtonList.FindMaxRowColumnIndex(); maxRow = maxButtonCell.RowIndex; maxCol = maxButtonCell.ColumnIndex; // Find max row and column index on line deatil. Cell maxLineCell = LineHeaderList.FindMaxRowColumnIndex(); maxRow = Math.Max(maxRow, maxLineCell.RowIndex); maxCol = Math.Max(maxCol, maxLineCell.ColumnIndex); //== Generate Row. ParentWorkflow.RowCount = Math.Max(0, ((maxRow + 1) * 2) - 1); for (int i = 0; i < ParentWorkflow.RowCount; i++) { WorkflowRowStyle row = null; if (i % 2 == 0) { // It's Button. row = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.Button); row.Height = BUTTON_HEIGHT; } else { // It's VSpace. row = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.Space); row.Height = VSPACE_HEIGHT; } ParentWorkflow.RowStyles.Add(row); } //== Generate Column ParentWorkflow.ColumnCount = Math.Max(0, ((maxCol + 1) * 2) - 1); for (int i = 0; i < ParentWorkflow.ColumnCount; i++) { WorkflowColumnStyle col = null; if (i % 2 == 0) { // It's Button. col = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.Button); col.Width = BUTTON_WIDTH; } else { // It's HSpace. col = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.Space); col.Width = HSPACE_WIDTH; } ParentWorkflow.ColumnStyles.Add(col); } //== Put button into cell. for (int i = 0; i < ButtonList.Count; i++) { WorkflowButton btn = ButtonList[i]; WorkflowButtonArgs buttonArgs = new WorkflowButtonArgs(); buttonArgs.Data = btn.Data; // Raise event when button has loading. // User can bind event "ButtonLoad" to override our Text and Image. ParentWorkflow.OnButtonLoad(buttonArgs); btn.Text = buttonArgs.Text; btn.Image = buttonArgs.Image; btn.BackColor = Color.Transparent; // Add control into table's cell. Cell cell = GetIndexWorkFlowButtonCell(btn.Data.ROW_INDEX, btn.Data.COL_INDEX); ParentWorkflow.Controls.Add(btn, cell.ColumnIndex, cell.RowIndex); btn.Dock = DockStyle.Fill; } }