Beispiel #1
0
        //private void AddPartToView(PartConfig pconf, string description)
        //{
        //    ClientUICommon.syncContext.Post(o =>
        //   {
        //       int index = partView.Rows.Add();
        //       partView.Rows[index].Cells[0].Value = pconf.PartID;
        //       partView.Rows[index].Cells[1].Value = pconf.ProgFileName;
        //       partView.Rows[index].Cells[2].Value = pconf.NormFileName;
        //       partView.Rows[index].Cells[3].Value = pconf.FlvFileName;
        //       partView.Rows[index].Cells[4].Value = pconf.TolFileName;
        //       partView.Rows[index].Cells[5].Value = description;
        //   }, null);
        //}

        private void modifyToolStripButton1_Click(object sender, EventArgs e)
        {
            if (partView.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择一个工件", "信息", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            int          index  = partView.SelectedRows[0].Index;
            PartConfForm pcForm = new PartConfForm();

            pcForm.PartID          = ((PartConfig)partConfBs[index]).PartID;
            pcForm.PartProgram     = ((PartConfig)partConfBs[index]).ProgFileName;
            pcForm.PartDescription = ((PartConfig)partConfBs[index]).Description;
            if (pcForm.ShowDialog() == DialogResult.OK)
            {
                string path = PathManager.Instance.GetBladesFullPath(pcForm.PartID);
                if (!Directory.Exists(path))
                {
                    MessageBox.Show("blades目录不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.tol", SearchOption.TopDirectoryOnly).Length != 1)
                    {
                        MessageBox.Show("blades文件缺失", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                //if (PartConfigManager.Instance./*AddPartConfig*/Exists(pcForm.PartID))
                //{
                //    MessageBox.Show("工件已存在", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                ((PartConfig)partConfBs[index]).FlvFileName  = Path.GetFileName(Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly)[0]);
                ((PartConfig)partConfBs[index]).NormFileName = Path.GetFileName(Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly)[0]);
                ((PartConfig)partConfBs[index]).TolFileName  = Path.GetFileName(Directory.GetFiles(path, "*.Tol", SearchOption.TopDirectoryOnly)[0]);
                ((PartConfig)partConfBs[index]).PartID       = pcForm.PartID;
                ((PartConfig)partConfBs[index]).ProgFileName = Path.GetFileName(pcForm.PartProgram);
                ((PartConfig)partConfBs[index]).Description  = pcForm.PartDescription;
            }
        }
Beispiel #2
0
        private void addPartToolStripButton_Click(object sender, EventArgs e)
        {
            PartConfForm pcfm = new PartConfForm();

            if (pcfm.ShowDialog() == DialogResult.OK)
            {
                // 查找blades文件
                string path = PathManager.Instance.GetBladesFullPath(pcfm.PartID);
                if (!Directory.Exists(path))
                {
                    MessageBox.Show("blades目录不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly).Length != 1 ||
                        Directory.GetFiles(path, "*.tol", SearchOption.TopDirectoryOnly).Length != 1)
                    {
                        MessageBox.Show("blades文件缺失", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                // 添加工件配置
                if (PartConfigManager.Instance./*AddPartConfig*/ Exists(pcfm.PartID))
                {
                    MessageBox.Show("工件已存在", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                PartConfig pc = new PartConfig();
                pc.FlvFileName  = Path.GetFileName(Directory.GetFiles(path, "*.flv", SearchOption.TopDirectoryOnly)[0]);
                pc.NormFileName = Path.GetFileName(Directory.GetFiles(path, "*.nom", SearchOption.TopDirectoryOnly)[0]);
                pc.TolFileName  = Path.GetFileName(Directory.GetFiles(path, "*.Tol", SearchOption.TopDirectoryOnly)[0]);
                pc.PartID       = pcfm.PartID;
                pc.ProgFileName = Path.GetFileName(pcfm.PartProgram);
                pc.Description  = pcfm.PartDescription;

                partConfBs.Add(pc);

                // 更新工件Panel
                //partConfList.Add(pc);
                //partView.Refresh();
            }
        }