示例#1
0
        bool LoadInfo(XmlDocument dom)
        {
            XmlElement node_info = dom.DocumentElement.SelectSingleNode("information") as XmlElement;

            if (node_info != null)
            {
                ID         = node_info.GetAttribute("id");
                Name       = node_info.GetAttribute("name");
                NatureName = node_info.GetAttribute("nature_name");
                Stable     = ST.GetBoolDefault(node_info.GetAttribute("stable"));

                LoadAuthors(node_info);

                LoadCompatibilities(dom);

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public override void Deserialize(Version documentVersion, System.Xml.XmlElement node)
        {
            base.Deserialize(documentVersion, node);

            Hyperlink = node.GetAttribute("hyperlink");
            Folded    = ST.GetBoolDefault(node.GetAttribute("folded"));

            //
            if (documentVersion >= Document.DV_3) // 新
            {
                CustomWidth  = ST.GetInt(node.GetAttribute("custom_width"));
                CustomHeight = ST.GetInt(node.GetAttribute("custom_height"));
            }
            else
            {
                CustomWidth  = ST.GetInt(node.GetAttribute("width"));
                CustomHeight = ST.GetInt(node.GetAttribute("height"));
            }

            TextBounds       = ST.GetRectangle(node.GetAttribute("text_b"), TextBounds);
            RemarkIconBounds = ST.GetRectangle(node.GetAttribute("remark_b"), RemarkIconBounds);
            FoldingButton    = ST.GetRectangle(node.GetAttribute("fold_btn_b"), FoldingButton);

            XmlElement styleNode = node.SelectSingleNode("style") as XmlElement;

            if (styleNode != null)
            {
                Style.Deserialize(documentVersion, styleNode);
            }

            //
            var linkNodes = node.SelectNodes("links/link");

            foreach (XmlElement linkNode in linkNodes)
            {
                Link link = new Link();
                link.Deserialize(documentVersion, linkNode);
                Links.Add(link);
            }

            //
            var widgetNodes = node.SelectNodes("widgets/widget");

            foreach (XmlElement widgetNode in widgetNodes)
            {
                var widget = Widget.DeserializeWidget(documentVersion, widgetNode);
                if (widget != null)
                {
                    Widgets.Add(widget);
                }
            }

            //
            XmlNodeList nodes = node.SelectNodes("nodes/node");

            foreach (XmlElement subNode in nodes)
            {
                Topic subTopic = new Topic();
                subTopic.Deserialize(documentVersion, subNode);
                Children.Add(subTopic);
            }

            //
            if (!Children.IsNullOrEmpty())
            {
                XmlNodeList lines = node.SelectNodes("lines/line");
                foreach (XmlElement lineNode in lines)
                {
                    var line = new TopicLine();
                    line.Deserialize(documentVersion, lineNode);

                    var targetID = lineNode.GetAttribute("target");
                    var target   = Children.Find(c => StringComparer.OrdinalIgnoreCase.Equals(c.ID, targetID));
                    if (target != null)
                    {
                        line.SetTarget(target);
                        Lines.Add(line);
                    }
                }
            }

            //
        }
示例#3
0
        static Topic LoadNodes(XmlElement xmlNode)
        {
            if (xmlNode == null || xmlNode.Name != "node")
            {
                return(null);
            }

            // topic
            Topic topic = new Topic();

            topic.Text      = xmlNode.GetAttribute("TEXT");
            topic.ID        = xmlNode.GetAttribute("ID");
            topic.BackColor = ST.GetColor(xmlNode.GetAttribute("BACKGROUND_COLOR"), topic.BackColor);
            topic.ForeColor = ST.GetColor(xmlNode.GetAttribute("COLOR"), topic.BackColor);
            topic.Folded    = ST.GetBool(xmlNode.GetAttribute("FOLDED"), topic.Folded);
            topic.Padding   = new Padding(ST.GetInt(xmlNode.GetAttribute("HGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("VGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("HGAP"), 0),
                                          ST.GetInt(xmlNode.GetAttribute("VGAP"), 0));

            // font
            XmlElement node = xmlNode.SelectSingleNode("font") as XmlElement;

            if (node != null)
            {
                FontStyle fs = FontStyle.Regular;
                if (ST.GetBoolDefault(node.GetAttribute("BOLD")))
                {
                    fs |= FontStyle.Bold;
                }
                if (ST.GetBoolDefault(node.GetAttribute("ITALIC")))
                {
                    fs |= FontStyle.Italic;
                }
                topic.Font = new Font(node.GetAttribute("NAME"), ST.GetFloat(node.GetAttribute("SIZE"), 0), fs);
            }

            // note
            XmlElement noteNode = xmlNode.SelectSingleNode("richcontent[@TYPE='NOTE']") as XmlElement;

            if (noteNode != null)
            {
                topic.Remark = DeserializeRemark(noteNode);
            }

            // arrowlink
            XmlNodeList links = xmlNode.SelectNodes("arrowlink");

            foreach (XmlElement linkNode in links)
            {
                Link link = DeserializeLink(linkNode);
                topic.Links.Add(link);
            }

            // children
            XmlNodeList list = xmlNode.SelectNodes("node");

            foreach (XmlElement element in list)
            {
                Topic subTopic = LoadNodes(element);
                if (subTopic != null)
                {
                    topic.Children.Add(subTopic);
                }
            }

            return(topic);
        }