Beispiel #1
0
        /// <summary>
        /// 添加一个方法对象到动作流中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem_Add_Click(object sender, EventArgs e)
        {
            Type         methodType     = currNode.Tag as Type;
            string       dafaultNewName = _methodFlow.GetDefaultNameWillAddMethod(methodType);
            BenameDialog bnd            = new BenameDialog();

            bnd.Text = "新方法节点命名";
            bnd.SetName(dafaultNewName);
            if (DialogResult.OK != bnd.ShowDialog())
            {
                return;
            }
            IJFMethod newMethod = JFMethodFlow.CreateMethod(methodType.Name);
            bool      isOK      = _methodFlow.Add(newMethod, bnd.GetName());

            if (isOK)
            {
                ToolStripMenuItem_Insert.Enabled = true;
                ShowTips("添加动作节点成功!");
                UpdateFlow2UI();
            }
            else
            {
                MessageBox.Show("添加动作节点失败,请检查动作名称是否已存在于流程中!");
                return;
            }
        }
Beispiel #2
0
        private void ToolStripMenuItem_Insert_Click(object sender, EventArgs e)
        {
            int idx = toolStripComboBox_Index.SelectedIndex;

            if (idx < 0)
            {
                MessageBox.Show("请选择动作节点序号");
                return;
            }

            Type         methodType     = currNode.Tag as Type;
            string       dafaultNewName = _methodFlow.GetDefaultNameWillAddMethod(methodType);
            BenameDialog bnd            = new BenameDialog();

            bnd.Text = "新方法节点命名";
            bnd.SetName(dafaultNewName);
            if (DialogResult.OK != bnd.ShowDialog())
            {
                return;
            }
            IJFMethod newMethod = JFMethodFlow.CreateMethod(methodType.Name);
            bool      isOK      = _methodFlow.Insert(newMethod, idx, bnd.GetName());

            if (isOK)
            {
                ShowTips("插入动作节点成功!");
                UpdateFlow2UI();
            }
            else
            {
                MessageBox.Show("插入动作节点失败,请检查\n节点序号是否超限/动作名称是否已存在于流程中!");
                return;
            }
        }
        /// <summary>新建动作流</summary>
        private void ToolStripMenuItem_Create_Click(object sender, EventArgs e)
        {
            if (null != methodFlow)
            {
                if (null != currFilePath) //当前对象是从文件中载入的
                {
                    if (DialogResult.Yes == MessageBox.Show("建立新流程之前,是否保存当前动作流程?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        methodFlow.Save(currFilePath);
                    }
                }
                else //当前对象还没有保存到文件中
                {
                    if (DialogResult.Yes == MessageBox.Show("是否将当前动作流程保存到文件中?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        SaveFileDialog sfd = new SaveFileDialog();
                        sfd.Filter       = "JF流程文件(*.jff)|*.jff"; //设置文件类型
                        sfd.FileName     = "保存";                  //设置默认文件名
                        sfd.DefaultExt   = "jff";                 //设置默认格式(可以不设)
                        sfd.AddExtension = true;                  //设置自动在文件名中添加扩展名
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            methodFlow.Save(sfd.FileName);
                        }
                    }
                }
            }
            BenameDialog bnd = new BenameDialog();

            bnd.SetName("未命名方法流");
            if (DialogResult.OK != bnd.ShowDialog())
            {
                return;
            }
            currFilePath    = null;
            methodFlow      = new JFMethodFlow();
            methodFlow.Name = bnd.GetName();
            ucMethodFlow.SetMethodFlow(methodFlow);
            tstbFilePath.Text = "";
            ToolStripMenuItem_Save.Enabled   = false;
            ToolStripMenuItem_SaveAs.Enabled = true;
        }
        /// <summary>
        /// 添加新点位
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btAdd_Click(object sender, EventArgs e)
        {
            BenameDialog nameDialog = new BenameDialog();

            nameDialog.Text = "添加新点位";
            if (nameDialog.ShowDialog() == DialogResult.OK)
            {
                string posName = nameDialog.GetName();
                if (_station.ContianPositionName(posName))
                {
                    MessageBox.Show("不能添加已存在的点位名称:" + posName);
                    return;
                }
                JFMultiAxisPosition newPos = new JFMultiAxisPosition();
                newPos.Name = posName;
                _station.AddWorkPosition(newPos);
                DataGridViewRow         row      = new DataGridViewRow();
                DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                cellName.Value = posName;
                row.Cells.Add(cellName);
                foreach (string axisName in _station.AxisNames)
                {
                    DataGridViewCheckBoxCell chkEnable = new DataGridViewCheckBoxCell();
                    chkEnable.Value = false;
                    row.Cells.Add(chkEnable);
                    DataGridViewTextBoxCell cellPos = new DataGridViewTextBoxCell();
                    cellPos.Style.BackColor = SystemColors.ControlDark;
                    row.Cells.Add(cellPos);
                }
                DataGridViewButtonCell btCell = new DataGridViewButtonCell();
                btCell.Value = "更新";
                row.Cells.Add(btCell);
                dgvPos.Rows.Add(row);
                btDel.Enabled = true;
            }
        }