예제 #1
0
        private void EqTreeViewAdd()
        {
            TreeNode selectedNode = _eqTreeView.SelectedNode;

            switch (selectedNode.Text)
            {
            //显示属性初始化窗口
            case "PPCs":
                PPCInitForm ppcInitForm = new PPCInitForm();
                ppcInitForm.ShowDialog();
                if (ppcInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, ppcInitForm.GetObjectName(), Princeple.FormType.PPC);
                }
                ppcInitForm.Dispose();
                break;

            case "FPGAs":
                FPGAInitForm fpgaInitForm = new FPGAInitForm();
                fpgaInitForm.ShowDialog();
                if (fpgaInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, fpgaInitForm.GetObjectName(), Princeple.FormType.FPGA);
                }
                fpgaInitForm.Dispose();
                break;

            case "ZYNQs":
                ZYNQInitForm zynqInitForm = new ZYNQInitForm();
                zynqInitForm.ShowDialog();
                if (zynqInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, zynqInitForm.GetObjectName(), Princeple.FormType.ZYNQ);
                }
                zynqInitForm.Dispose();
                break;

            case "板卡库":
                BoardInitForm boardInitForm = new BoardInitForm();
                boardInitForm.ShowDialog();

                if (boardInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, boardInitForm.BoardNodeName, Princeple.FormType.BOARD);
                }
                boardInitForm.Dispose();
                break;

            case "背板库":
                BackPlaneInitForm bpInitForm = new BackPlaneInitForm();
                bpInitForm.ShowDialog();
                if (bpInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, bpInitForm.GetObjectName(), Princeple.FormType.BACKPLANE);
                }
                bpInitForm.Dispose();
                break;

            case "机箱库":
                ContainerInitForm ctnInitForm = new ContainerInitForm();
                ctnInitForm.ShowDialog();
                if (ctnInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, ctnInitForm.GetObjectName(), Princeple.FormType.CONTIANER);
                    ctnInitForm.Dispose();
                }
                break;

            case "系统库":
                SystemStruInitForm sysInitForm = new SystemStruInitForm();
                sysInitForm.ShowDialog();
                if (sysInitForm.DialogResult == DialogResult.Yes)
                {
                    NodeInfo.AddChildrenNode(selectedNode, sysInitForm.GetObjectName(), Princeple.FormType.SYSTEM);
                    sysInitForm.Dispose();
                }
                break;

            default:
                break;
            }
            //无论有无文件内容更改都把TreeView的内容读入对应xml文件内
            XMLManager.HandleTreeView.ReadTreeViewToXML(_eqTreeView, XMLManager.PathManager.GetEqLibFilePath());
        }
예제 #2
0
        /*组件修改*/
        private void ContextMSModify_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = _eqTreeView.SelectedNode;
            string   oldNodeName  = selectedNode.Text;

            switch (selectedNode.Parent.Text)
            {
            case "PPCs":
                //通过读取XML文件初始化PPC,然后用一个PPC实例初始化PPCInitForm
                PPC ppc = ModelFactory <PPC> .CreateByName(selectedNode.Text);

                PPCInitForm ppcInitForm = new PPCInitForm(ppc);
                ppcInitForm.ShowDialog();

                if (ppcInitForm.DialogResult == DialogResult.Yes)
                {
                    if (ppcInitForm.GetObjectName() != oldNodeName)
                    {    //改了名字的话,要删除老文件
                        selectedNode.Text = ppcInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetPPCPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                ppcInitForm.Dispose();
                break;

            case "FPGAs":
                FPGA fpga = ModelFactory <FPGA> .CreateByName(selectedNode.Text);

                FPGAInitForm fpgaInitForm = new FPGAInitForm(fpga);
                fpgaInitForm.ShowDialog();

                if (fpgaInitForm.DialogResult == DialogResult.Yes)
                {
                    if (fpgaInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = fpgaInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetFPGAPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                fpgaInitForm.Dispose();
                break;

            case "ZYNQs":
                ZYNQ zynq = ModelFactory <ZYNQ> .CreateByName(selectedNode.Text);

                ZYNQInitForm zynqInitForm = new ZYNQInitForm(zynq);
                zynqInitForm.ShowDialog();

                if (zynqInitForm.DialogResult == DialogResult.Yes)
                {
                    if (zynqInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = zynqInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetZYNQPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                zynqInitForm.Dispose();
                break;

            case "板卡库":
                Board board = ModelFactory <Board> .CreateByName(selectedNode.Text);

                BoardInitForm boardInitForm = new BoardInitForm(board);
                boardInitForm.ShowDialog();

                if (boardInitForm.DialogResult == DialogResult.Yes)
                {
                    if (boardInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = boardInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetBoardPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                boardInitForm.Dispose();
                break;

            case "背板库":
                BackPlane bp = ModelFactory <BackPlane> .CreateByName(selectedNode.Text);

                BackPlaneInitForm bpInitForm = new BackPlaneInitForm(bp);
                bpInitForm.ShowDialog();

                if (bpInitForm.DialogResult == DialogResult.Yes)
                {
                    if (bpInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = bpInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetBackPlanePath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                bpInitForm.Dispose();
                break;

            case "机箱库":
                Models.Container  ctnView     = ModelFactory <Models.Container> .CreateByName(selectedNode.Text);;
                ContainerInitForm ctnInitForm = new ContainerInitForm(ctnView);
                ctnInitForm.ShowDialog();

                if (ctnInitForm.DialogResult == DialogResult.Yes)
                {
                    if (ctnInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = ctnInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetContainerPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                ctnInitForm.Dispose();
                break;

            default:
                break;
            }
            //无论有无文件内容更改都把TreeView的内容读入对应xml文件内
            XMLManager.HandleTreeView.ReadTreeViewToXML(_eqTreeView, XMLManager.PathManager.GetEqLibFilePath());
        }