Example #1
0
 private void AddVisibleChildrenRecursive(TreeViewTest.BackendData.Foo source, TreeViewItem dest)
 {
     if (this.IsExpanded(source.id))
     {
         if (source.children != null && source.children.Count > 0)
         {
             dest.children = new List <TreeViewItem>(source.children.Count);
             for (int i = 0; i < source.children.Count; i++)
             {
                 TreeViewTest.BackendData.Foo foo = source.children[i];
                 dest.children[i] = new TreeViewTest.FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo);
                 this.itemCounter++;
                 this.AddVisibleChildrenRecursive(foo, dest.children[i]);
             }
         }
     }
     else
     {
         if (source.hasChildren)
         {
             dest.children = new List <TreeViewItem>
             {
                 new TreeViewItem(-1, -1, null, string.Empty)
             };
         }
     }
 }
Example #2
0
 private void AddChildrenRecursive(TreeViewTest.BackendData.Foo foo, int numChildren, bool force)
 {
     if (this.IDCounter > this.m_MaxItems)
     {
         return;
     }
     if (foo.depth >= 12)
     {
         return;
     }
     if (!force && UnityEngine.Random.value < 0.5f)
     {
         return;
     }
     if (foo.children == null)
     {
         foo.children = new List <TreeViewTest.BackendData.Foo>(numChildren);
     }
     for (int i = 0; i < numChildren; i++)
     {
         TreeViewTest.BackendData.Foo foo2 = new TreeViewTest.BackendData.Foo("Tud" + this.IDCounter, foo.depth + 1, ++this.IDCounter);
         foo2.parent = foo;
         foo.children.Add(foo2);
     }
     if (this.IDCounter > this.m_MaxItems)
     {
         return;
     }
     foreach (TreeViewTest.BackendData.Foo current in foo.children)
     {
         this.AddChildrenRecursive(current, UnityEngine.Random.Range(3, 15), false);
     }
 }
Example #3
0
            private HashSet <int> GetParentsBelowRecursive(TreeViewTest.BackendData.Foo searchFromThis)
            {
                HashSet <int> hashSet = new HashSet <int>();

                TreeViewTest.BackendData.GetParentsBelowRecursive(searchFromThis, hashSet);
                return(hashSet);
            }
Example #4
0
            public void ReparentSelection(TreeViewTest.BackendData.Foo parentItem, TreeViewTest.BackendData.Foo insertAfterItem, List <TreeViewTest.BackendData.Foo> draggedItems)
            {
                foreach (TreeViewTest.BackendData.Foo current in draggedItems)
                {
                    current.parent.children.Remove(current);
                    current.parent = parentItem;
                }
                if (!parentItem.hasChildren)
                {
                    parentItem.children = new List <TreeViewTest.BackendData.Foo>();
                }
                List <TreeViewTest.BackendData.Foo> list = new List <TreeViewTest.BackendData.Foo>(parentItem.children);
                int index = 0;

                if (parentItem == insertAfterItem)
                {
                    index = 0;
                }
                else
                {
                    int num = parentItem.children.IndexOf(insertAfterItem);
                    if (num >= 0)
                    {
                        index = num + 1;
                    }
                    else
                    {
                        Debug.LogError("Did not find insertAfterItem, should be a child of parentItem!!");
                    }
                }
                list.InsertRange(index, draggedItems);
                parentItem.children = list;
            }
Example #5
0
 public void GenerateData(int maxNumItems)
 {
     this.m_MaxItems = maxNumItems;
     this.IDCounter  = 1;
     this.m_Root     = new TreeViewTest.BackendData.Foo("Root", 0, 0);
     while (this.IDCounter < this.m_MaxItems)
     {
         this.AddChildrenRecursive(this.m_Root, UnityEngine.Random.Range(3, 15), true);
     }
 }
Example #6
0
 private static void GetParentsBelowRecursive(TreeViewTest.BackendData.Foo item, HashSet <int> parentIDs)
 {
     if (!item.hasChildren)
     {
         return;
     }
     parentIDs.Add(item.id);
     foreach (TreeViewTest.BackendData.Foo current in item.children)
     {
         TreeViewTest.BackendData.GetParentsBelowRecursive(current, parentIDs);
     }
 }
Example #7
0
            protected override HashSet <int> GetParentsAbove(int id)
            {
                HashSet <int> set = new HashSet <int>();

                for (TreeViewTest.BackendData.Foo foo = TreeViewTest.BackendData.FindNodeRecursive(this.m_Backend.root, id); foo != null; foo = foo.parent)
                {
                    if (foo.parent != null)
                    {
                        set.Add(foo.parent.id);
                    }
                }
                return(set);
            }
Example #8
0
 public HashSet <int> GetParentsBelow(int id)
 {
     TreeViewTest.BackendData.Foo foo = TreeViewTest.BackendData.FindNodeRecursive(this.root, id);
     if (foo == null)
     {
         return(new HashSet <int>());
     }
     if (this.m_RecursiveFindParentsBelow)
     {
         return(this.GetParentsBelowRecursive(foo));
     }
     return(this.GetParentsBelowStackBased(foo));
 }
Example #9
0
 private void AddChildrenRecursive(TreeViewTest.BackendData.Foo source, TreeViewItem dest)
 {
     if (source.hasChildren)
     {
         dest.children = new List <TreeViewItem>(source.children.Count);
         for (int i = 0; i < source.children.Count; i++)
         {
             TreeViewTest.BackendData.Foo foo = source.children[i];
             dest.children[i] = new TreeViewTest.FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo);
             this.itemCounter++;
             this.AddChildrenRecursive(foo, dest.children[i]);
         }
     }
 }
Example #10
0
            private HashSet <int> GetParentsBelowStackBased(TreeViewTest.BackendData.Foo searchFromThis)
            {
                Stack <TreeViewTest.BackendData.Foo> stack = new Stack <TreeViewTest.BackendData.Foo>();

                stack.Push(searchFromThis);
                HashSet <int> hashSet = new HashSet <int>();

                while (stack.Count > 0)
                {
                    TreeViewTest.BackendData.Foo foo = stack.Pop();
                    if (foo.hasChildren)
                    {
                        hashSet.Add(foo.id);
                        foreach (TreeViewTest.BackendData.Foo current in foo.children)
                        {
                            stack.Push(current);
                        }
                    }
                }
                return(hashSet);
            }
Example #11
0
 public static TreeViewTest.BackendData.Foo FindNodeRecursive(TreeViewTest.BackendData.Foo item, int id)
 {
     if (item == null)
     {
         return(null);
     }
     if (item.id == id)
     {
         return(item);
     }
     if (item.children == null)
     {
         return(null);
     }
     foreach (TreeViewTest.BackendData.Foo current in item.children)
     {
         TreeViewTest.BackendData.Foo foo = TreeViewTest.BackendData.FindNodeRecursive(current, id);
         if (foo != null)
         {
             return(foo);
         }
     }
     return(null);
 }
Example #12
0
 public FooTreeViewItem(int id, int depth, TreeViewItem parent, string displayName, TreeViewTest.BackendData.Foo foo) : base(id, depth, parent, displayName)
 {
     this.foo = foo;
 }
Example #13
0
			private void AddChildrenRecursive(TreeViewTest.BackendData.Foo foo, int numChildren, bool force)
			{
				if (this.IDCounter > this.m_MaxItems)
				{
					return;
				}
				if (foo.depth >= 12)
				{
					return;
				}
				if (!force && UnityEngine.Random.value < 0.5f)
				{
					return;
				}
				if (foo.children == null)
				{
					foo.children = new List<TreeViewTest.BackendData.Foo>(numChildren);
				}
				for (int i = 0; i < numChildren; i++)
				{
					TreeViewTest.BackendData.Foo foo2 = new TreeViewTest.BackendData.Foo("Tud" + this.IDCounter, foo.depth + 1, ++this.IDCounter);
					foo2.parent = foo;
					foo.children.Add(foo2);
				}
				if (this.IDCounter > this.m_MaxItems)
				{
					return;
				}
				foreach (TreeViewTest.BackendData.Foo current in foo.children)
				{
					this.AddChildrenRecursive(current, UnityEngine.Random.Range(3, 15), false);
				}
			}
Example #14
0
			public void GenerateData(int maxNumItems)
			{
				this.m_MaxItems = maxNumItems;
				this.IDCounter = 1;
				this.m_Root = new TreeViewTest.BackendData.Foo("Root", 0, 0);
				while (this.IDCounter < this.m_MaxItems)
				{
					this.AddChildrenRecursive(this.m_Root, UnityEngine.Random.Range(3, 15), true);
				}
			}
Example #15
0
			public FooTreeViewItem(int id, int depth, TreeViewItem parent, string displayName, TreeViewTest.BackendData.Foo foo) : base(id, depth, parent, displayName)
			{
				this.foo = foo;
			}