示例#1
0
        /// <summary>
        /// This will add a node to the collection.
        /// </summary>
        /// <param name="node">Specifies a node to be added.</param>
        /// <returns>Returns index of the newly added item.</returns>
        public int Add(TmxNode node)
        {
            if (this.parent != null)
            {
                node.SetParent(this.parent);
            }

            return(this.List.Add(node));
        }
示例#2
0
        /// <summary>
        /// This will insert a node at the given position.
        /// </summary>
        /// <param name="index">The position at which to insert the node.</param>
        /// <param name="node">The node to insert.</param>
        public void Insert(int index, TmxNode node)
        {
            if (this.parent != null)
            {
                node.SetParent(this.parent);
            }

            this.InnerList.Insert(index, node);
        }
示例#3
0
        /// <summary>
        /// This will return true if the node passed is a descendent of this node.
        /// </summary>
        /// <param name="node">The node that might be the parent or grandparent (etc).</param>
        /// <returns>True if this node is a descendent of the one passed in.</returns>
        public bool IsDescendentOf(TmxNode node)
        {
            TmxNode parent = this.Parent;

            while (parent != null)
            {
                if (parent == node)
                {
                    return(true);
                }

                parent = parent.Parent;
            }

            return(false);
        }
示例#4
0
        /// <summary>
        /// This will return the ancstor that is common to this node and the one specified.
        /// </summary>
        /// <param name="node">The possible node that is relative.</param>
        /// <returns>The common ancestor, or null if there is none.</returns>
        public TmxNode GetCommonAncestor(TmxNode node)
        {
            TmxNode thisParent = this;

            while (thisParent != null)
            {
                TmxNode thatParent = node;
                while (thatParent != null)
                {
                    if (thisParent == thatParent)
                    {
                        return(thisParent);
                    }

                    thatParent = thatParent.Parent;
                }

                thisParent = thisParent.Parent;
            }

            return(null);
        }
示例#5
0
        /// <summary>
        /// This will return true if the node passed is a descendent of this node.
        /// </summary>
        /// <param name="node">The node that might be the parent or grandparent (etc).</param>
        /// <returns>True if this node is a descendent of the one passed in.</returns>
        public bool IsDescendentOf(TmxNode node)
        {
            TmxNode parent = this.Parent;
            while (parent != null)
            {
                if (parent == node)
                {
                    return true;
                }

                parent = parent.Parent;
            }

            return false;
        }
示例#6
0
 /// <summary>
 /// This will return true if the node passed is one of the children or grandchildren of this node.
 /// </summary>
 /// <param name="node">The node that might be a child.</param>
 /// <returns>True if this node is an ancestor of the one specified.</returns>
 public bool IsAncestorOf(TmxNode node)
 {
     return node.IsDescendentOf(this);
 }
示例#7
0
        /// <summary>
        /// This will return the ancstor that is common to this node and the one specified.
        /// </summary>
        /// <param name="node">The possible node that is relative.</param>
        /// <returns>The common ancestor, or null if there is none.</returns>
        public TmxNode GetCommonAncestor(TmxNode node)
        {
            TmxNode thisParent = this;
            while (thisParent != null)
            {
                TmxNode thatParent = node;
                while (thatParent != null)
                {
                    if (thisParent == thatParent)
                    {
                        return thisParent;
                    }

                    thatParent = thatParent.Parent;
                }

                thisParent = thisParent.Parent;
            }

            return null;
        }
        /// <summary>
        /// This will insert a node at the given position.
        /// </summary>
        /// <param name="index">The position at which to insert the node.</param>
        /// <param name="node">The node to insert.</param>
        public void Insert(int index, TmxNode node)
        {
            if (this.parent != null)
            {
                node.SetParent(this.parent);
            }

            this.InnerList.Insert(index, node);
        }
 /// <summary>
 /// This is used to identify the index of this node as it appears in the collection.
 /// </summary>
 /// <param name="node">The node to test.</param>
 /// <returns>The index of the node, or -1 if it is not in this collection.</returns>
 public int IndexOf(TmxNode node)
 {
     return this.List.IndexOf(node);
 }
        /// <summary>
        /// This will add a node to the collection.
        /// </summary>
        /// <param name="node">Specifies a node to be added.</param>
        /// <returns>Returns index of the newly added item.</returns>
        public int Add(TmxNode node)
        {
            if (this.parent != null)
            {
                node.SetParent(this.parent);
            }

            return this.List.Add(node);
        }
示例#11
0
 /// <summary>
 /// This is used to identify the index of this node as it appears in the collection.
 /// </summary>
 /// <param name="node">The node to test.</param>
 /// <returns>The index of the node, or -1 if it is not in this collection.</returns>
 public int IndexOf(TmxNode node)
 {
     return(this.List.IndexOf(node));
 }
示例#12
0
 /// <summary>
 /// This will return true if the node passed is one of the children or grandchildren of this node.
 /// </summary>
 /// <param name="node">The node that might be a child.</param>
 /// <returns>True if this node is an ancestor of the one specified.</returns>
 public bool IsAncestorOf(TmxNode node)
 {
     return(node.IsDescendentOf(this));
 }