Exemplo n.º 1
0
        public static Document LoadFile(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }

            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(null, filename);
            }

            XmlDocument dom = new XmlDocument();

            dom.Load(filename);

            MindMap map = LoadMindMap(dom);

            if (map != null)
            {
                //map.Filename = filename;
                //if (string.IsNullOrEmpty(map.Name))
                //{
                map.Name = Path.GetFileNameWithoutExtension(filename);
                //}
            }

            Document doc = new Document();

            doc.Name = map.Name;
            doc.Charts.Add(map);
            return(doc);
        }
Exemplo n.º 2
0
        void Children_AfterSort(object sender, EventArgs e)
        {
            if (MindMap != null)
            {
                MindMap.OnTopicAfterSort();
            }

            OnItemsChanged();
        }
Exemplo n.º 3
0
        void OnDescriptionChanged()
        {
            if (DescriptionChanged != null)
            {
                DescriptionChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                MindMap.OnTopicDescriptionChanged(this);
            }
        }
Exemplo n.º 4
0
        private void OnWidgetChanged(object sender, Blumind.Core.PropertyChangedEventArgs e)
        {
            //if (WidgetChanged != null)
            //{
            //    WidgetChanged(sender, new ChangeEventArgs(types));
            //}

            if (MindMap != null)
            {
                MindMap.OnTopicWidgetChanged(this, sender as Widget, e);
            }
        }
Exemplo n.º 5
0
        void Links_ItemRemoved(object sender, XListEventArgs <Link> e)
        {
            if (e.Item != null && e.Item.From == this)
            {
                e.Item.From = null;
            }

            if (MindMap != null)
            {
                MindMap.OnLineRemoved(e.Item);
            }
        }
Exemplo n.º 6
0
        void OnHeightChanged()
        {
            if (CustomHeightChanged != null)
            {
                CustomHeightChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                MindMap.OnTopicHeightChanged(this);
            }
        }
Exemplo n.º 7
0
        void OnFoldedChanged()
        {
            if (FoldedChanged != null)
            {
                FoldedChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                MindMap.OnTopicFoldedChanged(this);
            }
        }
Exemplo n.º 8
0
        void OnIconChanged()
        {
            if (IconChanged != null)
            {
                IconChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                MindMap.OnTopicIconChanged(this);
            }
        }
Exemplo n.º 9
0
        public static MindMap LoadAsXml(Version documentVersion, XmlElement node)
        {
            if (node == null)
            {
                return(null);
            }

            MindMap map = new MindMap(node.GetAttribute("name"));

            map.Deserialize(documentVersion, node);
            return(map);
        }
Exemplo n.º 10
0
        void OnWidthChanged()
        {
            if (CustomWidthChanged != null)
            {
                CustomWidthChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                MindMap.OnTopicWidthChanged(this);
            }
        }
Exemplo n.º 11
0
        void Style_ValueChanged(object sender, EventArgs e)
        {
            if (StyleChanged != null)
            {
                StyleChanged(this, EventArgs.Empty);
            }

            if (MindMap != null)
            {
                //MindMap.OnTopicStyleChanged(this);
                MindMap.OnObjectStyleChanged(this, null, ChangeTypes.Layout | ChangeTypes.Visual);
            }
        }
Exemplo n.º 12
0
        void Links_ItemAdded(object sender, XListEventArgs <Link> e)
        {
            if (e.Item != null)
            {
                e.Item.From  = this;
                e.Item.Chart = this.Chart;
            }

            if (MindMap != null)
            {
                MindMap.OnLineAdded(e.Item);
            }
        }
Exemplo n.º 13
0
        void Children_ItemRemoved(object sender, XListEventArgs <Topic> e)
        {
            if (e.Item != null && e.Item.ParentTopic == this)
            {
                e.Item.ParentTopic = null;
            }

            if (MindMap != null)
            {
                MindMap.OnTopicRemoved(e.Item);
            }

            OnItemsChanged();
        }
Exemplo n.º 14
0
        void OnBeforeCollapse(CancelEventArgs e)
        {
            if (BeforeCollapse != null)
            {
                BeforeCollapse(this, e);
            }

            if (!e.Cancel && MindMap != null)
            {
                TopicCancelEventArgs ce = new TopicCancelEventArgs(this);
                MindMap.OnTopicBeforeCollapse(ce);
                e.Cancel = ce.Cancel;
            }
        }
Exemplo n.º 15
0
        public static void SaveFile(MindMap mindMap, string filename)
        {
            XmlDocument dom = new XmlDocument();

            XmlElement root = dom.CreateElement("map");

            root.SetAttribute("version", "0.9.0");
            root.AppendChild(dom.CreateComment(@"Export from the Blumind, download free mind mapping software Blumind from http://www.blumind.org"));
            root.AppendChild(dom.CreateComment(@"To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net"));
            dom.AppendChild(root);
            SaveMindMap(root, mindMap.Root, mindMap);

            dom.Save(filename);
        }
Exemplo n.º 16
0
        void Children_ItemAdded(object sender, XListEventArgs <Topic> e)
        {
            if (e.Item != null && e.Item.ParentTopic != this)
            {
                e.Item.ParentTopic = this;
                e.Item.Chart       = this.MindMap;
                e.Item.Level       = this.Level + 1;
            }

            if (MindMap != null)
            {
                MindMap.OnTopicAdded(e.Item);
            }

            OnItemsChanged();
        }
Exemplo n.º 17
0
        void Widgets_ItemRemoved(object sender, XListEventArgs <Widget> e)
        {
            if (e.Item != null)
            {
                if (e.Item.WidgetContainer == this)
                {
                    e.Item.WidgetContainer = null;
                }
                e.Item.PropertyChanged -= new Blumind.Core.PropertyChangedEventHandler(Widget_Changed);
            }

            if (MindMap != null)
            {
                MindMap.OnWidgetRemoved(e.Item);
            }
        }
Exemplo n.º 18
0
        static void SaveLink(XmlElement parent, Link link, MindMap mindMap)
        {
            if (parent == null || link == null || string.IsNullOrEmpty(link.TargetID))
            {
                return;
            }

            XmlElement node = parent.OwnerDocument.CreateElement("arrowlink");

            if (!link.Color.IsEmpty)
            {
                node.SetAttribute("COLOR", ST.ToWebColor(link.Color));
            }
            else if (!mindMap.LinkLineColor.IsEmpty)
            {
                node.SetAttribute("COLOR", ST.ToWebColor(mindMap.LinkLineColor));
            }

            node.SetAttribute("DESTINATION", link.TargetID);
            if (link.EndCap != LineAnchor.None)
            {
                node.SetAttribute("ENDARROW", "Default");
            }
            else
            {
                node.SetAttribute("ENDARROW", "None");
            }

            node.SetAttribute("ENDINCLINATION",
                              string.Format("{0};{1};", link.LayoutData.ControlPoint2.X - link.LayoutData.EndPoint.X, link.LayoutData.ControlPoint2.Y - link.LayoutData.EndPoint.Y));

            if (link.StartCap != LineAnchor.None)
            {
                node.SetAttribute("STARTARROW", "Default");
            }
            else
            {
                node.SetAttribute("STARTARROW", "None");
            }

            node.SetAttribute("STARTINCLINATION",
                              string.Format("{0};{1};", link.LayoutData.ControlPoint1.X - link.LayoutData.StartPoint.X, link.LayoutData.ControlPoint1.Y - link.LayoutData.StartPoint.Y));

            parent.AppendChild(node);
        }
Exemplo n.º 19
0
        static MindMap LoadMindMap(XmlDocument dom)
        {
            if (dom.DocumentElement.Name != "map")
            {
                throw new ArgumentException();
            }

            MindMap map = new MindMap();

            //
            XmlElement rootNode = dom.DocumentElement.SelectSingleNode("node") as XmlElement;

            if (rootNode != null)
            {
                Topic topic = LoadNodes(rootNode);
                map.Root = topic;
            }

            return(map);
        }
Exemplo n.º 20
0
        /*public static MindMap LoadFile(string filename)
         * {
         *  if (string.IsNullOrEmpty(filename))
         *      throw new ArgumentNullException("filename");
         *
         *  if (!File.Exists(filename))
         *      throw new FileNotFoundException(null, filename);
         *
         *  MindMap map = LoadAsXml(filename);
         *
         *  if (map != null)
         *  {
         *      map.Filename = filename;
         *      //if (string.IsNullOrEmpty(map.Name))
         *      //{
         *          map.Name = Path.GetFileNameWithoutExtension(filename);
         *      //}
         *  }
         *
         *  return map;
         * }
         *
         * static MindMap LoadAsXml(string filename)
         * {
         *  if (string.IsNullOrEmpty(filename) || !File.Exists(filename))
         *      throw new FileNotFoundException();
         *
         *  XmlDocument dom = new XmlDocument();
         *  dom.Load(filename);
         *
         *  if (dom.DocumentElement.Name != "map")
         *      throw new ArgumentException("filename");
         *
         *  return LoadAsXml(dom.DocumentElement);
         * }
         *
         * public static MindMap LoadAsXml(XmlElement docElement)
         * {
         *  // doc-root
         *  MindMap map = new MindMap(docElement.GetAttribute("name"));
         *  map.LayoutType = ST.GetLayoutType(ST.ReadTextNode(docElement, "layout"));
         *  map.Description = ST.ReadCDataNode(docElement, "description");
         *  if (map.Description == string.Empty)
         *      map.Description = ST.ReadTextNode(docElement, "description");
         *
         *  // info
         *  XmlElement infoNode = docElement.SelectSingleNode("info") as XmlElement;
         *  if (infoNode != null)
         *  {
         *      LoadInfomation(map, infoNode);
         *  }
         *
         *  // style
         *  XmlElement styleNode = docElement.SelectSingleNode("style") as XmlElement;
         *  if (styleNode != null)
         *  {
         *      XmlSerializer.DeserializeMapStyle(styleNode, map);
         *  }
         *
         *  // extend attributes
         *  XmlElement attributeNode = docElement.SelectSingleNode("attributes") as XmlElement;
         *  if (attributeNode != null)
         *  {
         *      LoadExtendAttributes(map, attributeNode);
         *  }
         *
         *  // nodes
         *  XmlElement rootNode = docElement.SelectSingleNode("nodes/node") as XmlElement;
         *  if (rootNode != null)
         *  {
         *      var topic = Topic.DeserializeTopic(rootNode);
         *      map.Root = topic;
         *  }
         *
         *  return map;
         * }
         *
         * static void LoadInfomation(MindMap map, XmlElement info)
         * {
         *  if (map == null || info == null)
         *      return;
         *
         *  map.Author = ST.ReadTextNode(info, "author");
         *  map.Company = ST.ReadTextNode(info, "company");
         *  map.Version = ST.ReadTextNode(info, "version");
         * }
         *
         * static void LoadExtendAttributes(MindMap map, XmlElement node)
         * {
         *  if (map == null || node == null)
         *      return;
         *
         *  XmlNodeList list = node.SelectNodes("item");
         *  foreach (XmlElement attNode in list)
         *  {
         *      map.ExtendAttributes[attNode.GetAttribute("name")] = attNode.InnerText;
         *  }
         * }*/

        public static MindMap ImportXmlFile(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }

            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(null, filename);
            }

            MindMap map = new MindMap();

            XmlDocument dom = new XmlDocument();

            dom.Load(filename);

            Topic topic = ImportXmlFile(dom.DocumentElement);

            map.Root = topic;

            return(map);
        }
Exemplo n.º 21
0
        static void SaveMindMap(XmlElement parent, Topic topic, MindMap mindMap)
        {
            if (parent == null || topic == null)
            {
                return;
            }

            XmlElement node = parent.OwnerDocument.CreateElement("node");

            if (!topic.BackColor.IsEmpty)
            {
                node.SetAttribute("BACKGROUND_COLOR", ST.ToWebColor(topic.BackColor));
            }
            else if (!mindMap.NodeBackColor.IsEmpty)
            {
                node.SetAttribute("BACKGROUND_COLOR", ST.ToWebColor(mindMap.NodeBackColor));
            }

            if (!topic.ForeColor.IsEmpty)
            {
                node.SetAttribute("COLOR", ST.ToWebColor(topic.ForeColor));
            }
            else if (!mindMap.NodeForeColor.IsEmpty)
            {
                node.SetAttribute("COLOR", ST.ToWebColor(mindMap.NodeForeColor));
            }

            if (topic.Folded)
            {
                node.SetAttribute("FOLDED", "true");
            }

            if (!string.IsNullOrEmpty(topic.ID))
            {
                node.SetAttribute("ID", topic.ID);
            }

            if (topic.Vector == Blumind.Controls.Vector4.Left)
            {
                node.SetAttribute("POSITION", "left");
            }
            else if (topic.Vector == Blumind.Controls.Vector4.Right)
            {
                node.SetAttribute("POSITION", "right");
            }

            node.SetAttribute("TEXT", topic.Text);

            node.SetAttribute("HGAP", topic.Padding.Left.ToString());
            node.SetAttribute("VGAP", topic.Padding.Right.ToString());

            if (!string.IsNullOrEmpty(topic.Remark))
            {
                SerializeRemark(node, topic.Remark);
            }

            // Links
            if (topic.Links.Count > 0)
            {
                foreach (Link link in topic.Links)
                {
                    SaveLink(node, link, mindMap);
                }
            }

            // Hyperlink
            if (!string.IsNullOrEmpty(topic.Hyperlink))
            {
                node.SetAttribute("LINK", topic.Hyperlink);
            }

            //
            parent.AppendChild(node);

            // children
            if (topic.Children.Count > 0)
            {
                foreach (Topic subTopic in topic.Children)
                {
                    SaveMindMap(node, subTopic, mindMap);
                }
            }
        }