Example #1
0
        public static MapTree.AttributeSpec GetOrCreateAttributeSpec(MapTree tree)
        {
            MapTree.AttributeSpec aspec = GetAttributeSpec(tree);
            if (aspec == null) aspec = tree.CreateAttributeSpec();

            return aspec;
        }
Example #2
0
        public void MoveNodeUp()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");

            r.MoveUp();
        }
Example #3
0
        public void Deserialize_FeatureDisplay()
        {
            MindMapSerializer s = new MindMapSerializer();
            string originalText = File.ReadAllText(@"Resources\Feature Display.mm");
            MapTree tree = new MapTree();
            s.Deserialize(originalText, tree);

            Assert.AreEqual(tree.RootNode.ChildNodes.Count(), 9);
        }
Example #4
0
        private void Register(MapTree tree)
        {
            tree.SelectedNodes.NodeSelected += MapView_nodeSelected;
            tree.SelectedNodes.NodeDeselected += MapView_nodeDeselected;

            tree.NodePropertyChanged += MapNode_NodePropertyChanged;
            tree.TreeStructureChanged += MapNode_TreeStructureChanged;
            tree.IconChanged += MapNode_IconChanged;
        }
Example #5
0
        public void RegisterMap(MapTree tree)
        {
            tree.AttributeChanged += Tree_AttributeChanged;

            tree.SelectedNodes.NodeSelected += SelectedNodes_NodeSelected;
            tree.SelectedNodes.NodeDeselected += SelectedNodes_NodeDeselected;

            tree.NodePropertyChanged += Tree_NodePropertyChanged;
            tree.TreeStructureChanged += Tree_TreeStructureChanged;
        }
Example #6
0
        public void RegisterMap()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            ChangeManager manager = new ChangeManager();
            manager.RegisterMap(t);

            r.Text = "changed";

            Assert.IsTrue(manager.CanUndo);
        }
Example #7
0
        public void Add_ReAddingNode_OneSelectedEvent()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            int eventSelectCount = 0;
            t.SelectedNodes.NodeSelected += (node, nodes) => eventSelectCount++;
            t.SelectedNodes.Add(r);
            t.SelectedNodes.Add(r);

            Assert.AreEqual(1, eventSelectCount);
        }
Example #8
0
        public void Clear(MapTree tree)
        {
            TaskView tv = (TaskView)GetFirstControl();
            while (tv != null)
            {
                TaskView nextTV = (TaskView)GetNextControl(tv);

                if (tv.MapNode.Tree == tree) RemoveTask(tv);

                tv = nextTV;
            }
        }
Example #9
0
 private void Clear(MapTree tree)
 {
     for (int i = Count - 1; i >= 0; i--)
     {
         MapNode node = this[i];
         if (node.Tree == tree)
         {
             RemoveAt(i);
             TaskChanged(node, new CompletedTaskEventArgs() { TaskChange = CompletedTaskChange.TaskRemoved, OldCompletionDate = node.GetCompletionDate(), OldTaskStatus = node.GetTaskStatus() });
         }
     }
 }
Example #10
0
        public void UnregisterMap(MapTree tree)
        {
            tree.AttributeChanged -= Tree_AttributeChanged;

            tree.SelectedNodes.NodeSelected -= SelectedNodes_NodeSelected;
            tree.SelectedNodes.NodeDeselected -= SelectedNodes_NodeDeselected;

            tree.NodePropertyChanged -= Tree_NodePropertyChanged;
            tree.TreeStructureChanged -= Tree_TreeStructureChanged;

            Clear(tree);
        }
Example #11
0
        public bool ContainsAttribute(MapTree.AttributeSpec attSpec)
        {
            if (attributeList != null)
            {
                foreach (Attribute att in attributeList)
                {
                    if (att.AttributeSpec == attSpec)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Example #12
0
        public void DeserializeSerialize_RichNotesMap()
        {
            MindMapSerializer s = new MindMapSerializer();
            string originalText = File.ReadAllText(@"Resources\RichNotesMap.mm");
            MapTree tree = new MapTree();
            s.Deserialize(originalText, tree);

            using (MemoryStream stream = new MemoryStream())
            {
                s.Serialize(stream, tree);
                stream.Position = 0;
                string generatedText = new StreamReader(stream).ReadToEnd();

                Assert.AreEqual(originalText, generatedText, "Serialized xml doesn't match this original.");
            }
        }
Example #13
0
        public void AddTask_RetrieveIt()
        {
            // setup
            var pManager = new PluginManagerStub();

            MindMate.Plugins.Tasks.TaskPlugin taskPlugin = new MindMate.Plugins.Tasks.TaskPlugin();
            taskPlugin.Initialize(pManager);
            taskPlugin.OnApplicationReady();

            MapTree tree = new MapTree();
            new MapNode(tree, "Center");
            tree.TurnOnChangeManager();
            taskPlugin.OnCreatingTree(tree);

            tree.RootNode.AddTask(DateTime.Now);

            // test
            Assert.IsNotNull(taskPlugin.TaskListView.FindTaskView(tree.RootNode, tree.RootNode.GetDueDate()));
        }
Example #14
0
        public void MapView_SampleMap_ImageTest()
        {
            string xmlString = System.IO.File.ReadAllText(@"Resources\Sample Map.mm");
            MapTree tree = new MapTree();
            new MindMapSerializer().Deserialize(xmlString, tree);

            MindMate.MetaModel.MetaModel.Initialize();
            MapView view = new MapView(tree);

            var image = view.DrawToBitmap();
            if(SAVE_ACTUAL_IMAGE) image.Save(@"Resources\Sample Map - Actual.png");
            var refImage = (Bitmap)Bitmap.FromFile(@"Resources\Sample Map.png");

            //form.Close();
            view.Canvas.Dispose();

            Assert.AreEqual<float>(0.0f, image.PercentageDifference(refImage, 0));

            image.Dispose();
            refImage.Dispose();
        }
Example #15
0
        public void Deserialize_RootNode()
        {
            MindMapSerializer s = new MindMapSerializer();
            string XMLString = File.ReadAllText(@"Resources\Feature Display.mm");
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.LoadXml(XMLString);
            XmlElement x = xmlDoc.DocumentElement;

            var t = new MapTree();
            var r = new MapNode(t, null);

            for (int i = 0; i < x.ChildNodes.Count; i++)
            {
                XmlNode xnode = x.ChildNodes[i];
                if (xnode.Name == "node")
                {
                    s.Deserialize(xnode, t);
                }
            }

            Assert.AreEqual(t.RootNode.ChildNodes.Count(), 9);
        }
Example #16
0
        public void Clear()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c121 = new MapNode(c12, "c121");
            var c13 = new MapNode(c1, "c13");
            var c131 = new MapNode(c13, "c131");
            var c1311 = new MapNode(c131, "c1311");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            var c31 = new MapNode(c3, "c31");
            var c32 = new MapNode(c3, "c32");
            t.SelectAllNodes();

            int count = 0;
            t.SelectedNodes.NodeDeselected += (node, nodes) => count++;

            t.SelectedNodes.Clear();

            Assert.AreEqual(12, count);
        }
Example #17
0
        public void ApplyNodeStyle()
        {
            MapTree tree = new MapTree();
            MapNode r = new MapNode(tree, "r");
            r.FontSize = 15;
            var c1 = new MapNode(r, "c1");
            var c2 = new MapNode(r, "c2");
            var form = new System.Windows.Forms.Form();
            MetaModel.MetaModel.Initialize();
            var mainCtrl = A.Fake<IMainCtrl>();
            MapCtrl mapCtrl = new MapCtrl(new MapView(tree), mainCtrl);
            form.Controls.Add(mapCtrl.MapView.Canvas);
            tree.TurnOnChangeManager();
            r.AddToSelection();
            var style = mapCtrl.CreateNodeStyle();
            r.Selected = false;
            c1.AddToSelection();
            c2.AddToSelection();

            mapCtrl.ApplyNodeStyle(style);

            Assert.AreEqual(15, c1.FontSize);
            Assert.AreEqual(15, c2.FontSize);
        }
Example #18
0
        public void RemoveAt()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c121 = new MapNode(c12, "c121");
            var c13 = new MapNode(c1, "c13");
            var c131 = new MapNode(c13, "c131");
            var c1311 = new MapNode(c131, "c1311");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            var c31 = new MapNode(c3, "c31");
            var c32 = new MapNode(c3, "c32");
            r.Selected = true;

            t.SelectedNodes.RemoveAt(0);

            Assert.IsNull(t.SelectedNodes.Last);
        }
Example #19
0
        public void Find_ByTextSearch()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c13 = new MapNode(c1, "c13");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            c3.Folded = true;
            var c31 = new MapNode(c3, "c31");
            var c311 = new MapNode(c31, "c311");
            var c32 = new MapNode(c3, "c32");

            var result = t.RootNode.Find(n => n.Text.EndsWith("2"));

            Assert.AreEqual(c12, result);
        }
Example #20
0
        public void GetEnumerator()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c121 = new MapNode(c12, "c121");
            var c13 = new MapNode(c1, "c13");
            var c131 = new MapNode(c13, "c131");
            var c1311 = new MapNode(c131, "c1311");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            var c31 = new MapNode(c3, "c31");
            var c32 = new MapNode(c3, "c32");

            t.SelectAllNodes();

            int count = 0;
            foreach (var node in t.SelectedNodes)
            {
                count++;
            }

            Assert.AreEqual(12, count);
        }
Example #21
0
        public void GetEnumerator_IEnumerable()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");

            r.Selected = true;

            var iterator = ((IEnumerable) (t.SelectedNodes)).GetEnumerator();
            iterator.MoveNext();

            Assert.AreEqual(r, iterator.Current);
        }
Example #22
0
        public void CopyFormatTo_CompareOutputWithSavedImage()
        {
            var t = new MapTree();
            var r = new MapNode(t, "Root");

            var n1 = new MapNode(r, "Testing Format Copy");
            var n2 = new MapNode(r, "Testing Format Copy");

            n1.Bold = true;
            n1.Strikeout = true;
            n1.Color = Color.BlueViolet;
            n1.BackColor = Color.Bisque;
            n1.FontSize = 16;

            n1.CopyFormatTo(n2);

            MetaModel.MetaModel.Initialize();
            var mapView = new MapView(t);
            mapView.GetNodeView(n1);
            mapView.GetNodeView(n2);

            Bitmap bmp1 = new Bitmap(@"Resources\CopyFormatTo_CompareOutputWithSavedImage_Src.png");

            Bitmap bmp2 = new Bitmap(2500, 2500);
            Graphics g = Graphics.FromImage(bmp2);
            MapPainter.DrawNode(n2, false, mapView, g);
            g.Dispose();

            bmp2.Save(@"Resources\CopyFormatTo_CompareOutputWithSavedImage_Des.png", ImageFormat.Png);

            Assert.IsTrue(bmp1.PercentageDifference(bmp2, 0) == 0);

            bmp1.Dispose();
            bmp2.Dispose();
        }
Example #23
0
        public void ExcludeNodesAlreadyPartOfHierarchy()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c121 = new MapNode(c12, "c121");
            var c13 = new MapNode(c1, "c13");
            var c131 = new MapNode(c13, "c131");
            var c1311 = new MapNode(c131, "c1311");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            var c31 = new MapNode(c3, "c31");
            var c32 = new MapNode(c3, "c32");

            t.SelectAllNodes();

            var exclude = t.SelectedNodes.ExcludeNodesAlreadyPartOfHierarchy();

            for (int i = 0; i < t.SelectedNodes.Count; i++)
            {
                if (t.SelectedNodes[i] != r && !exclude[i])
                {
                    Assert.Fail();
                }
            }

            Assert.AreEqual(1, exclude.Count(b => !b));
        }
Example #24
0
        public void CopyFormatTo_ValidateObjectState()
        {
            var t = new MapTree();
            var r = new MapNode(t, "Root");

            var n1 = new MapNode(r, "Testing Format Copy");
            var n2 = new MapNode(r, "Testing Format Copy");

            n1.Bold = true;
            n1.Strikeout = true;
            n1.Color = Color.BlueViolet;
            n1.BackColor = Color.Bisque;
            n1.FontSize = 16;

            n1.CopyFormatTo(n2);

            Assert.AreEqual(n1.Bold, n2.Bold);
            Assert.AreEqual(n1.Strikeout, n2.Strikeout);
            Assert.AreEqual(n1.Italic, n2.Italic);
            Assert.AreEqual(n1.Color, n2.Color);
            Assert.AreEqual(n1.BackColor, n2.BackColor);
            Assert.AreEqual(n1.FontSize, n2.FontSize);
            Assert.AreEqual(n1.FontName, n2.FontName);
        }
Example #25
0
        public void FoldedSet_WithSelectedChild_DeselectChild()
        {
            var t = new MapTree();
            var r = new MapNode(t, "Root");
            var c1 = new MapNode(r, "c1");
            var c12 = new MapNode(c1, "c12");
            c12.Selected = true;

            c1.Folded = true;

            Assert.IsFalse(c12.Selected);
        }
Example #26
0
 public AttributeSpecVisibility(MapTree.AttributeSpec spec, bool oldValue)
 {
     this.spec = spec;
     this.oldValue = oldValue;
 }
Example #27
0
 public void ItalicSet_AlreadyItalic_NoChange()
 {
     var t = new MapTree();
     var r = new MapNode(t, "Root") { Italic = true };
     DateTime time = r.Modified;
     t.NodePropertyChanged += (node, args) => Assert.Fail();
     r.Italic = true;
     Assert.IsTrue(r.Italic);
     Assert.AreEqual(r.Modified, time);
 }
Example #28
0
        public void ForEach_UpdateText()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");
            var c13 = new MapNode(c1, "c13");
            var c2 = new MapNode(r, "c2");
            var c3 = new MapNode(r, "c3", NodePosition.Left);
            c3.Folded = true;
            var c31 = new MapNode(c3, "c31");
            var c311 = new MapNode(c31, "c311");
            var c32 = new MapNode(c3, "c32");

            t.RootNode.ForEach(n => n.Text = "Updated");

            Assert.AreEqual("Updated", c12.Text);
            Assert.AreEqual("Updated", c2.Text);
            Assert.AreEqual("Updated", c32.Text);
        }
Example #29
0
        public void Contains()
        {
            var t = new MapTree();
            var r = new MapNode(t, "r");
            var c1 = new MapNode(r, "c1");
            var c11 = new MapNode(c1, "c11");
            var c12 = new MapNode(c1, "c12");

            r.Selected = true;

            Assert.IsTrue(t.SelectedNodes.Contains(r));
        }
Example #30
0
        public void FoldedSet_AlreadyFolded_NoChange()
        {
            var t = new MapTree();
            var r = new MapNode(t, "Root");
            var c1 = new MapNode(r, "c1");
            var c12 = new MapNode(c1, "c12");
            c1.Folded = true;
            DateTime time = c1.Modified;
            t.NodePropertyChanged += (node, args) => Assert.Fail();

            c1.Folded = true;

            Assert.IsTrue(c1.Folded);
            Assert.AreEqual(time, c1.Modified);
        }