private void LoadTreeFromXML(XElement xele, TmTreeView tv)
        {
            TmNode node;
            foreach (XElement xnode in xele.Elements(ThemeListNode.TypeString))
            {
                node = new ThemeListNode();
                node.Load(xnode, false); // Add only the first node
                tv.Add(node);
            }

            foreach (XElement xnode in xele.Elements(CategoryNode.TypeString))
            {
                node = new CategoryNode();
                node.BeginUpdate();
                node.Load(xnode, true); // Add entire branch
                node.UpdateAge();
                node.EndUpdate();
                tv.Add(node);
            }

            foreach (XElement xnode in xele.Elements(ThemeNode.TypeString))
            {
                node = new ThemeNode();
                node.BeginUpdate();
                node.Load(xnode, true); // Add entire branch
                node.UpdateAge();
                node.EndUpdate();
                tv.Add(node);
            }
            tv.TextSortInit((string)xele.Attribute("sortorder"));
        }
        public void Load(XElement xele, bool recurse)
        {
            if (xele == null)
                throw new ArgumentNullException("xele");

            //Kind was already set when node was created.  Set all other properties
            Name = (string)xele.Attribute("name");
            XElement data = xele.Element("tags");
            Tags = data == null ? null : data.Value;
            data = xele.Element("summary");
            Summary = data == null ? null : data.Value;
            data = xele.Element("description");
            Description = data == null ? null : data.Value;
            data = xele.Element("pubdate");
            if (data != null)
            {
                DateTime temp;
                if (DateTime.TryParse(data.Value, out temp))
                    if (this is ThemeNode)
                        ((ThemeNode)this).PubDate = temp;
            }

            data = xele.Element("data");
            if (data != null)
            {
                // Ignore data elements for themelists.
                var themeNode = this as ThemeNode;
                if (themeNode != null)
                    (themeNode).Data = ThemeData.Load(data);
                var themeListNode = this as ThemeListNode;
                if (themeListNode != null)
                    (themeListNode).FilePath = data.Value;
            }

            data = xele.Element("metadata");
            if (data != null)
                Metadata = Metadata.Load(data);

            if (recurse)
            {
                TmNode childNode;

                foreach (XElement xnode in xele.Elements(CategoryNode.TypeString))
                {
                    childNode = new CategoryNode();
                    Add(childNode);
                    childNode.Load(xnode);
                }

                foreach (XElement xnode in xele.Elements(ThemeNode.TypeString))
                {
                    if (this is SubThemeNode || this is ThemeNode)
                        childNode = new SubThemeNode();
                    else
                        childNode = new ThemeNode();
                    Add(childNode);
                    childNode.Load(xnode);
                }
            }
        }