示例#1
0
        private Rectangle GetLineRectangle(Cell from, Cell to, WorkflowLineDirection direction)
        {
            Rectangle rectStartCell = GetCellRectangle(new Cell(null, from.RowIndex, from.ColumnIndex));
            Rectangle rectEndCell   = GetCellRectangle(new Cell(null, to.RowIndex, to.ColumnIndex));

            Rectangle lineRectangle = Rectangle.Empty;

            switch (direction)
            {
            case WorkflowLineDirection.LEFT:
            case WorkflowLineDirection.RIGHT:
                // Horizontal Line
                Image hline = ParentWorkflow.LineImage.HLINE;
                lineRectangle.X      = rectStartCell.X + (rectStartCell.Width / 2);
                lineRectangle.Y      = rectStartCell.Y + (rectStartCell.Height / 2) - (hline.Height / 2);
                lineRectangle.Height = hline.Height;

                lineRectangle.Width = (rectEndCell.X + (rectEndCell.Width / 2)) - lineRectangle.X;
                break;

            case WorkflowLineDirection.TOP:
            case WorkflowLineDirection.BOTTOM:
                // Vertical Line
                Image vline = ParentWorkflow.LineImage.VLINE;
                lineRectangle.X     = rectStartCell.X + (rectStartCell.Width / 2) - (vline.Width / 2);
                lineRectangle.Y     = rectStartCell.Y + (rectStartCell.Height / 2);
                lineRectangle.Width = vline.Width;

                lineRectangle.Height = rectEndCell.Y + (rectEndCell.Height / 2) - lineRectangle.Y;
                break;
            }

            return(lineRectangle);
        }
示例#2
0
        /// <summary>
        /// Get image of line from line direction.
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        private Image GetImageFromLineDirection(WorkflowLineDirection direction)
        {
            switch (direction)
            {
            case WorkflowLineDirection.LEFT:
            case WorkflowLineDirection.RIGHT:
                return(ParentWorkflow.LineImage.HLINE);

            case WorkflowLineDirection.TOP:
            case WorkflowLineDirection.BOTTOM:
                return(ParentWorkflow.LineImage.VLINE);
            }

            return(ParentWorkflow.LineImage.EMPTY);
        }
示例#3
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;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Get image of arrow from line direction.
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        private Image GetArrowImageFromLineDirection(WorkflowLineDirection direction)
        {
            switch (direction)
            {
            case WorkflowLineDirection.LEFT:
                return(ParentWorkflow.LineImage.ARROW_LEFT);

            case WorkflowLineDirection.TOP:
                return(ParentWorkflow.LineImage.ARROW_UP);

            case WorkflowLineDirection.RIGHT:
                return(ParentWorkflow.LineImage.ARROW_RIGHT);

            case WorkflowLineDirection.BOTTOM:
                return(ParentWorkflow.LineImage.ARROW_DOWN);
            }

            return(ParentWorkflow.LineImage.EMPTY);
        }
示例#5
0
        private Rectangle GetArrowRectangle(Cell cell, WorkflowLineDirection direction)
        {
            Rectangle cellRect = GetCellRectangle(cell);


            Image arrowImg = GetArrowImageFromLineDirection(direction);

            Rectangle arrowRect = Rectangle.Empty;

            arrowRect.Width  = arrowImg.Width;
            arrowRect.Height = arrowImg.Height;
            switch (direction)
            {
            case WorkflowLineDirection.LEFT:
                arrowRect.X = cellRect.X;
                arrowRect.Y = cellRect.Y + (cellRect.Height / 2) - (arrowImg.Height / 2);
                break;

            case WorkflowLineDirection.TOP:
                arrowRect.X = cellRect.X + (cellRect.Width / 2) - (arrowImg.Width / 2);
                arrowRect.Y = cellRect.Y;
                break;

            case WorkflowLineDirection.RIGHT:
                arrowRect.X = cellRect.Right - arrowRect.Width;
                arrowRect.Y = cellRect.Y + (cellRect.Height / 2) - (arrowImg.Height / 2);
                break;

            case WorkflowLineDirection.BOTTOM:
                arrowRect.X = cellRect.X + (cellRect.Width / 2) - (arrowImg.Width / 2);
                arrowRect.Y = cellRect.Bottom - arrowImg.Height;
                break;

            case WorkflowLineDirection.NONE:
                break;

            default:
                throw new ArgumentOutOfRangeException("direction");
            }

            return(arrowRect);
        }
示例#6
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);
            }
        }