protected override void ItemSelected(BaseItem selectedItem) { short flags = ShellNative.FOF_ALLOWUNDO; switch (selectedItem.DisplayName) { case NoConfirmation: flags |= ShellNative.FOF_NOCONFIRMATION; break; case RenameOnConflict: flags |= ShellNative.FOF_RENAMEONCOLLISION; break; default: break; } var fileAction = FilesystemAction.LastFileAction; var filesystemAction = new FilesystemAction(_workspace.NotificationHost); var items = Clipboard.GetFileDropList(); Task.Factory.StartNew(() => { filesystemAction.Paste(_workspace.ActiveLister.Path, items, fileAction, flags); }); if (fileAction == FileAction.Move) { Clipboard.Clear(); } }
private void DropList_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(_dragFormat) && !_dragCanceled) { var files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files == null || !files.Any()) { return; } string destination = null; var listViewItem = FindAnchestor <ListViewItem>(e.OriginalSource); if (listViewItem?.Content is FileItem item) { destination = item.ItemType == ItemType.Container ? item.Path : item.Directory; } else { var listView = FindAnchestor <ListView>(e.OriginalSource); if (listView.DataContext is ILister lister) { destination = lister.Path; } } if (destination != null) { e.Effects = (e.KeyStates & DragDropKeyStates.ControlKey) != 0 ? DragDropEffects.Copy : DragDropEffects.Move; var fileAction = e.Effects == DragDropEffects.Copy ? FileAction.Copy : FileAction.Move; if (_listView.DataContext is FileLister) { FilesystemAction.SetClipboard <FileItem>(fileAction, files); } else { FilesystemAction.SetClipboard <IItem>(fileAction, files); } var action = new FilesystemAction(_notificationHost); var items = Clipboard.GetFileDropList(); Task.Factory.StartNew(() => { action.Paste(destination, items, fileAction); }); if (fileAction == FileAction.Move) { Clipboard.Clear(); } e.Handled = true; } } }