/// <summary>
 /// 组装读取的数据
 /// </summary>
 /// <param name="RootTreeItem">根节点数据</param>
 /// <param name="root">根节点XML</param>
 protected void LoadData(MyXTreeItem RootTreeItem, XmlNode root)
 {
     ///检查是否已经存在
     foreach (XmlNode node in root.SelectNodes("CodeBox"))
     {
         XmlElement  codeNode   = (XmlElement)node;
         MyXTreeItem RetreeItem = new MyXTreeItem();
         RetreeItem.IsSelected       = false;
         RetreeItem.IsExpanded       = false;
         RetreeItem.XName            = codeNode.GetAttribute("Name");
         RetreeItem.MyHitText        = codeNode.GetAttribute("HitText");
         RetreeItem.MyCodeBoxType    = CodeBox.CodeBoxTypeMapping(codeNode.GetAttribute("CodeBoxType"));
         RetreeItem.SystemCodeString = codeNode.GetAttribute("SystemCodeString");
         RetreeItem.ReturnValue      = codeNode.GetAttribute("ReturnValue");
         foreach (XmlNode xNode in codeNode.SelectNodes("XAribute"))
         {
             ///MyXTreeItem的子项
             XAributeItem xaItem = new XAributeItem();
             ///将内容提出填装
             XmlElement xaNode = (XmlElement)xNode;
             xaItem.Parameter_name   = xaNode.GetAttribute("Name");
             xaItem.MyXAttributeType = XAribute.XAttributeTypeMapping(((XmlElement)xaNode.SelectSingleNode("PointTypeitem")).InnerText);
             xaItem.MyXAttributeSpec = XAribute.XAttributeSpecMapping(((XmlElement)xaNode.SelectSingleNode("ListTypeitem")).InnerText);
             xaItem.MyXPositonStyle  = XAribute.XPositonStyleMapping(((XmlElement)xaNode.SelectSingleNode("PositionTypeitem")).InnerText);
             xaItem.MyCanLinkType    = XAribute.CanLinkTypeMapping(((XmlElement)xaNode.SelectSingleNode("LinkTypeitem")).InnerText);
             xaItem.MyHittext        = ((XmlElement)xaNode.SelectSingleNode("TipTypeitem")).InnerText;
             xaItem.MyLastExText     = ((XmlElement)xaNode.SelectSingleNode("LastExTexteitem")).InnerText;
             ///添加到子项中
             RetreeItem.MyXaributeChildren.Add(xaItem);
         }
         ///添加子节点
         RootTreeItem.ChildrenItem.Add(RetreeItem);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 将XML对象转换回CodeBox对象
        /// </summary>
        /// <param name="boxElement"></param>
        /// <returns></returns>
        public static void ReadCodeBoxObject(XmlNode boxnode, PicTabPage pic)
        {
            XmlElement boxElement = (XmlElement)boxnode;
            //CodeBox ReBox = new CodeBox();
            int    Id    = int.Parse(boxElement.GetAttribute("ID"));
            string Title = boxElement.GetAttribute("Title");
            string Hint  = boxElement.GetAttribute("HitText");

            CodeBox.XAType CodeboxType = CodeBox.CodeBoxTypeMapping(boxElement.GetAttribute("CodeBoxType"));
            Point          position    = new Point();

            position.X = float.Parse(boxElement.GetAttribute("PositionX"));
            position.Y = float.Parse(boxElement.GetAttribute("PositionY"));
            string SystemCodeString = boxElement.GetAttribute("SystemCodeString");
            string ReturnValueName  = boxElement.GetAttribute("ReturnValueName");
            ///加载一个CodeBox
            CodeBox ReBox = pic.LoadXCodeBox(Title, position, Id, CodeboxType);

            ReBox.SystemCodeString = SystemCodeString;
            ReBox.ReturnValueName  = ReturnValueName;
            ///循环左边属性
            XmlNode LeftXAribute = boxnode.SelectSingleNode("LeftXAribute");

            foreach (XmlNode node in LeftXAribute.SelectNodes("XAribute"))
            {
                ReadXAributeObject(node, ReBox);
            }
            ///循环右边属性
            XmlNode RightXAribute = boxnode.SelectSingleNode("RightXAribute");

            foreach (XmlNode node in RightXAribute.SelectNodes("XAribute"))
            {
                ReadXAributeObject(node, ReBox);
            }
        }