Пример #1
0
        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();
            }
        }
Пример #2
0
        public void Delete()
        {
            var result = new FilesystemAction(Workspace.NotificationHost).Delete(ItemsView.SelectedItems);

            if (result != null)
            {
                Workspace.NotificationHost.AddError(result);
            }
        }
Пример #3
0
        private void DeleteSelectedFiles()
        {
            var selectedItems = _workspace.ActiveLister.SelectedItems.OfType <FileItem>();
            var result        = new FilesystemAction(_workspace.NotificationHost).Delete(selectedItems);

            if (result != null)
            {
                _workspace.NotificationHost.AddError(result);
            }
        }
Пример #4
0
        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;
                }
            }
        }
Пример #5
0
        private void SetSelection(FileAction fa)
        {
            var selection = ItemsView.SelectedItems.Select(s => s.Path);

            FilesystemAction.SetClipboard <FileItem>(fa, selection);
        }