Exemplo n.º 1
0
        private void Tree_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                TreeNode target = GetSuitableDropTarget(e);
                if (target == null)
                {
                    e.Effect = DragDropEffects.None;
                }
                else
                {
                    Entity newParent = (Entity)target.Tag;

                    TreeNode[] nodeList = SelectedNodes;

                    int i = 0;

                    Entity[] entities = new Entity[nodeList.Length];

                    foreach (TreeNode node in nodeList)
                    {
                        entities[i] = (Entity)node.Tag;
                        i++;
                    }

                    if ((e.KeyState & 8) == 8) //check CTRL
                    {
                        ApplicationController.CopyEntity(entities, newParent);
                    }
                    else
                    {
                        ApplicationController.MoveEntity(entities, newParent);
                    }

                    ((TreeNode)newParent.Tag).Expand();
                }
            }
            catch (Exception ex)
            {
                ExceptionBox.Show(ex);
            }
        }