Beispiel #1
0
        /// <summary>
        /// Crawls the node structure in a depth-first search of the item.
        /// </summary>
        private TreeViewDataItem TraverseTree(TreeViewDataItem node, DataItem item)
        {
            TreeViewDataItem result = null;

            //Checks if root node matches the given item.
            if (node == null)
            {
                return(null);
            }
            else if (node._data == item)
            {
                return(node);
            }

            //Iterates through each node recursively.
            for (int i = 0; i < node.Items.Count; i++)
            {
                result = TraverseTree(
                    (TreeViewDataItem)node.Items[i],
                    item);

                if (result != null)
                {
                    return(result);
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Two treeviewdataitems are equal if the underlying data's
        /// guids are equal.
        /// </summary>
        public bool Equals(TreeViewDataItem other)
        {
            if (other == null)
            {
                return(false);
            }

            return(_data.guid == other._data.guid);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new treeview item with underlying data.
        /// </summary>
        /// <param name="item">
        /// The data to provide.
        /// </param>
        public TreeViewDataItem(DataItem item)
            : base()
        {
            this._data  = item;
            _parentView = null;

            if (item != null)
            {
                Header = (string)item.GetData("name");
            }
            else
            {
                Header = String.Empty;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Sets the parent item of this item so traversal is easier later.
 /// </summary>
 /// <param name="item">
 /// The containing parent of this item.
 /// </param>
 public void SetParent(TreeViewDataItem item)
 {
     _parentView = item;
 }