Пример #1
0
        protected virtual void PerformDragDropCore(DropPosition position, RadTreeNode targetNode, List <RadTreeNode> draggedNodes)
        {
            RadTreeNode           parent     = targetNode.Parent;
            RadTreeNodeCollection collection = targetNode.TreeViewElement.Nodes;

            if (parent != null)
            {
                collection = parent.Nodes;
            }

            bool dropAtTop = position == DropPosition.BeforeNode;
            int  index     = collection.IndexOf(targetNode);

            if (!dropAtTop && index + 1 <= collection.Count)
            {
                index++;
            }

            foreach (RadTreeNode node in draggedNodes)
            {
                if (!this.OnDragEnding(position, node, targetNode))
                {
                    continue;
                }

                if (node.Parent == parent && node.TreeViewElement == targetNode.TreeViewElement)
                {
                    int nodeIndex = collection.IndexOf(node);

                    if (nodeIndex < index)
                    {
                        index--;
                    }
                }

                node.Remove();
                collection.Insert(index, node);
                index++;
                this.owner.OnDragEnded(new RadTreeViewDragEventArgs(node, targetNode));
            }
        }
Пример #2
0
        protected virtual void PerformDragDropCore(
            DropPosition position,
            RadTreeNode targetNode,
            List <RadTreeNode> draggedNodes)
        {
            RadTreeNode           parent = targetNode.Parent;
            RadTreeNodeCollection nodes  = targetNode.TreeViewElement.Nodes;

            if (parent != null)
            {
                nodes = parent.Nodes;
            }
            bool flag   = position == DropPosition.BeforeNode;
            int  index1 = nodes.IndexOf(targetNode);

            if (!flag && index1 + 1 <= nodes.Count)
            {
                ++index1;
            }
            bool isCopyingNodes = this.IsCopyingNodes;
            int  index2         = 0;

            while (index2 < draggedNodes.Count)
            {
                if (!this.OnDragEnding(position, draggedNodes[index2], targetNode))
                {
                    draggedNodes.RemoveAt(index2);
                }
                else
                {
                    ++index2;
                }
            }
            if (this.owner.bindingProvider.CanDrop || targetNode.treeView != null && targetNode.treeView.bindingProvider.CanDrop)
            {
                this.owner.bindingProvider.DropNodes(targetNode.Parent, draggedNodes);
                foreach (RadTreeNode draggedNode in draggedNodes)
                {
                    this.owner.OnDragEnded(new RadTreeViewDragEventArgs(draggedNode, targetNode));
                }
            }
            else
            {
                foreach (RadTreeNode draggedNode in draggedNodes)
                {
                    RadTreeNode radTreeNode = draggedNode;
                    if (radTreeNode.Parent == parent && radTreeNode.TreeViewElement == targetNode.TreeViewElement && nodes.IndexOf(radTreeNode) < index1)
                    {
                        --index1;
                    }
                    if (isCopyingNodes)
                    {
                        radTreeNode = this.CreateTreeNode(radTreeNode);
                    }
                    else
                    {
                        radTreeNode.Remove();
                    }
                    nodes.Insert(index1, radTreeNode);
                    ++index1;
                    this.owner.OnDragEnded(new RadTreeViewDragEventArgs(radTreeNode, targetNode));
                }
            }
        }