//把初始化界面填入的内容赋值到一个Container的对象上面去; private void RefreshContainer(Models.Container ctn) { ctn.Name = this._typeTB.Text; ctn.Type = this._typeTB.Text; ctn.BackPlaneName = this._bpTypeCB.Text; foreach (DataGridViewRow item in dataGridView1.Rows) { int slotNum = int.Parse(item.Cells[0].Value.ToString()); string boardName = item.Cells[1].Value.ToString(); ctn.BoardNameDir.Add(slotNum, boardName); } }
public ContainerInitForm() { InitializeComponent(); SetFatherComponents(); ListDataGridView(); BpTypeComboBoxInit(); base._yesBtn.Click += new EventHandler((s, e) => { var ctn = new Models.Container(); RefreshContainer(ctn); ctn.SaveXmlByName(); this.DialogResult = DialogResult.Yes; }); }
/*组件修改*/ 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()); }
public ContainerViewModel(Models.Container container) { _container = container; }
} //当前视图被选中的图元 public ContainerViewModel(Models.Container container, Rectangle rect) { _container = container; Init(rect); }
/// <summary> /// 通过一个Container实例来初始化ContainerInitForm,用于修改机箱的时候 /// </summary> /// <param name="ctn"></param> public ContainerInitForm(Models.Container ctn) { //TODO throw new NotImplementedException(); }