public void LoadWins()//读取窗口文件 { /// 创建XmlDocument类的实例 XmlDocument myxmldoc = new XmlDocument(); string sWinsPath = CProject.sPrjPath + "\\Project\\Wins\\传送控制.xml"; myxmldoc.Load(sWinsPath); string xpath = "FormWindow"; XmlElement childNode = (XmlElement)myxmldoc.SelectSingleNode(xpath); cForm.LoadFromXML(childNode); //取图元 xpath = "FormWindow/Misc"; childNode = (XmlElement)myxmldoc.SelectSingleNode(xpath); int i = 0; foreach (XmlElement item in childNode.ChildNodes) { string sNodeName = item.Name; string str1 = sNodeName.Substring(0, 2); if ((sNodeName.Substring(0, 2) == "TY" || sNodeName.Substring(0, 2) == "KJ") && item.ChildNodes.Count > 0) { foreach (XmlElement TYNode in item.ChildNodes) { switch (TYNode.Name) { case "TYLine": CElementFactory.SetClassIndex(LCElementType.LINE); break; case "TYText": CElementFactory.SetClassIndex(LCElementType.TEXT); break; case "TYRect": CElementFactory.SetClassIndex(LCElementType.RECTANGLE); break; case "TYEllipse": CElementFactory.SetClassIndex(LCElementType.ELLIPS); break; case "TYRndRect": CElementFactory.SetClassIndex(LCElementType.ROUNDRECTANGLE); break; case "TYZLine": CElementFactory.SetClassIndex(LCElementType.POLYLINE); break; case "TYArc": CElementFactory.SetClassIndex(LCElementType.ARC); break; case "KJHotImage": CElementFactory.SetClassIndex(LCElementType.IMAGECONTROL); break; case "KJIcon": CElementFactory.SetClassIndex(LCElementType.GROUP); break; case "TYRing": CElementFactory.SetClassIndex(LCElementType.Ring); break; case "TYPipe": CElementFactory.SetClassIndex(LCElementType.Pipe); break; case "KJRuler": CElementFactory.SetClassIndex(LCElementType.KJRuler); break; default: continue; //break; } CBase NewOb = CElementFactory.CreateElement(null, this); if (NewOb == null) { continue; } NewOb.LoadFromXML(TYNode); if (TYNode.Name == "KJRuler") { CRuler = (KJRuler)NewOb; } for (i = ListTuYuan.Count - 1; i > -1; i--) { CBase Ob = (CBase)ListTuYuan[i]; Int32 iEO = Ob.iElementOrder; if (NewOb.iElementOrder >= iEO) { ListTuYuan.Insert(i + 1, NewOb); break; } } if (i == -1) { ListTuYuan.Insert(0, NewOb); } } }//if ((sNodeName.Substring(0, 2) == "TY else if (sNodeName == "Machinings") { foreach (XmlElement TYNode in item.ChildNodes) { CMach.LoadFromXML(TYNode); } } }//foreach (XmlElement item in childNode.ChildNodes) }
public void LoadWins()//读取Wins文件 { /// 创建XmlDocument类的实例 XmlDocument myxmldoc = new XmlDocument(); cForm.sPath = CProject.sPrjPath + "\\Project\\Wins\\生长室维护.xml"; myxmldoc.Load(cForm.sPath); string xpath = "FormWindow"; XmlElement childNode = (XmlElement)myxmldoc.SelectSingleNode(xpath); cForm.LoadFromXML(childNode); //取图元 xpath = "FormWindow/Misc"; childNode = (XmlElement)myxmldoc.SelectSingleNode(xpath); int i = 0; foreach (XmlElement item in childNode.ChildNodes) { string sNodeName = item.Name; string str1 = sNodeName.Substring(0, 2); if ((sNodeName.Substring(0, 2) == "TY" || sNodeName.Substring(0, 2) == "KJ") && item.ChildNodes.Count > 0) { foreach (XmlElement TYNode in item.ChildNodes) { switch (TYNode.Name) { case "TYLine": CElementFactory.SetClassIndex(LCElementType.LINE); break; case "TYText": CElementFactory.SetClassIndex(LCElementType.TEXT); break; case "TYRect": CElementFactory.SetClassIndex(LCElementType.RECTANGLE); break; case "TYEllipse": CElementFactory.SetClassIndex(LCElementType.ELLIPS); break; case "TYRndRect": CElementFactory.SetClassIndex(LCElementType.ROUNDRECTANGLE); break; case "TYZLine": CElementFactory.SetClassIndex(LCElementType.POLYLINE); break; case "TYArc": CElementFactory.SetClassIndex(LCElementType.ARC); break; case "KJHotImage": CElementFactory.SetClassIndex(LCElementType.IMAGECONTROL); break; case "KJIcon": CElementFactory.SetClassIndex(LCElementType.GROUP); break; case "TYRing": CElementFactory.SetClassIndex(LCElementType.Ring); break; case "TYPipe": CElementFactory.SetClassIndex(LCElementType.Pipe); break; default: continue; //break; } CBase NewOb = CElementFactory.CreateElement(null, this); if (NewOb == null) { continue; } NewOb.LoadFromXML(TYNode); if (NewOb.ElementType == LCElementType.Pipe) { CPipe CNum = (CPipe)NewOb; if (CNum.bShowSet) { NumericUpDown nNumUD = new NumericUpDown(); CNumUpDown cNumUD = new CNumUpDown(CNum.ValPF, CNum.SetWidth, 20, 13); nNumUD.Font = new Font("宋体", 13, GraphicsUnit.World); nNumUD.Location = CNum.ValPF; nNumUD.Maximum = new decimal(new int[] { 65535, 0, 0, 0 }); nNumUD.Name = CNum.Name; nNumUD.Size = new Size((int)CNum.SetWidth, 20); nNumUD.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)))); nNumUD.UpDownAlign = LeftRightAlignment.Left; nNumUD.TextAlign = HorizontalAlignment.Right; CVar nVar = frmMain.staComm.GetVarByStaNameVarName("NJ301", nNumUD.Name); if (nVar != null) { nNumUD.Value = new decimal(new int[] { (int)nVar.PLCValue[2], 0, 0, 0 }); } else { nNumUD.Value = new decimal(new int[] { 0, 0, 0, 0 }); } nNumUD.ValueChanged += new EventHandler(nCon_ValueChanged); cNumUD.nNumUD = nNumUD; ListNumericUpDown.Add(cNumUD); this.Controls.Add(nNumUD); } } for (i = ListTuYuan.Count - 1; i > -1; i--) { CBase Ob = (CBase)ListTuYuan[i]; Int32 iEO = Ob.iElementOrder; if (NewOb.iElementOrder >= iEO) { ListTuYuan.Insert(i + 1, NewOb); break; } } if (i == -1) { ListTuYuan.Insert(0, NewOb); } } } //if ((sNodeName.Substring(0, 2) == "TY } //foreach (XmlElement item in childNode.ChildNodes) //对应图元 foreach (CBase nTY in ListTuYuan) { if (nTY.ElementType == LCElementType.GROUP && nTY.KJIconType == 2) { foreach (KJIcon nIcon in KJIconList.ListKJIcon) { if (nIcon.IconName == nTY.IconName) { ((CGroup)nTY).BaseKJIcon = nIcon; } } foreach (SwitchPic nSP in ((CGroup)nTY).ListSwitchPic) { foreach (KJIcon nIcon in KJIconList.ListKJIcon) { if (nIcon.IconName == nSP.PicName) { ((SwitchPic)nSP).BaseKJIcon = nIcon; } } } } } }