private void SetIndent(VirtualizingTreeViewItem parent, ref int itemIndex)
        {
            while (true)
            {
                object obj = TreeView.GetItemAt(itemIndex + 1);
                VirtualizingTreeViewItem child = (VirtualizingTreeViewItem)TreeView.GetItemContainer(obj);
                if (child == null)
                {
                    return;
                }

                if (child.Item == null)
                {
                    return;
                }

                if (child.Parent != parent.m_treeViewItemData)
                {
                    return;
                }

                child.m_treeViewItemData.Indent = parent.m_treeViewItemData.Indent + TreeView.Indent;
                if (child.m_itemLayout != null && child.m_itemLayout.padding != null)
                {
                    child.m_itemLayout.padding.left = child.m_treeViewItemData.Indent;
                }

                itemIndex++;
                SetIndent(child, ref itemIndex);
            }
        }
Exemplo n.º 2
0
 void IEndDragHandler.OnEndDrag(PointerEventData eventData)
 {
     if (this.TreeView.DropTarget != null)
     {
         GameObject dropTarget = (GameObject)this.TreeView.DropTarget;
         GameObject gameObject = new GameObject();
         VirtualizingTreeViewItem itemContainer1 = (VirtualizingTreeViewItem)this.TreeView.GetItemContainer(this.TreeView.DropTarget);
         if (this.TreeView.DropAction == ItemDropAction.SetLastChild)
         {
             gameObject.get_transform().SetParent(dropTarget.get_transform());
             this.TreeView.AddChild(this.TreeView.DropTarget, (object)gameObject);
             itemContainer1.CanExpand  = true;
             itemContainer1.IsExpanded = true;
         }
         else if (this.TreeView.DropAction != ItemDropAction.None)
         {
             int index = this.TreeView.DropAction != ItemDropAction.SetNextSibling ? this.TreeView.IndexOf((object)dropTarget) : this.TreeView.IndexOf((object)dropTarget) + 1;
             gameObject.get_transform().SetParent(dropTarget.get_transform().get_parent());
             gameObject.get_transform().SetSiblingIndex(index);
             TreeViewItemContainerData itemContainerData = (TreeViewItemContainerData)this.TreeView.Insert(index, (object)gameObject);
             VirtualizingTreeViewItem  itemContainer2    = (VirtualizingTreeViewItem)this.TreeView.GetItemContainer((object)gameObject);
             if (Object.op_Inequality((Object)itemContainer2, (Object)null))
             {
                 itemContainer2.Parent = itemContainer1.Parent;
             }
             else
             {
                 itemContainerData.Parent = itemContainer1.Parent;
             }
         }
     }
     this.TreeView.ExternalItemDrop();
 }
        protected override void SetNextSiblingInternal(ItemContainerData sibling, ItemContainerData nextSibling)
        {
            TreeViewItemContainerData tvSibling      = (TreeViewItemContainerData)sibling;
            TreeViewItemContainerData lastDescendant = tvSibling.LastDescendant(this);

            if (lastDescendant == null)
            {
                lastDescendant = tvSibling;
            }
            TreeViewItemContainerData tvItemData    = (TreeViewItemContainerData)nextSibling;
            TreeViewItemContainerData dragItemChild = tvItemData.FirstChild(this);

            base.SetNextSiblingInternal(lastDescendant, nextSibling);
            if (dragItemChild != null)
            {
                MoveSubtree(tvItemData, dragItemChild);
            }

            SetParent(tvSibling.Parent, tvItemData);

            VirtualizingTreeViewItem tvItem = (VirtualizingTreeViewItem)GetItemContainer(tvItemData.Item);

            if (tvItem != null)
            {
                tvItem.UpdateIndent();
            }
        }
Exemplo n.º 4
0
        private void MoveSubtree(TreeViewItemContainerData parent, TreeViewItemContainerData child)
        {
            int  num          = this.IndexOf(parent.Item);
            int  siblingIndex = this.IndexOf(child.Item);
            bool flag         = false;

            if (num < siblingIndex)
            {
                flag = true;
            }
            TreeViewItemContainerData itemContainerData = parent;
            VirtualizingTreeViewItem  itemContainer1    = (VirtualizingTreeViewItem)this.GetItemContainer(itemContainerData.Item);

            if (Object.op_Inequality((Object)itemContainer1, (Object)null))
            {
                itemContainer1.UpdateIndent();
            }
            for (; child != null && child.IsDescendantOf(parent) && itemContainerData != child; child = (TreeViewItemContainerData)this.GetItemContainerData(siblingIndex))
            {
                base.SetNextSiblingInternal((ItemContainerData)itemContainerData, (ItemContainerData)child);
                VirtualizingTreeViewItem itemContainer2 = (VirtualizingTreeViewItem)this.GetItemContainer(child.Item);
                if (Object.op_Inequality((Object)itemContainer2, (Object)null))
                {
                    itemContainer2.UpdateIndent();
                }
                itemContainerData = child;
                if (flag)
                {
                    ++siblingIndex;
                }
            }
        }
 public override void SetPosition(Vector2 position)
 {
     if (Object.op_Equality((Object)this.Item, (Object)null))
     {
         return;
     }
     if (!this.m_treeView.CanReparent)
     {
         base.SetPosition(position);
     }
     else
     {
         RectTransform            rectTransform1           = this.Item.RectTransform;
         VirtualizingTreeViewItem virtualizingTreeViewItem = (VirtualizingTreeViewItem)this.Item;
         Vector2     sizeDelta = this.m_rectTransform.get_sizeDelta();
         ref Vector2 local1    = ref sizeDelta;
         Rect        rect1     = rectTransform1.get_rect();
         double      height1   = (double)((Rect) ref rect1).get_height();
         local1.y = (__Null)height1;
         if (this.m_useGrid)
         {
             ref Vector2 local2 = ref sizeDelta;
             Rect        rect2  = rectTransform1.get_rect();
             double      width  = (double)((Rect) ref rect2).get_width();
             local2.x = (__Null)width;
         }
Exemplo n.º 6
0
 public override void DataBindItem(object item, VirtualizingItemContainer itemContainer)
 {
     itemContainer.Clear();
     if (item != null)
     {
         VirtualizingTreeViewItemDataBindingArgs args = new VirtualizingTreeViewItemDataBindingArgs();
         args.Item            = item;
         args.ItemPresenter   = !Object.op_Equality((Object)itemContainer.ItemPresenter, (Object)null) ? itemContainer.ItemPresenter : ((Component)this).get_gameObject();
         args.EditorPresenter = !Object.op_Equality((Object)itemContainer.EditorPresenter, (Object)null) ? itemContainer.EditorPresenter : ((Component)this).get_gameObject();
         this.RaiseItemDataBinding(args);
         VirtualizingTreeViewItem virtualizingTreeViewItem = (VirtualizingTreeViewItem)itemContainer;
         virtualizingTreeViewItem.CanExpand   = args.HasChildren;
         virtualizingTreeViewItem.CanEdit     = this.CanEdit && args.CanEdit;
         virtualizingTreeViewItem.CanDrag     = this.CanDrag && args.CanDrag;
         virtualizingTreeViewItem.CanBeParent = args.CanBeParent;
         virtualizingTreeViewItem.UpdateIndent();
     }
     else
     {
         VirtualizingTreeViewItem virtualizingTreeViewItem = (VirtualizingTreeViewItem)itemContainer;
         virtualizingTreeViewItem.CanExpand = false;
         virtualizingTreeViewItem.CanEdit   = false;
         virtualizingTreeViewItem.CanDrag   = false;
         virtualizingTreeViewItem.UpdateIndent();
     }
 }
Exemplo n.º 7
0
        public override void DataBindItem(object item, VirtualizingItemContainer itemContainer)
        {
            itemContainer.Clear();

            if (item != null)
            {
                VirtualizingTreeViewItemDataBindingArgs args = new VirtualizingTreeViewItemDataBindingArgs();
                args.Item            = item;
                args.ItemPresenter   = itemContainer.ItemPresenter == null ? gameObject : itemContainer.ItemPresenter;
                args.EditorPresenter = itemContainer.EditorPresenter == null ? gameObject : itemContainer.EditorPresenter;

                RaiseItemDataBinding(args);

                VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)itemContainer;
                treeViewItem.CanExpand       = args.HasChildren;
                treeViewItem.CanEdit         = CanEdit && args.CanEdit;
                treeViewItem.CanDrag         = CanDrag && args.CanDrag;
                treeViewItem.CanBeParent     = args.CanBeParent;
                treeViewItem.CanChangeParent = args.CanChangeParent;
                treeViewItem.UpdateIndent();
            }
            else
            {
                VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)itemContainer;
                treeViewItem.CanExpand       = false;
                treeViewItem.CanEdit         = false;
                treeViewItem.CanDrag         = false;
                treeViewItem.CanBeParent     = false;
                treeViewItem.CanChangeParent = false;
                treeViewItem.UpdateIndent();
            }
        }
 public void RemoveChild(object parent, object item, bool isLastChild)
 {
     if (parent == null)
     {
         base.Remove(item);
     }
     else
     {
         if (GetItemContainer(item) != null)
         {
             base.Remove(item);
         }
         else
         {
             //Parent item is not expanded (if isLastChild just remove parent expander)
             if (isLastChild)
             {
                 VirtualizingTreeViewItem parentContainer = (VirtualizingTreeViewItem)GetItemContainer(parent);
                 if (parentContainer)
                 {
                     parentContainer.CanExpand = false;
                 }
             }
         }
     }
 }
        public void Internal_Expand(object item)
        {
            TreeViewItemContainerData treeViewItemData = (TreeViewItemContainerData)GetItemContainerData(item);

            if (treeViewItemData == null)
            {
                throw new ArgumentException("TreeViewItemContainerData not found", "item");
            }
            if (treeViewItemData.IsExpanded)
            {
                return;
            }
            treeViewItemData.IsExpanded = true;

            if (m_expandSilently)
            {
                return;
            }

            if (ItemExpanding != null)
            {
                VirtualizingItemExpandingArgs args = new VirtualizingItemExpandingArgs(treeViewItemData.Item);
                ItemExpanding(this, args);

                IEnumerable children  = args.Children == null ? null : args.Children.OfType <object>().ToArray();
                int         itemIndex = IndexOf(treeViewItemData.Item);

                VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)GetItemContainer(treeViewItemData.Item);
                if (treeViewItem != null)
                {
                    treeViewItem.CanExpand = children != null;
                }
                else
                {
                    treeViewItemData.CanExpand = children != null;
                }

                if (treeViewItemData.CanExpand)
                {
                    foreach (object childItem in children)
                    {
                        itemIndex++;

                        TreeViewItemContainerData childData      = (TreeViewItemContainerData)Insert(itemIndex, childItem);
                        VirtualizingTreeViewItem  childContainer = (VirtualizingTreeViewItem)GetItemContainer(childItem);
                        if (childContainer != null)
                        {
                            childContainer.Parent = treeViewItemData;
                        }
                        else
                        {
                            childData.Parent = treeViewItemData;
                        }
                    }

                    UpdateSelectedItemIndex();
                }
            }
        }
Exemplo n.º 10
0
 public void AddChild(object parent, object item)
 {
     if (parent == null)
     {
         this.Add(item);
     }
     else
     {
         VirtualizingTreeViewItem itemContainer1 = (VirtualizingTreeViewItem)this.GetItemContainer(parent);
         int index = -1;
         TreeViewItemContainerData itemContainerData1;
         if (Object.op_Equality((Object)itemContainer1, (Object)null))
         {
             itemContainerData1 = (TreeViewItemContainerData)this.GetItemContainerData(parent);
             if (itemContainerData1 == null)
             {
                 Debug.LogWarning((object)"Lost parent data");
                 return;
             }
             if (itemContainerData1.IsExpanded)
             {
                 index = !itemContainerData1.HasChildren(this) ? this.IndexOf(itemContainerData1.Item) + 1 : this.IndexOf(itemContainerData1.LastDescendant(this).Item) + 1;
             }
             else
             {
                 itemContainerData1.CanExpand = true;
             }
         }
         else
         {
             if (itemContainer1.IsExpanded)
             {
                 index = !itemContainer1.HasChildren ? this.IndexOf(itemContainer1.Item) + 1 : this.IndexOf(itemContainer1.LastDescendant().Item) + 1;
             }
             else
             {
                 itemContainer1.CanExpand = true;
             }
             itemContainerData1 = itemContainer1.TreeViewItemData;
         }
         if (index <= -1)
         {
             return;
         }
         TreeViewItemContainerData itemContainerData2 = (TreeViewItemContainerData)this.Insert(index, item);
         VirtualizingTreeViewItem  itemContainer2     = (VirtualizingTreeViewItem)this.GetItemContainer(item);
         if (Object.op_Inequality((Object)itemContainer2, (Object)null))
         {
             itemContainer2.Parent = itemContainerData1;
         }
         else
         {
             itemContainerData2.Parent = itemContainerData1;
         }
     }
 }
Exemplo n.º 11
0
        public void UpdateIndent(object obj)
        {
            VirtualizingTreeViewItem itemContainer = (VirtualizingTreeViewItem)this.GetItemContainer(obj);

            if (Object.op_Equality((Object)itemContainer, (Object)null))
            {
                return;
            }
            itemContainer.UpdateIndent();
        }
        /// <summary>
        /// Add data item as last child of parent
        /// </summary>
        /// <param name="parent">parent data item</param>
        /// <param name="item">data item to add</param>
        public void AddChild(object parent, object item)
        {
            if (parent == null)
            {
                Add(item);
            }
            else
            {
                TreeViewItemContainerData parentContainerData = (TreeViewItemContainerData)GetItemContainerData(parent);
                if (parentContainerData == null)
                {
                    return;
                }

                int index = -1;
                if (parentContainerData.IsExpanded)
                {
                    if (parentContainerData.HasChildren(this))
                    {
                        TreeViewItemContainerData lastDescendant = parentContainerData.LastDescendant(this);
                        index = IndexOf(lastDescendant.Item) + 1;
                    }
                    else
                    {
                        index = IndexOf(parentContainerData.Item) + 1;
                    }
                }
                else
                {
                    VirtualizingTreeViewItem parentContainer = (VirtualizingTreeViewItem)GetItemContainer(parent);
                    if (parentContainer != null)
                    {
                        parentContainer.CanExpand = true;
                    }
                    else
                    {
                        parentContainerData.CanExpand = true;
                    }
                }

                if (index > -1)
                {
                    TreeViewItemContainerData addedItemData     = (TreeViewItemContainerData)Insert(index, item);
                    VirtualizingTreeViewItem  addedTreeViewItem = (VirtualizingTreeViewItem)GetItemContainer(item);
                    if (addedTreeViewItem != null)
                    {
                        addedTreeViewItem.Parent = parentContainerData;
                    }
                    else
                    {
                        addedItemData.Parent = parentContainerData;
                    }
                }
            }
        }
        public void UpdateIndent(object obj)
        {
            VirtualizingTreeViewItem item = (VirtualizingTreeViewItem)GetItemContainer(obj);

            if (item == null)
            {
                return;
            }

            item.UpdateIndent();
        }
Exemplo n.º 14
0
        private void SetParent(TreeViewItemContainerData parent, TreeViewItemContainerData child)
        {
            VirtualizingTreeViewItem tvDragItem = (VirtualizingTreeViewItem)GetItemContainer(child.Item);

            if (tvDragItem != null)
            {
                tvDragItem.Parent = parent;
            }
            else
            {
                child.Parent = parent;
            }
        }
Exemplo n.º 15
0
        public void Collapse(object item)
        {
            VirtualizingTreeViewItem treeViewItem = this.GetTreeViewItem(item);

            if (Object.op_Inequality((Object)treeViewItem, (Object)null))
            {
                treeViewItem.IsExpanded = false;
            }
            else
            {
                this.Internal_Collapse(item);
            }
        }
Exemplo n.º 16
0
        private void SetParent(TreeViewItemContainerData parent, TreeViewItemContainerData child)
        {
            VirtualizingTreeViewItem itemContainer = (VirtualizingTreeViewItem)this.GetItemContainer(child.Item);

            if (Object.op_Inequality((Object)itemContainer, (Object)null))
            {
                itemContainer.Parent = parent;
            }
            else
            {
                child.Parent = parent;
            }
        }
        public void Collapse(object item)
        {
            VirtualizingTreeViewItem tvi = GetTreeViewItem(item);

            if (tvi != null)
            {
                tvi.IsExpanded = false;
            }
            else
            {
                Internal_Collapse(item);
            }
        }
        public void Collapse(object item)
        {
            VirtualizingTreeViewItem tvi = GetTreeViewItem(item);

            if (tvi != null)
            {
                tvi.IsExpanded = false;
            }
            else
            {
                TreeViewItemContainerData containerData = (TreeViewItemContainerData)GetItemContainerData(item);
                containerData.IsExpanded = false;
            }
        }
Exemplo n.º 19
0
 protected override void DestroyItems(object[] items, bool unselect)
 {
     TreeViewItemContainerData[] array = ((IEnumerable <TreeViewItemContainerData>)((IEnumerable <object>)items).Select <object, ItemContainerData>((Func <object, ItemContainerData>)(item => this.GetItemContainerData(item))).OfType <TreeViewItemContainerData>().ToArray <TreeViewItemContainerData>()).Where <TreeViewItemContainerData>((Func <TreeViewItemContainerData, bool>)(container => container.Parent != null)).Select <TreeViewItemContainerData, TreeViewItemContainerData>((Func <TreeViewItemContainerData, TreeViewItemContainerData>)(container => container.Parent)).ToArray <TreeViewItemContainerData>();
     this.Collapse(items);
     base.DestroyItems(items, unselect);
     foreach (TreeViewItemContainerData itemContainerData in array)
     {
         if (!itemContainerData.HasChildren(this))
         {
             VirtualizingTreeViewItem itemContainer = (VirtualizingTreeViewItem)this.GetItemContainer(itemContainerData.Item);
             if (Object.op_Inequality((Object)itemContainer, (Object)null))
             {
                 itemContainer.CanExpand = false;
             }
         }
     }
 }
Exemplo n.º 20
0
        void IEndDragHandler.OnEndDrag(PointerEventData eventData)
        {
            if (TreeView.DropTarget != null)
            {
                GameObject dropTarget  = (GameObject)TreeView.DropTarget;
                GameObject newDataItem = new GameObject();
                VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)TreeView.GetItemContainer(TreeView.DropTarget);

                if (TreeView.DropAction == ItemDropAction.SetLastChild)
                {
                    newDataItem.transform.SetParent(dropTarget.transform);
                    TreeView.AddChild(TreeView.DropTarget, newDataItem);
                    treeViewItem.CanExpand  = true;
                    treeViewItem.IsExpanded = true;
                }
                else if (TreeView.DropAction != ItemDropAction.None)
                {
                    int index;
                    if (TreeView.DropAction == ItemDropAction.SetNextSibling)
                    {
                        index = TreeView.IndexOf(dropTarget) + 1;
                    }
                    else
                    {
                        index = TreeView.IndexOf(dropTarget);
                    }

                    newDataItem.transform.SetParent(dropTarget.transform.parent);
                    newDataItem.transform.SetSiblingIndex(index);

                    TreeViewItemContainerData newTreeViewItemData = (TreeViewItemContainerData)TreeView.Insert(index, newDataItem);
                    VirtualizingTreeViewItem  newTreeViewItem     = (VirtualizingTreeViewItem)TreeView.GetItemContainer(newDataItem);
                    if (newTreeViewItem != null)
                    {
                        newTreeViewItem.Parent = treeViewItem.Parent;
                    }
                    else
                    {
                        newTreeViewItemData.Parent = treeViewItem.Parent;
                    }
                }
            }

            TreeView.ExternalItemDrop();
        }
Exemplo n.º 21
0
 private void SetIndent(VirtualizingTreeViewItem parent, ref int itemIndex)
 {
     while (true)
     {
         VirtualizingTreeViewItem itemContainer = (VirtualizingTreeViewItem)this.TreeView.GetItemContainer(this.TreeView.GetItemAt(itemIndex + 1));
         if (!Object.op_Equality((Object)itemContainer, (Object)null) && itemContainer.Item != null && itemContainer.Parent == parent.m_treeViewItemData)
         {
             itemContainer.m_treeViewItemData.Indent = parent.m_treeViewItemData.Indent + this.TreeView.Indent;
             ((LayoutGroup)itemContainer.m_itemLayout).get_padding().set_left(itemContainer.m_treeViewItemData.Indent);
             ++itemIndex;
             this.SetIndent(itemContainer, ref itemIndex);
         }
         else
         {
             break;
         }
     }
 }
        public override void SetTarget(VirtualizingItemContainer item)
        {
            base.SetTarget(item);
            if (Object.op_Equality((Object)item, (Object)null))
            {
                return;
            }
            VirtualizingTreeViewItem virtualizingTreeViewItem = (VirtualizingTreeViewItem)item;

            if (Object.op_Inequality((Object)virtualizingTreeViewItem, (Object)null))
            {
                this.m_siblingGraphicsRectTransform.set_offsetMin(new Vector2(virtualizingTreeViewItem.Indent, (float)this.m_siblingGraphicsRectTransform.get_offsetMin().y));
            }
            else
            {
                this.m_siblingGraphicsRectTransform.set_offsetMin(new Vector2(0.0f, (float)this.m_siblingGraphicsRectTransform.get_offsetMin().y));
            }
        }
Exemplo n.º 23
0
        public bool Expand(object item)
        {
            VirtualizingTreeViewItem treeViewItem = this.GetTreeViewItem(item);

            if (Object.op_Inequality((Object)treeViewItem, (Object)null))
            {
                treeViewItem.IsExpanded = true;
            }
            else
            {
                if ((TreeViewItemContainerData)this.GetItemContainerData(item) == null)
                {
                    Debug.LogWarning((object)("Unable find container data for item " + item));
                    return(false);
                }
                this.Internal_Expand(item);
            }
            return(true);
        }
Exemplo n.º 24
0
        public override void SetTarget(VirtualizingItemContainer item)
        {
            base.SetTarget(item);
            if (item == null)
            {
                return;
            }

            VirtualizingTreeViewItem tvItem = (VirtualizingTreeViewItem)item;

            if (tvItem != null)
            {
                m_siblingGraphicsRectTransform.offsetMin = new Vector2(tvItem.Indent, m_siblingGraphicsRectTransform.offsetMin.y);
            }
            else
            {
                m_siblingGraphicsRectTransform.offsetMin = new Vector2(0, m_siblingGraphicsRectTransform.offsetMin.y);
            }
        }
        public override void DataBindItem(object item, ItemContainerData containerData, VirtualizingItemContainer itemContainer)
        {
            itemContainer.Clear();

            VirtualizingTreeViewItemDataBindingArgs args = new VirtualizingTreeViewItemDataBindingArgs();

            args.Item            = item;
            args.ItemPresenter   = itemContainer.ItemPresenter == null ? gameObject : itemContainer.ItemPresenter;
            args.EditorPresenter = itemContainer.EditorPresenter == null ? gameObject : itemContainer.EditorPresenter;

            RaiseItemDataBinding(args);

            VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)itemContainer;

            treeViewItem.CanExpand = args.HasChildren;
            treeViewItem.CanEdit   = args.CanEdit;
            treeViewItem.CanDrag   = args.CanDrag;
            treeViewItem.UpdateIndent();
        }
        public void Expand(object item)
        {
            VirtualizingTreeViewItem tvi = GetTreeViewItem(item);

            if (tvi != null)
            {
                tvi.IsExpanded = true;
            }
            else
            {
                TreeViewItemContainerData containerData = (TreeViewItemContainerData)GetItemContainerData(item);
                if (containerData == null)
                {
                    Debug.LogWarning("Unable find container data for item " + item);
                }
                else
                {
                    Internal_Expand(item);
                }
            }
        }
        protected override void DestroyItems(object[] items, bool unselect)
        {
            TreeViewItemContainerData[] itemContainers = items.Select(item => GetItemContainerData(item)).OfType <TreeViewItemContainerData>().ToArray();
            TreeViewItemContainerData[] parents        = itemContainers.Where(container => container.Parent != null).Select(container => container.Parent).ToArray();

            Collapse(items);

            base.DestroyItems(items, unselect);

            foreach (TreeViewItemContainerData parent in parents)
            {
                if (!parent.HasChildren(this))
                {
                    VirtualizingTreeViewItem treeViewItem = (VirtualizingTreeViewItem)GetItemContainer(parent.Item);
                    if (treeViewItem != null)
                    {
                        treeViewItem.CanExpand = false;
                    }
                }
            }
        }
        private void MoveSubtree(TreeViewItemContainerData parent, TreeViewItemContainerData child)
        {
            int  parentSiblingIndex    = IndexOf(parent.Item);
            int  siblingIndex          = IndexOf(child.Item);
            bool incrementSiblingIndex = false;

            if (parentSiblingIndex < siblingIndex)
            {
                incrementSiblingIndex = true;
            }

            TreeViewItemContainerData prev   = parent;
            VirtualizingTreeViewItem  tvItem = (VirtualizingTreeViewItem)GetItemContainer(prev.Item);

            if (tvItem != null)
            {
                tvItem.UpdateIndent();
            }
            while (child != null && child.IsDescendantOf(parent))
            {
                if (prev == child)
                {
                    break;
                }
                base.SetNextSiblingInternal(prev, child);

                tvItem = (VirtualizingTreeViewItem)GetItemContainer(child.Item);
                if (tvItem != null)
                {
                    tvItem.UpdateIndent();
                }

                prev = child;
                if (incrementSiblingIndex)
                {
                    siblingIndex++;
                }
                child = (TreeViewItemContainerData)GetItemContainerData(siblingIndex);
            }
        }
Exemplo n.º 29
0
        protected override void SetPrevSiblingInternal(
            ItemContainerData sibling,
            ItemContainerData prevSibling)
        {
            TreeViewItemContainerData itemContainerData1 = (TreeViewItemContainerData)sibling;
            TreeViewItemContainerData itemContainerData2 = (TreeViewItemContainerData)prevSibling;
            TreeViewItemContainerData child = itemContainerData2.FirstChild(this);

            base.SetPrevSiblingInternal(sibling, prevSibling);
            if (child != null)
            {
                this.MoveSubtree(itemContainerData2, child);
            }
            this.SetParent(itemContainerData1.Parent, itemContainerData2);
            VirtualizingTreeViewItem itemContainer = (VirtualizingTreeViewItem)this.GetItemContainer(itemContainerData2.Item);

            if (!Object.op_Inequality((Object)itemContainer, (Object)null))
            {
                return;
            }
            itemContainer.UpdateIndent();
        }
        protected override void SetPrevSiblingInternal(ItemContainerData sibling, ItemContainerData prevSibling)
        {
            TreeViewItemContainerData tvSiblingData   = (TreeViewItemContainerData)sibling;
            TreeViewItemContainerData tvItemData      = (TreeViewItemContainerData)prevSibling;
            TreeViewItemContainerData tvDragItemChild = tvItemData.FirstChild(this);

            base.SetPrevSiblingInternal(sibling, prevSibling);

            if (tvDragItemChild != null)
            {
                MoveSubtree(tvItemData, tvDragItemChild);
            }

            SetParent(tvSiblingData.Parent, tvItemData);

            VirtualizingTreeViewItem tvItem = (VirtualizingTreeViewItem)GetItemContainer(tvItemData.Item);

            if (tvItem != null)
            {
                tvItem.UpdateIndent();
            }
        }