Beispiel #1
0
        /// <summary>
        /// Extract EndPoint from lines header list.
        /// </summary>
        /// <param name="lines"></param>
        private List <WorkflowLineDetail> ExtractEndPoint(WorkflowLineHeaderList lines)
        {
            List <WorkflowLineDetail> list = new List <WorkflowLineDetail>();

            for (int i = 0; i < lines.Count; i++)
            {
                WorkflowLineDetail lineDetail = lines[i].GetLineEndPoint();
                if (lineDetail != null)
                {
                    list.Add(lineDetail);
                }
            }

            return(list);
        }
Beispiel #2
0
        private void GenerateArrowSpaceForEndPoint(List <WorkflowLineDetail> lineEndPoints)
        {
            for (int i = 0; i < lineEndPoints.Count(); i++)
            {
                WorkflowLineDetail    line      = lineEndPoints[i];
                WorkflowLineDirection direction = line.GetLineDirection();

                Cell cell = GetIndexWorkFlowButtonCell(line.ToCell.RowIndex, line.ToCell.ColumnIndex);

                WorkflowColumnStyle columnStyle = null;
                WorkflowRowStyle    rowStyle    = null;

                switch (direction)
                {
                case WorkflowLineDirection.LEFT:
                    // add space on right side of Button cell.
                    columnStyle       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.DisplayArrow);
                    columnStyle.Width = ARROW_SPACE;

                    ParentWorkflow.InsertColumn(cell.ColumnIndex + 1, columnStyle);
                    break;

                case WorkflowLineDirection.TOP:
                    // add space on bottom side of Button cell.
                    rowStyle        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.DisplayArrow);
                    rowStyle.Height = ARROW_SPACE;

                    ParentWorkflow.InsertRow(cell.RowIndex + 1, rowStyle);
                    break;

                case WorkflowLineDirection.RIGHT:
                    // add space on left side of Button cell.
                    columnStyle       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.DisplayArrow);
                    columnStyle.Width = ARROW_SPACE;

                    ParentWorkflow.InsertColumn(cell.ColumnIndex, columnStyle);
                    break;

                case WorkflowLineDirection.BOTTOM:
                    // add space on top side of Button cell.
                    rowStyle        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.DisplayArrow);
                    rowStyle.Height = ARROW_SPACE;

                    ParentWorkflow.InsertRow(cell.RowIndex, rowStyle);
                    break;
                }
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        /// <summary>
        /// Drawing line follow line detail direction.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="line">Line detail of start-end point that will drawing</param>
        private void DrawLine(Graphics g, WorkflowLineDetail line)
        {
            Cell fromCell = GetIndexWorkFlowButtonCell(line.FromCell.RowIndex, line.FromCell.ColumnIndex);
            Cell toCell   = GetIndexWorkFlowButtonCell(line.ToCell.RowIndex, line.ToCell.ColumnIndex);

            Cell startCell = null;
            Cell endCell   = null;

            WorkflowLineDirection direction = line.GetLineDirection();

            switch (direction)
            {
            case WorkflowLineDirection.LEFT:
                if (line.Status == WorkflowLineStatus.EndPoint)
                {
                    toCell.ColumnIndex += 1;
                }
                startCell = toCell;
                endCell   = fromCell;
                break;

            case WorkflowLineDirection.TOP:
                if (line.Status == WorkflowLineStatus.EndPoint)
                {
                    toCell.RowIndex += 1;
                }
                startCell = toCell;
                endCell   = fromCell;
                break;

            case WorkflowLineDirection.RIGHT:
                if (line.Status == WorkflowLineStatus.EndPoint)
                {
                    toCell.ColumnIndex -= 1;
                }
                startCell = fromCell;
                endCell   = toCell;
                break;

            case WorkflowLineDirection.BOTTOM:
                if (line.Status == WorkflowLineStatus.EndPoint)
                {
                    toCell.RowIndex -= 1;
                }
                startCell = fromCell;
                endCell   = toCell;
                break;

            case WorkflowLineDirection.NONE:
                return;
            }

            if (startCell == null || endCell == null)
            {
                return;
            }

            // Draw Straight-Line (Without Arrow).
            Rectangle lineRect = GetLineRectangle(startCell, endCell, direction);

            Image img = GetImageFromLineDirection(direction);

            //img = ImageHelper.GetThumbnailImage(img, lineRect.Width, lineRect.Height);
            img = ImageHelper.ResizeImage(img, lineRect.Width, lineRect.Height);

            g.DrawImage(img, lineRect);
            img.Dispose();

            if (line.Status == WorkflowLineStatus.EndPoint)
            {
                Image     arrowImg  = GetArrowImageFromLineDirection(direction);
                Rectangle arrowRect = GetArrowRectangle(toCell, direction);
                g.DrawImage(arrowImg, arrowRect);
            }
        }