Example #1
0
        private void tree_DragDrop(object sender, DragEventArgs e)
        {
            if (!TreeBehaviour.AllowDragDrop)
            {
                return;
            }
            try
            {
                TreeNode            dropNode = tree.GetNodeAt(tree.PointToClient(new Point(e.X, e.Y)));
                DragObjectContainer cnt      = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer));
                if (cnt != null && dropNode != null && cnt.Data is AppObject[])
                {
                    ITreeNode   targetNode  = ((DATreeNode)dropNode).m_node;
                    AppObject[] draggedObjs = (AppObject[])cnt.Data;
                    targetNode.DragDrop(draggedObjs);
                    //MacroManager.DragDropNode(targetNode, draggedObjs);
                }

                try
                {
                    IDataObject obj   = e.Data;
                    string[]    files = (string[])obj.GetData("FileDrop");
                    foreach (string f in files)
                    {
                        string fn = IOTool.GetUniqueFileName(Path.Combine(Root.FileSystemPath, Path.GetFileNameWithoutExtension(f) + ".lnk"));
                        using (StreamWriter sw = new StreamWriter(fn)) sw.Write(f);
                        RefreshRoot();
                        MacroManager.DropFileIntoTree(tree, f);
                    }
                }
                catch (Exception) { }

                tree.SelectedNode = dropNode;
            }
            catch (Exception ex)
            {
                Errors.Report(ex);
            }
        }