private void OnFilePaste(object sender, EventArgs e) { try { if (Clipboard.ContainsData(DataFormats.FileDrop)) { var paths = new StringCollection(); paths = Clipboard.GetFileDropList(); modelCopy = new ModelProcessCopy(); modelCopy.Source = paths.Cast <string>().ToList(); modelCopy.DestPath = CurrentPath; modelCopy.SourceCurrentPath = Directory.GetParent(modelCopy.Source[0]).FullName; var cmd = new CommandCopyFiles(modelCopy.Source.Count > 0 && !String.IsNullOrEmpty(modelCopy.DestPath), strings.noSelectedFiles, true, modelCopy, isMove); var presenterProgress = new PresenterProgress(); if (modelCopy != null) { presenterProgress.AddModel(modelCopy); } presenterProgress.AddCommand(cmd); presenterProgress.Show(); CommandManager.Execute(cmd); } if (isMove) { Clipboard.Clear(); } } catch (Exception ex) { MyLog.logger.Error(ex.StackTrace); view.MessageShow(ex.Message, strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OnDragDropped(object sender, EventArgs e) { var items = view.GetSelectedItems(); List <string> selectedItems = new List <string>(); ListViewItem itemDest = view.GetItemDest; foreach (ListViewItem item in items) { if (String.Equals(item.Text, prev, StringComparison.CurrentCultureIgnoreCase)) { selectedItems.Add(fromPath); } else if (fromPath.Length <= 3) { selectedItems.Add(Path.Combine(fromPath, item.Text + item.SubItems[1].Text)); } else { selectedItems.Add(Path.Combine(fromPath, item.Text + item.SubItems[1].Text)); } } modelCopy = new ModelProcessCopy(); modelCopy.Source = selectedItems; if (itemDest != null && !File.Exists(Path.Combine(CurrentPath, itemDest.Text + itemDest.SubItems[1].Text))) { modelCopy.DestPath = Path.Combine(CurrentPath, itemDest.Text); } else { modelCopy.DestPath = CurrentPath; } modelCopy.SourceCurrentPath = Directory.GetParent(modelCopy.Source[0]).FullName; var cmd = new CommandCopyFiles(modelCopy.Source.Count > 0 && !String.IsNullOrEmpty(modelCopy.DestPath), strings.noSelectedFiles, false, modelCopy, false); var presenterProgress = new PresenterProgress(); if (modelCopy != null) { presenterProgress.AddModel(modelCopy); } presenterProgress.AddCommand(cmd); presenterProgress.Show(); CommandManager.Execute(cmd); }