void DataGridViewCellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 1) //调试工作流
     {
         FormStationWorkFlowCfg dlg = new FormStationWorkFlowCfg();
         string workFlowName        = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string;
         dlg.SetStationWorkFlow(_station, workFlowName);
         dlg.ShowDialog();
     }
     else if (e.ColumnIndex == 2) //从文件中导入
     {
         string         workFlowName = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string;
         JFMethodFlow   flow         = _station.GetWorkFlow(workFlowName);
         OpenFileDialog ofd          = new OpenFileDialog();
         ofd.Filter = "JF流程文件(*.jff) | *.jff";
         //ofd.InitialDirectory = Application.StartupPath;
         ofd.ValidateNames   = true;
         ofd.CheckPathExists = true;
         ofd.CheckFileExists = false;
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             if (DialogResult.OK == MessageBox.Show(string.Format("确定将文件:{0} 导入到工作流{1}?", ofd.FileName, workFlowName)))
             {
                 try
                 {
                     flow.Load(ofd.FileName);
                     _station.SaveCfg();
                     MessageBox.Show("导入成功!");
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("载入失败!异常信息:" + ex.ToString());
                 }
             }
         }
     }
     else if (e.ColumnIndex == 3) //导出工作流到文件
     {
         string         workFlowName = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string;
         JFMethodFlow   flow         = _station.GetWorkFlow(workFlowName);
         OpenFileDialog ofd          = new OpenFileDialog();
         ofd.Filter = "JF流程文件(*.jff) | *.jff";
         //ofd.InitialDirectory = Application.StartupPath;
         ofd.ValidateNames   = true;
         ofd.CheckPathExists = true;
         ofd.CheckFileExists = false;
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             flow.Save(ofd.FileName);
             MessageBox.Show("导出文件成功!");
         }
     }
 }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            JFMethodFlow fl = new JFMethodFlow();

            fl.Load("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\123.jff");
            if (string.IsNullOrEmpty(fl.Name))
            {
                fl.Name = "Hehe";
                fl.Save("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\123.jff");
            }
            string       txt       = fl.ToTxt();
            JFMethodFlow anotherJF = new JFMethodFlow();

            anotherJF.FromTxt(txt);
            anotherJF.Save("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\456.jff");
        }
        /// <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;
        }