Ejemplo n.º 1
0
        public List <XMindSheet> GetSheetInfo()
        {
            List <XMindSheet> lst = new List <XMindSheet>();

            foreach (XElement el in GetSheets())
            {
                string sheetId = GetAttribValue(el, "id");

                string centralTopicId = el.Descendants().Where(w1 => w1.Name.ToString().EndsWith("topic") && w1.Parent.Name.ToString().EndsWith("sheet"))
                                        .Where(w3 => GetAttribValue(w3.Parent, "id") == sheetId)
                                        .Select(s => GetAttribValue(s, "id")).First();

                string centralTopicTitle = GetTopic(centralTopicId).Descendants()
                                           .Where(w2 => w2.Name.ToString().EndsWith("title")).Select(s => s.Value).First();

                XMindSheet xmSheet = new XMindSheet(sheetId,
                                                    el.Descendants()
                                                    .Where(w2 => w2.Name.ToString().EndsWith("title") && w2.Parent.Name.ToString().EndsWith("sheet"))
                                                    .Where(w3 => GetAttribValue(w3.Parent, "id") == sheetId)
                                                    .Select(s => s.Value).First());

                XMindTopic xmTopic = new XMindTopic(null, centralTopicId, centralTopicTitle);
                xmSheet.Topics.Add(xmTopic);

                xmSheet.TopicFlatList.Add(xmTopic);
                GetTopicsRecursively(GetTopic(centralTopicId), xmSheet, xmTopic);

                lst.Add(xmSheet);
            }

            return(lst);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper method to build nested topic structure used by public method GetSheetInfo().
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="xmSheet"></param>
        /// <param name="xmTopic"></param>
        private void GetTopicsRecursively(XElement parent, XMindSheet xmSheet, XMindTopic xmTopic)
        {
            foreach (XElement nextLevelTopic in parent.Descendants().Where(w1 => w1.Name.ToString().EndsWith("topic") &&
                                                                           GetAttribValue(w1.Parent.Parent.Parent, "id") == GetAttribValue(parent, "id")))
            {
                string     topicId     = GetAttribValue(nextLevelTopic, "id");
                XMindTopic nextXmTopic = new XMindTopic(xmTopic, topicId, GetTopicTitle(topicId));

                xmSheet.TopicFlatList.Add(nextXmTopic);
                xmTopic.Topics.Add(nextXmTopic);
                GetTopicsRecursively(nextLevelTopic, xmSheet, nextXmTopic);
            }
        }