/// <summary> /// This method initialises the dragging of a TreeNode /// </summary> void ItemDrag(object sender, ItemDragEventArgs e) { ReleaseCom(); startButton = e.Button; ShellItem item = (ShellItem)((TreeNode)e.Item).Tag; dataObjectPtr = ShellHelper.GetIDataObject(new ShellItem[] { item }); if (dataObjectPtr != IntPtr.Zero) { DragDropEffects effects; OnDragStart(new DragEnterEventArgs((item.ParentItem != null ? item.ParentItem : item), br.FolderView)); ShellAPI.DoDragDrop(dataObjectPtr, this, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move, out effects); OnDragEnd(new EventArgs()); } }
public DragDropEffects StartDrag(MouseButtons startButton, FileSystemInfoEx[] selectedItems) { ReleaseCom(); if (selectedItems.Length == 0) { return(DragDropEffects.None); } this.startButton = startButton; dataObjectPtr = ShellHelper.GetIDataObject(selectedItems); if (dataObjectPtr != IntPtr.Zero) { DragDropEffects effects; ShellAPI.DoDragDrop(dataObjectPtr, this, DragDropEffects.Copy | DragDropEffects.Link /*| DragDropEffects.Move*/, out effects); return(effects); } return(DragDropEffects.None); }
/// <summary> /// This method initialises the dragging of a ListViewItem /// </summary> void ItemDrag(object sender, ItemDragEventArgs e) { ReleaseCom(); startButton = e.Button; ShellItem[] items = new ShellItem[br.FileView.SelectedItems.Count]; for (int i = 0; i < br.FileView.SelectedItems.Count; i++) { items[i] = (ShellItem)br.FileView.SelectedItems[i].Tag; } dataObjectPtr = ShellHelper.GetIDataObject(items); if (dataObjectPtr != IntPtr.Zero) { DragDropEffects effects; OnDragStart(new DragEnterEventArgs((items[0].ParentItem != null ? items[0].ParentItem : items[0]), br.FileView)); ShellAPI.DoDragDrop(dataObjectPtr, this, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move, out effects); OnDragEnd(new EventArgs()); } }