/// <summary>
        /// 新建工作流
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btAdd_Click(object sender, EventArgs e)
        {
            FormAddFlow2Station dlg = new FormAddFlow2Station();

            dlg.Text = _station.Name + " 添加工作流";
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }
            string flowName2Add = dlg.WorkFlowName;

            string[] existNames = _station.WorkFlowNames;
            if (null != existNames)
            {
                foreach (string nm in existNames)
                {
                    if (nm == flowName2Add)
                    {
                        MessageBox.Show("添加工作流失败!已存在同名称对象:" + flowName2Add);
                        return;
                    }
                }
            }
            JFMethodFlow flow2Add = new JFMethodFlow();

            if (dlg.IsLoadedFromFile)
            {
                flow2Add.Load(dlg.FilePath);
            }
            flow2Add.Name = flowName2Add;
            _station.AddWorkFlow(flow2Add);
            _station.SaveCfg();
            UpdateStation2UI();
        }
 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("导出文件成功!");
         }
     }
 }
Exemple #3
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>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem_LoadFromFile_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);
                        }
                    }
                }
            }

            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)
            {
                currFilePath = ofd.FileName;
                methodFlow   = new JFMethodFlow();
                methodFlow.Load(currFilePath);
                tstbFilePath.Text = currFilePath;
                ucMethodFlow.SetMethodFlow(methodFlow);
                ToolStripMenuItem_Save.Enabled   = true;
                ToolStripMenuItem_SaveAs.Enabled = true;
            }
        }