/// <summary> /// /// </summary> /// <param name="buttons"></param> /// <param name="lineHeaders"></param> public void StartGenerateWorkflow(WorkflowButtonList buttons, WorkflowLineHeaderList lineHeaders) { #warning Please remove: TableLayout show cell border. //ParentWorkflow.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; ButtonList = buttons; LineHeaderList = lineHeaders; //== Create Button and Space cell. GenerateButton(buttons); //== Extract EndPoint line. m_lineEndPoint.Clear(); m_lineEndPoint.AddRange(ExtractEndPoint(LineHeaderList)); //== Calculate area for EndPoint GenerateArrowSpaceForEndPoint(m_lineEndPoint); }
/// <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; } }
public static WorkflowDocument LoadDatabase(Database db, string workflowID, string USER_ACCOUNT) { WorkflowButtonList buttonList = new WorkflowButtonList(); WorkflowLineHeaderList lineHeaderList = new WorkflowLineHeaderList(); ButtonDAO daoButton = new ButtonDAO(); LineHeaderDAO daoLineHeader = new LineHeaderDAO(); LineDetailDAO daoLineDetail = new LineDetailDAO(); ConnectorDAO daoConnector = new ConnectorDAO(); #region " Load Buttons " //== Generate all Button (not binding event click) // Event ButtonClick will bind when assign document to viewer. List <ButtonDTO> listButtons = daoButton.FindButton(db, workflowID, USER_ACCOUNT, SystemMaintenance.DataDefine.AUTO_ARRANGE_ICON, SystemMaintenance.DataDefine.ICON_PER_ROW); for (int i = 0; i < listButtons.Count; i++) { ButtonDTO dto = listButtons[i]; WorkflowButton button = new WorkflowButton(dto); button.Dock = DockStyle.Fill; button.Anchor = AnchorStyles.None; button.Name = String.Format("{0}.{1}.{2}", dto.WF_ID, dto.ROW_INDEX, dto.COL_INDEX); //button.Click += new EventHandler(buttonClick); button.Location = new Point(0, 0); if (dto.FLG_VIEW == 1) { button.Visible = true; } else { button.Visible = false; } // add to collection buttonList.Add(button); } #endregion //ถ้าเปิดให้ auto arrange icon จะไม่มี work flow line if (SystemMaintenance.DataDefine.AUTO_ARRANGE_ICON != true) { #region " Load Lines " List <LineHeaderDTO> listLineHeader = daoLineHeader.GetLineHeaders(db, workflowID); for (int i = 0; i < listLineHeader.Count; i++) { LineHeaderDTO lineHeaderDTO = listLineHeader[i]; List <LineDetailDTO> listLineDetail = daoLineDetail.GetLineDetails(db, workflowID, lineHeaderDTO.ID); List <ConnectorDTO> listConnector = daoConnector.GetConnectors(db, workflowID, lineHeaderDTO.ID); // Create Model Header WorkflowLineHeader wf_header = new WorkflowLineHeader(null, lineHeaderDTO.ID, lineHeaderDTO.ZINDEX); // Loop for Create inner Model LineDetail. for (int iLine = 0; iLine < listLineDetail.Count; iLine++) { LineDetailDTO lineDetailDTO = listLineDetail[iLine]; WorkflowLineDetail wf_detail = new WorkflowLineDetail(wf_header , new Cell(null, lineDetailDTO.FROM_ROW, lineDetailDTO.FROM_COL) , new Cell(null, lineDetailDTO.TO_ROW, lineDetailDTO.TO_COL) , (WorkflowLineStatus)lineDetailDTO.STATUS); wf_header.Lines.Add(wf_detail); } // Loop for Create inner Model LineConnector. for (int iConnector = 0; iConnector < listConnector.Count; iConnector++) { ConnectorDTO connectorDTO = listConnector[iConnector]; WorkflowLineConnector wf_connector = new WorkflowLineConnector(wf_header , new Cell(null, connectorDTO.ROW_INDEX, connectorDTO.COL_INDEX) , (WorkflowConnectorType) connectorDTO.STATUS); wf_header.Connectors.Add(wf_connector); } lineHeaderList.Add(wf_header); } #endregion } WorkflowDocument document = new WorkflowDocument(workflowID, buttonList, lineHeaderList); return(document); }
internal WorkflowDocument(string workflowID, WorkflowButtonList buttonList, WorkflowLineHeaderList lineHeaderList) { m_workflowID = workflowID; ButtonList = buttonList; LineHeaderList = lineHeaderList; }