示例#1
0
        /// <summary>
        /// Reads the cells into the graph model. All cells are children of the root
        /// element in the node.
        /// </summary>
        public override XmlNode BeforeDecode(mxCodec dec, XmlNode node, Object into)
        {
            if (node is XmlElement)
            {
                XmlElement elt = (XmlElement)node;
                mxGraphModel model = null;

                if (into is mxGraphModel)
                {
                    model = (mxGraphModel)into;
                }
                else
                {
                    model = new mxGraphModel();
                }

                // Reads the cells into the graph model. All cells
                // are children of the root element in the node.
                XmlNode root = elt.GetElementsByTagName("root")[0];
                mxICell rootCell = null;

                if (root != null)
                {
                    XmlNode tmp = root.FirstChild;

                    while (tmp != null)
                    {
                        mxICell cell = dec.DecodeCell(tmp, true);

                        if (cell != null && cell.Parent == null)
                        {
                            rootCell = cell;
                        }

                        tmp = tmp.NextSibling;
                    }

                    root.ParentNode.RemoveChild(root);
                }

                // Sets the root on the model if one has been decoded
                if (rootCell != null)
                {
                    model.Root = rootCell;
                }
            }

            return node;
        }
示例#2
0
        /// <summary>
        /// Reads the cells into the graph model. All cells are children of the root
        /// element in the node.
        /// </summary>
        public override XmlNode BeforeDecode(mxCodec dec, XmlNode node, Object into)
        {
            if (node is XmlElement)
            {
                XmlElement   elt   = (XmlElement)node;
                mxGraphModel model = null;

                if (into is mxGraphModel)
                {
                    model = (mxGraphModel)into;
                }
                else
                {
                    model = new mxGraphModel();
                }

                // Reads the cells into the graph model. All cells
                // are children of the root element in the node.
                XmlNode root     = elt.GetElementsByTagName("root")[0];
                mxICell rootCell = null;

                if (root != null)
                {
                    XmlNode tmp = root.FirstChild;

                    while (tmp != null)
                    {
                        mxICell cell = dec.DecodeCell(tmp, true);

                        if (cell != null && cell.Parent == null)
                        {
                            rootCell = cell;
                        }

                        tmp = tmp.NextSibling;
                    }

                    root.ParentNode.RemoveChild(root);
                }

                // Sets the root on the model if one has been decoded
                if (rootCell != null)
                {
                    model.Root = rootCell;
                }
            }

            return(node);
        }