private void AssociatedObject_DropRecord(object sender, DropRecordEventArgs e) { try { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { FileModel target = e.TargetRecord as FileModel; string targetPath = target?.IsDirectory == true ? target.FullPath : CurrentFolderPath; IEnumerable <String> filePaths = e.Data.GetData(DataFormats.FileDrop) as IEnumerable <String>; bool sameDrive = Path.GetPathRoot(targetPath) == Path.GetPathRoot(filePaths.First()); bool copy = e.KeyStates.HasFlag(DragDropKeyStates.ControlKey) || (sameDrive && Settings.Default.DragDropSameDrive == 1) || (!sameDrive && Settings.Default.DragDropDifferentDrive == 0); if ((copy && Settings.Default.DragDropConfirmCopy) || (!copy && Settings.Default.DragDropConfirmMove)) { MessageViewModel viewModel = ViewModelSource.Create <MessageViewModel>(); viewModel.Icon = IconType.Question; if (filePaths.Count() == 1) { viewModel.Title = copy ? Properties.Resources.ConfirmCopy : Properties.Resources.ConfirmMove; viewModel.Content = String.Format(copy ? Properties.Resources.ConfirmCopyMessage : Properties.Resources.ConfirmMoveMessage, filePaths.First(), targetPath); } else { viewModel.Title = copy ? Properties.Resources.ConfirmCopy : Properties.Resources.ConfirmMove; viewModel.Content = String.Format(copy ? Properties.Resources.ConfirmMultipleCopy : Properties.Resources.ConfirmMultipleMove, targetPath); viewModel.Details = String.Join(Environment.NewLine, filePaths); } IDialogService dialogService = AssociatedObject.DataContext.GetService <IDialogService>(); MessageResult result = dialogService.ShowDialog(MessageButton.YesNo, viewModel.Title, "MessageView", viewModel); if (result == MessageResult.No) { return; } } if (copy) { Utilities.CopyFiles(filePaths, targetPath); } else { Utilities.MoveFiles(filePaths, targetPath); } } } finally { e.Handled = true; } }
void OnDropRecord(object sender, DropRecordEventArgs e) { if (e.IsFromOutside && e.Data.GetDataPresent(typeof(Employee))) { object data = e.Data.GetData(typeof(Employee)); Employee employee = (Employee)data; e.Data.SetData(new RecordDragDropData(new List <Employee>() { employee }.ToArray())); } }
void OnDropRecord(object sender, DropRecordEventArgs e) { object data = e.Data.GetData(typeof(RecordDragDropData)); foreach (Employee employee in ((RecordDragDropData)data).Records) { employee.Position = ((Employee)e.TargetRecord).Position; employee.Department = ((Employee)e.TargetRecord).Department; } if (e.DropPosition == DropPosition.Inside) { foreach (Employee employee in ((RecordDragDropData)data).Records) { employee.Position = ""; } } }