コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="rowStyle"></param>
        internal void InsertRow(int index, WorkflowRowStyle rowStyle)
        {
            if (index < 0 || index > this.RowCount)
            {
                throw new ArgumentOutOfRangeException(String.Format("Index : {0} out of range.", index));
            }

            // Update new row style.
            if (index == this.RowCount)
            {
                this.RowStyles.Add(rowStyle);
            }
            else
            {
                this.RowStyles.Insert(index, rowStyle);
            }

            // Add new row.
            this.RowCount++;

            // Move control to new location.
            for (int i = 0; i < this.Controls.Count; i++)
            {
                Control control = Controls[i];
                TableLayoutPanelCellPosition cellPosition = this.GetCellPosition(control);
                if (cellPosition.Row >= index)
                {
                    SetRow(control, cellPosition.Row + 1);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Get Row and Column index which cell type is Button on TableLayout
        /// </summary>
        /// <param name="row">Row index of button.</param>
        /// <param name="col">Column index of button.</param>
        /// <returns></returns>
        internal Cell GetIndexWorkFlowButtonCell(int rowButton, int colButton)
        {
            int buttonRow = 0;
            int buttonCol = 0;
            int index     = -1;

            //== Find Row button cell.
            for (int i = 0; i < ParentWorkflow.RowStyles.Count; i++)
            {
                WorkflowRowStyle rowStyle = ParentWorkflow.RowStyles[i] as WorkflowRowStyle;
                if (rowStyle == null)
                {
                    throw new ArgumentException("Invalid WorkflowRowStyle");
                }

                if (rowStyle.ColumnType == WorkflowRowType.Button)
                {
                    index++;
                }

                if (index == rowButton)
                {
                    buttonRow = i;
                    break;
                }
            }

            //== Find Row button cell.
            index = -1;
            for (int i = 0; i < ParentWorkflow.ColumnStyles.Count; i++)
            {
                WorkflowColumnStyle colStyle = ParentWorkflow.ColumnStyles[i] as WorkflowColumnStyle;
                if (colStyle == null)
                {
                    throw new ArgumentException("Invalid WorkflowRowStyle");
                }

                if (colStyle.ColumnType == WorkflowColumnType.Button)
                {
                    index++;
                }

                if (index == colButton)
                {
                    buttonCol = i;
                    break;
                }
            }

            return(new Cell(ParentWorkflow, buttonRow, buttonCol));
        }
コード例 #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>
        /// 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;
            }
        }