Ejemplo n.º 1
0
        /// <summary>
        ///     Called when the drop operation is performed on a node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DragDropHandler(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                Point        pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
                BaseTreeNode destinationNode = (BaseTreeNode)((BaseTreeView)sender).GetNodeAt(pt);
                object       data            = e.Data.GetData("WindowsForms10PersistentObject");
                BaseTreeNode sourceNode      = data as BaseTreeNode;
                if (sourceNode != null && destinationNode != null)
                {
                    if ((e.KeyState & Ctrl) != 0)
                    {
                        destinationNode.AcceptCopy(sourceNode);
                    }
                    else if ((e.KeyState & Alt) != 0)
                    {
                        destinationNode.AcceptMove(sourceNode);
                    }
                    else
                    {
                        destinationNode.AcceptDrop(sourceNode);
                        if (Refactor && Settings.Default.AllowRefactor)
                        {
                            NameSpace nameSpace = EnclosingFinder <NameSpace> .find(sourceNode.Model, true);

                            if (nameSpace != null)
                            {
                                // Only apply refactoring when dropping Model Element items
                                // This is useless for Requirements, and test related elements
                                RefactorAndRelocateOperation refactorAndRelocate =
                                    new RefactorAndRelocateOperation(sourceNode.Model as ModelElement);
                                refactorAndRelocate.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Refactoring", false);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Called when the drop operation is performed on a node
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void DragDropHandler(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
     {
         Point        pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
         BaseTreeNode DestinationNode = (BaseTreeNode)((BaseTreeView)sender).GetNodeAt(pt);
         BaseTreeNode SourceNode      = (BaseTreeNode)e.Data.GetData("WindowsForms10PersistentObject");
         if (DestinationNode != null)
         {
             if ((e.KeyState & CTRL) != 0)
             {
                 DestinationNode.AcceptCopy(SourceNode);
             }
             else if ((e.KeyState & ALT) != 0)
             {
                 DestinationNode.AcceptMove(SourceNode);
             }
             else
             {
                 DestinationNode.AcceptDrop(SourceNode);
             }
         }
     }
 }