예제 #1
0
        private void MailPage_DragDrop(object sender, DragEventArgs e)
        {
            System.Drawing.Point targetPoint = this.PointToClient(new System.Drawing.Point(e.X, e.Y));

            ContentNode targetNode = this.GetNodeAt(targetPoint) as ContentNode;

            if (null == targetNode)
            {
                return;
            }

            ContentNode draggedNode = (ContentNode)e.Data.GetData(typeof(ContentNode));

            if (!draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode))
            {
                if (e.Effect == DragDropEffects.Move)
                {
                    int oldParent = draggedNode.Content.Parent;

                    draggedNode.Content.Parent = targetNode.Content.Id;
                    try
                    {
                        UpdateParent(draggedNode.Content);

                        draggedNode.Remove();
                        targetNode.Nodes.Add(draggedNode);

                        targetNode.Expand();
                    }
                    catch (Exception exception)
                    {
                        draggedNode.Content.Parent = oldParent;
                        Utils.ShowMsgBox(exception);
                    }
                }
            }
        }