Ejemplo n.º 1
0
        public void RemoveNode(TreeNode TN)
        {
            ClearChildren(TN);

            if (items.Contains(TN))
            {
                this.items.Remove(TN);
            }
        }
Ejemplo n.º 2
0
        public void AddRootItem(TreeNode TN)
        {
            TN.Level = 0;
            TN.PropertyChanged +=new PropertyChangedEventHandler(TN_PropertyChanged);
            this.items.Add(TN);

            if (TN.IsExpanded)
            {
                PopulateChildren(TN);
            }
        }
Ejemplo n.º 3
0
        public void UpdateChildren(TreeNode TN)
        {
            TN.UpdateChildren();

            if (TN.HasChildren == false)
            {
                TN.IsExpanded = false;
            }
            else if (TN.IsExpanded)
            {
                if (items.Contains(TN))
                {
                    ClearChildren(TN);
                    PopulateChildren(TN);
                }
            }
        }
Ejemplo n.º 4
0
 private void ClearChildren(TreeNode TN)
 {
     if (items.Contains(TN))
     {
         int indexToRemove = this.items.IndexOf(TN) + 1;
         while ((indexToRemove < this.items.Count) && (this.items[indexToRemove].Level > TN.Level))
         {
             items[indexToRemove].PropertyChanged -= new PropertyChangedEventHandler(TN_PropertyChanged);
             items.RemoveAt(indexToRemove);
         }
     }
 }
Ejemplo n.º 5
0
 public NodeExpandedChanagedEventArgs(TreeNode tN)
 {
     _tN = tN;
 }
Ejemplo n.º 6
0
        private void PopulateChildren(TreeNode TN)
        {
            if (items.Contains(TN))
            {
                int index = this.items.IndexOf(TN);
                if (index == this.items.Count - 1 || this.items[index + 1].Level <= TN.Level)
                {
                    IEnumerable myList = TN.Children;
                    int offset = 0;
                    foreach (TreeNode TN2 in myList)
                    {
                        TN2.PropertyChanged += new PropertyChangedEventHandler(TN_PropertyChanged);
                        TN2.Level = TN.Level + 1;
                        this.items.Insert(index + offset + 1, TN2);

                        offset++;
                    }

                    foreach (TreeNode TN2 in myList)
                    {
                        if ((TN2.IsExpanded) && (TN.HasChildren))
                        {
                            PopulateChildren(TN2);
                        }
                    }
                }
            }
        }