Example #1
0
        //virtual void RemoveChild(CBase Child) override;
        //virtual ArrayList ChaifengChild() override;
        //virtual void RemoveAllChild() override;
        //virtual CBase CreateReDianAt(float x,float y,ConPointType Type) override;
        //virtual void MoveReDian(float x,float y)override;

        //virtual CBase Clone() override;
        //virtual CBase CopyTo(CBaseDesObject)override;
        //virtual void SaveToXML(XmlElement Node) override;
        public override void LoadFromXML(XmlElement Node)
        {
            base.LoadFromXML(Node);
            XmlElement CGroupNode = (XmlElement)(Node.SelectSingleNode("Misc"));

            IconName = CGroupNode.GetAttribute("IconName");
            Name     = CGroupNode.GetAttribute("Name");
            if (IconName == "GrpIcon36")
            {
                Name = "成组图标3";
            }
            if (CGroupNode.HasAttribute("iType"))//成组图标
            {
                KJIconType = 1;
                foreach (XmlElement item in CGroupNode.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 "TYArc":
                                CElementFactory.SetClassIndex(LCElementType.ARC);
                                break;

                            case "KJIcon":
                                CElementFactory.SetClassIndex(LCElementType.GROUP);
                                break;

                            default:
                                continue;
                                break;
                            }

                            CBase NewOb = CElementFactory.CreateElement(this, this);
                            if (NewOb == null)
                            {
                                return;
                            }
                            NewOb.LoadFromXML(TYNode);
                            AddChild(NewOb);
                        }
                    }
                }
            }
            else//固定图标
            {
                KJIconType = 2;

                KJIconList.AddKJIcon(IconName);
                XmlElement LayoutNode = (XmlElement)(Node.SelectSingleNode("Layout"));
                fRatio = float.Parse(LayoutNode.GetAttribute("fRatio"));
                if (LayoutNode.HasAttribute("iIconDir"))
                {
                    iIconDir   = int.Parse(LayoutNode.GetAttribute("iIconDir"));
                    LayoutNode = (XmlElement)(Node.SelectSingleNode("Behavior/SwitchPics"));
                    foreach (XmlElement item in LayoutNode.ChildNodes)
                    {
                        string    PicName   = item.GetAttribute("PicName");
                        string    Condition = item.GetAttribute("Condition");
                        SwitchPic nSw       = new SwitchPic(PicName, Condition);
                        ListSwitchPic.Add(nSw);
                        KJIconList.AddKJIcon(nSw.PicName);
                    }
                }
            }
            return;
        }
Example #2
0
        public void LoadWins()//读取Wins文件
        {
            /// 创建XmlDocument类的实例
            XmlDocument myxmldoc = new XmlDocument();

            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;
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        public bool LoadFromXML()
        {
            XmlDocument myxmldoc = new XmlDocument();
            string      sPath    = CProject.sPrjPath + "\\IconLib\\" + IconName + ".yic";

            if (File.Exists(sPath))
            {
                myxmldoc.Load(sPath);
                //取图元
                string     xpath     = "Root/Misc";
                XmlElement 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 "TYArc":
                                CElementFactory.SetClassIndex(LCElementType.ARC);
                                break;

                            case "KJHotImage":
                                CElementFactory.SetClassIndex(LCElementType.IMAGECONTROL);
                                break;

                            case "KJIcon":
                                CElementFactory.SetClassIndex(LCElementType.GROUP);
                                break;

                            default:
                                continue;
                                //break;
                            }

                            CBase NewOb = CElementFactory.CreateElement(null, this);
                            if (NewOb == null)
                            {
                                continue;
                            }
                            NewOb.LoadFromXML(TYNode);
                            for (i = ListTuYuan.Count - 1; i > -1; i--)
                            {
                                Object Ob  = ListTuYuan[i];
                                Int32  iEO = ((CBase)Ob).iElementOrder;
                                if (NewOb.iElementOrder >= iEO)
                                {
                                    ListTuYuan.Insert(i + 1, NewOb);
                                    break;
                                }
                            }
                            if (i == -1)
                            {
                                ListTuYuan.Insert(0, NewOb);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }