コード例 #1
0
        protected override void SetPrevSibling(ItemContainer sibling, ItemContainer prevSibling)
        {
            TreeViewItem treeViewItem = (TreeViewItem)sibling;
            TreeViewItem parent       = (TreeViewItem)prevSibling;
            TreeViewItem child        = parent.FirstChild();

            base.SetPrevSibling(sibling, prevSibling);
            if (Object.op_Inequality((Object)child, (Object)null))
            {
                this.MoveSubtree(parent, child);
            }
            parent.Parent = treeViewItem.Parent;
        }
コード例 #2
0
ファイル: TreeView.cs プロジェクト: senyaa1/CuiBuilder
        protected override void SetPrevSibling(ItemContainer sibling, ItemContainer prevSibling)
        {
            TreeViewItem tvSibling     = (TreeViewItem)sibling;
            TreeViewItem tvItem        = (TreeViewItem)prevSibling;
            TreeViewItem dragItemChild = tvItem.FirstChild();

            base.SetPrevSibling(sibling, prevSibling);

            if (dragItemChild != null)
            {
                MoveSubtree(tvItem, dragItemChild);
            }

            tvItem.Parent = tvSibling.Parent;
        }
コード例 #3
0
        protected override void Drop(ItemContainer[] dragItems, ItemContainer dropTarget, ItemDropAction action)
        {
            TreeViewItem tvDropTarget = (TreeViewItem)dropTarget;

            if (action == ItemDropAction.SetLastChild)
            {
                for (int i = 0; i < dragItems.Length; ++i)
                {
                    TreeViewItem tvDragItem = (TreeViewItem)dragItems[i];
                    tvDragItem.Parent = tvDropTarget;
                }
            }
            else if (action == ItemDropAction.SetPrevSibling)
            {
                for (int i = 0; i < dragItems.Length; ++i)
                {
                    TreeViewItem tvDragItem    = (TreeViewItem)dragItems[i];
                    TreeViewItem dragItemChild = tvDragItem.FirstChild();

                    DropItemBefore(tvDropTarget, tvDragItem);
                    if (dragItemChild != null)
                    {
                        MoveSubtree(tvDragItem, dragItemChild);
                    }

                    tvDragItem.Parent = tvDropTarget.Parent;
                }
            }
            else if (action == ItemDropAction.SetNextSibling)
            {
                for (int i = dragItems.Length - 1; i >= 0; --i)
                {
                    TreeViewItem tvDragItem    = (TreeViewItem)dragItems[i];
                    TreeViewItem dragItemChild = tvDragItem.FirstChild();

                    DropItemAfter(tvDropTarget, tvDragItem);
                    if (dragItemChild != null)
                    {
                        MoveSubtree(tvDragItem, dragItemChild);
                    }

                    tvDragItem.Parent = tvDropTarget.Parent;
                }
            }

            UpdateSelectedItemIndex();
        }
コード例 #4
0
        protected override void SetNextSibling(ItemContainer sibling, ItemContainer nextSibling)
        {
            TreeViewItem treeViewItem1 = (TreeViewItem)sibling;
            TreeViewItem treeViewItem2 = treeViewItem1.LastDescendant();

            if (Object.op_Equality((Object)treeViewItem2, (Object)null))
            {
                treeViewItem2 = treeViewItem1;
            }
            TreeViewItem parent = (TreeViewItem)nextSibling;
            TreeViewItem child  = parent.FirstChild();

            base.SetNextSibling((ItemContainer)treeViewItem2, nextSibling);
            if (Object.op_Inequality((Object)child, (Object)null))
            {
                this.MoveSubtree(parent, child);
            }
            parent.Parent = treeViewItem1.Parent;
        }
コード例 #5
0
ファイル: TreeView.cs プロジェクト: senyaa1/CuiBuilder
        protected override void SetNextSibling(ItemContainer sibling, ItemContainer nextSibling)
        {
            TreeViewItem tvSibling      = (TreeViewItem)sibling;
            TreeViewItem lastDescendant = tvSibling.LastDescendant();

            if (lastDescendant == null)
            {
                lastDescendant = tvSibling;
            }
            TreeViewItem tvItem        = (TreeViewItem)nextSibling;
            TreeViewItem dragItemChild = tvItem.FirstChild();

            base.SetNextSibling(lastDescendant, nextSibling);

            if (dragItemChild != null)
            {
                MoveSubtree(tvItem, dragItemChild);
            }

            tvItem.Parent = tvSibling.Parent;
        }
コード例 #6
0
ファイル: TreeView.cs プロジェクト: senyaa1/CuiBuilder
        private void OnTreeViewItemParentChanged(object sender, ParentChangedEventArgs e)
        {
            TreeViewItem tvItem = (TreeViewItem)sender;

            if (!CanHandleEvent(tvItem))
            {
                return;
            }

            TreeViewItem oldParent = e.OldParent;

            if (DropMarker.Action != ItemDropAction.SetLastChild && DropMarker.Action != ItemDropAction.None)
            {
                if (oldParent != null && !oldParent.HasChildren)
                {
                    oldParent.CanExpand = false;
                }
                return;
            }

            TreeViewItem tvDropTarget = e.NewParent;

            if (tvDropTarget != null)
            {
                if (tvDropTarget.CanExpand)
                {
                    tvDropTarget.IsExpanded = true;
                }
                else
                {
                    tvDropTarget.CanExpand = true;
                    try
                    {
                        m_expandSilently        = true;
                        tvDropTarget.IsExpanded = true;
                    }
                    finally
                    {
                        m_expandSilently = false;
                    }
                }
            }

            TreeViewItem dragItemChild = tvItem.FirstChild();
            TreeViewItem lastChild     = null;

            if (tvDropTarget != null)
            {
                lastChild = tvDropTarget.LastChild();
                if (lastChild == null)
                {
                    lastChild = tvDropTarget;
                }
            }
            else
            {
                lastChild = (TreeViewItem)LastItemContainer();
            }

            if (lastChild != tvItem)
            {
                TreeViewItem lastDescendant = lastChild.LastDescendant();
                if (lastDescendant != null)
                {
                    lastChild = lastDescendant;
                }

                if (!lastChild.IsDescendantOf(tvItem))
                {
                    base.SetNextSibling(lastChild, tvItem);
                }
            }

            if (dragItemChild != null)
            {
                MoveSubtree(tvItem, dragItemChild);
            }

            if (oldParent != null && !oldParent.HasChildren)
            {
                oldParent.CanExpand = false;
            }
        }
コード例 #7
0
        private void OnTreeViewItemParentChanged(object sender, ParentChangedEventArgs e)
        {
            TreeViewItem treeViewItem1 = (TreeViewItem)sender;

            if (!this.CanHandleEvent((object)treeViewItem1))
            {
                return;
            }
            TreeViewItem oldParent = e.OldParent;

            if (this.DropMarker.Action != ItemDropAction.SetLastChild && this.DropMarker.Action != ItemDropAction.None)
            {
                if (!Object.op_Inequality((Object)oldParent, (Object)null) || oldParent.HasChildren)
                {
                    return;
                }
                oldParent.CanExpand = false;
            }
            else
            {
                TreeViewItem newParent = e.NewParent;
                if (Object.op_Inequality((Object)newParent, (Object)null))
                {
                    if (newParent.CanExpand)
                    {
                        newParent.IsExpanded = true;
                    }
                    else
                    {
                        newParent.CanExpand = true;
                        try
                        {
                            this.m_expandSilently = true;
                            newParent.IsExpanded  = true;
                        }
                        finally
                        {
                            this.m_expandSilently = false;
                        }
                    }
                }
                TreeViewItem child = treeViewItem1.FirstChild();
                TreeViewItem treeViewItem2;
                if (Object.op_Inequality((Object)newParent, (Object)null))
                {
                    treeViewItem2 = newParent.LastChild();
                    if (Object.op_Equality((Object)treeViewItem2, (Object)null))
                    {
                        treeViewItem2 = newParent;
                    }
                }
                else
                {
                    treeViewItem2 = (TreeViewItem)this.LastItemContainer();
                }
                if (Object.op_Inequality((Object)treeViewItem2, (Object)treeViewItem1))
                {
                    TreeViewItem treeViewItem3 = treeViewItem2.LastDescendant();
                    if (Object.op_Inequality((Object)treeViewItem3, (Object)null))
                    {
                        treeViewItem2 = treeViewItem3;
                    }
                    if (!treeViewItem2.IsDescendantOf(treeViewItem1))
                    {
                        base.SetNextSibling((ItemContainer)treeViewItem2, (ItemContainer)treeViewItem1);
                    }
                }
                if (Object.op_Inequality((Object)child, (Object)null))
                {
                    this.MoveSubtree(treeViewItem1, child);
                }
                if (!Object.op_Inequality((Object)oldParent, (Object)null) || oldParent.HasChildren)
                {
                    return;
                }
                oldParent.CanExpand = false;
            }
        }