Exemple #1
0
        protected override void OnDragDrop(Forms.DragEventArgs drgevent)
        {
            if (selectedDropNode != null && nodeToBeDropped != null)
            {
                TreeNodeExParent oldParent, newParent;

                if (nodeToBeDropped.Parent != null)
                {
                    oldParent = new TreeNodeExParent(nodeToBeDropped.Parent);
                    nodeToBeDropped.Parent.Nodes.Remove(nodeToBeDropped);
                }
                else
                {
                    oldParent = new TreeNodeExParent(nodeToBeDropped.TreeView);
                    nodeToBeDropped.TreeView.Nodes.Remove(nodeToBeDropped);
                }

                if (dragMoveDirection == DragMoveDirection.On)
                {
                    selectedDropNode.Nodes.Add(nodeToBeDropped);
                    newParent = new TreeNodeExParent(selectedDropNode);
                }
                else
                {
                    int pos = (dragMoveDirection == DragMoveDirection.Above) ? selectedDropNode.Index : selectedDropNode.Index + 1;

                    if (selectedDropNode.Parent == null)
                    {
                        Nodes.Insert(pos, nodeToBeDropped);
                        newParent = new TreeNodeExParent(this);
                    }
                    else
                    {
                        selectedDropNode.Parent.Nodes.Insert(pos, nodeToBeDropped);
                        newParent = new TreeNodeExParent(selectedDropNode.Parent);
                    }
                }

                selectedDropNode.Invalidate();
                nodeToBeDropped.Invalidate();

                // tell the dropped node
                nodeToBeDropped.OnNodeMoved(new TreeNodeExMovedEventArgs(selectedDropNode, oldParent, newParent));

                // tell the receiver
                selectedDropNode.OnNodeDropped(new TreeNodeExMovedEventArgs(selectedDropNode, oldParent, newParent));

                selectedDropNode = nodeToBeDropped = null;
            }

            if (mouseExpandTimer != null)
            {
                mouseExpandTimer.Dispose();
                mouseExpandTimer = null;
            }

            Invalidate();

            base.OnDragDrop(drgevent);
        }
Exemple #2
0
		public TreeNodeExMovedEventArgs(TreeNodeEx node, TreeNodeExParent oldParent, TreeNodeExParent newParent)
		{
			Node = node;
			OldParent = oldParent;
			NewParent = newParent;
		}