private void OnMouseMove(object sender, MouseEventArgs e) { DataGrid dataGrid = sender as DataGrid; Point p = e.GetPosition(dataGrid); if (this.isMouseDown && (this.dragStartPoint - p).Length > 10) { List <FileDescriptor> files = new List <FileDescriptor>(); var items = dataGrid.SelectedItems.Cast <ExplorerItem>().ToList(); FindRecursive(files, items); this.numOfFiles = files.Count; this.copyIndex = 0; var virtualFileDataObject = new VirtualFileDataObject(Start, Stop, Pull); virtualFileDataObject.SetData(files); this.dlg = new ProgresshWindow() { Owner = Window.GetWindow(this) }; VirtualFileDataObject.DoDragDrop(dataGrid, virtualFileDataObject, DragDropEffects.Copy); this.isMouseDown = false; } }
public object StartDrag(ObjectListView olv, System.Windows.Forms.MouseButtons button, OLVListItem item) { var dataObject = new VirtualFileDataObject(); dataObject.SetData(from rowObject in olv.SelectedObjects.Cast <RowObject>() select CreateFileDescriptor(rowObject.Name, rowObject.Binary)); return(dataObject); }
internal bool DragDropFiles(object dragitem) { DnDtempFolder = Common.CreateTempFolder("PackageEditorDnD_"); List <FileData> files = null; FolderTreeNode node; int fullNodeNameLen = 0; if (dragitem is FolderTreeNode) { node = (FolderTreeNode)dragitem; files = getAllFilesUnderNode(node); VirtFsNode fsnode = node.virtFsNode;// Avoids CS1690 if (fsnode.FileName != null) { fullNodeNameLen = (treeHelper.GetFullNodeName(node)).Length - node.Text.Length; } } else { node = (FolderTreeNode)fsFolderTree.SelectedNode; files = getSelectedFiles(); VirtFsNode fsnode = node.virtFsNode;// Avoids CS1690 if (fsnode.FileName != null) { fullNodeNameLen = (treeHelper.GetFullNodeName(node)).Length; } } VirtualFileDataObject vfdo = new VirtualFileDataObject(); vfdo.IsAsynchronous = true; vfdo.PreferredDropEffect = DragDropEffects.Copy; List <VirtualFileDataObject.FileDescriptor> fileDescriptors = new List <VirtualFileDataObject.FileDescriptor>(); foreach (FileData item in files) { VirtualFileDataObject.FileDescriptor fileDecriptor = new VirtualFileDataObject.FileDescriptor(); fileDecriptor.Name = item.virtFsNode.FileName.Remove(0, fullNodeNameLen); fileDecriptor.Length = (long)item.virtFsNode.EndOfFile; fileDecriptor.ChangeTimeUtc = DateTime.FromFileTime((long)item.virtFsNode.ChangeTime).ToUniversalTime(); fileDecriptor.ExtraInfo = item.virtFsNode.FileName; fileDecriptor.StreamContents = new VirtualFileDataObject.MyAction <Delay.VirtualFileDataObject.Tuple <Stream, string> >(GetFileData); fileDescriptors.Add(fileDecriptor); } vfdo.SetData(fileDescriptors); vfdo.PreferredDropEffect = DragDropEffects.Copy; fsFilesList.DoDragDrop(vfdo, DragDropEffects.Copy); return(true); }
public void DoDragDrop(IParent parent) { VirtualFileDataObject virtualFileDataObject = new VirtualFileDataObject(); List <VirtualFileDataObject.FileDescriptor> files = new List <VirtualFileDataObject.FileDescriptor>(); this.PopulateFiles(files, parent, ((IViewable)parent).Name); virtualFileDataObject.SetData(files); var effect = VirtualFileDataObject.DoDragDrop(this.Control, virtualFileDataObject, DragDropEffects.Copy); if (effect == DragDropEffects.None) { virtualFileDataObject = null; } Console.WriteLine("Finished Drag-Drop operation setup"); }
public VirtualFileDataObject GetDataObject(DragDropEffects ActionToTake) { List <VirtualFileDataObject.FileDescriptor> _descs = new List <VirtualFileDataObject.FileDescriptor>(); foreach (ShellFile _file in Files) { VirtualFileDataObject.FileDescriptor _fd = new VirtualFileDataObject.FileDescriptor(); _fd.Name = _file.Name; _fd.Length = _file.Size; _fd.StreamContents = _file.WriteContentsToStream; _descs.Add(_fd); } VirtualFileDataObject _vdo = new VirtualFileDataObject(GetActionStarted, GetActionComplete); _vdo.SetData(_descs); _vdo.PreferredDropEffect = (System.Windows.DragDropEffects)ActionToTake; _vdo.IsAsynchronous = false; return(_vdo); }
public VirtualFileDataObject GetDataObject(DragDropEffects ActionToTake) { List<VirtualFileDataObject.FileDescriptor> _descs = new List<VirtualFileDataObject.FileDescriptor>(); foreach (ShellFile _file in Files) { VirtualFileDataObject.FileDescriptor _fd = new VirtualFileDataObject.FileDescriptor(); _fd.Name = _file.Name; _fd.Length = _file.Size; _fd.StreamContents = _file.WriteContentsToStream; _descs.Add(_fd); } VirtualFileDataObject _vdo = new VirtualFileDataObject(GetActionStarted, GetActionComplete); _vdo.SetData(_descs); _vdo.PreferredDropEffect = (System.Windows.DragDropEffects)ActionToTake; _vdo.IsAsynchronous = false; return _vdo; }
internal bool DragDropFiles(object dragitem) { DnDtempFolder = Common.CreateTempFolder("PackageEditorDnD_"); List<FileData> files = null; FolderTreeNode node; int fullNodeNameLen = 0; if (dragitem is FolderTreeNode) { node = (FolderTreeNode)dragitem; files = getAllFilesUnderNode(node); VirtFsNode fsnode = node.virtFsNode;// Avoids CS1690 if (fsnode.FileName != null) fullNodeNameLen = (treeHelper.GetFullNodeName(node)).Length - node.Text.Length; } else { node = (FolderTreeNode)fsFolderTree.SelectedNode; files = getSelectedFiles(); VirtFsNode fsnode = node.virtFsNode;// Avoids CS1690 if (fsnode.FileName != null) fullNodeNameLen = (treeHelper.GetFullNodeName(node)).Length; } VirtualFileDataObject vfdo = new VirtualFileDataObject(); vfdo.IsAsynchronous = true; vfdo.PreferredDropEffect = DragDropEffects.Copy; List<VirtualFileDataObject.FileDescriptor> fileDescriptors = new List<VirtualFileDataObject.FileDescriptor>(); foreach (FileData item in files) { VirtualFileDataObject.FileDescriptor fileDecriptor = new VirtualFileDataObject.FileDescriptor(); fileDecriptor.Name = item.virtFsNode.FileName.Remove(0, fullNodeNameLen); fileDecriptor.Length = (long)item.virtFsNode.EndOfFile; fileDecriptor.ChangeTimeUtc = DateTime.FromFileTime((long)item.virtFsNode.ChangeTime).ToUniversalTime(); fileDecriptor.ExtraInfo = item.virtFsNode.FileName; fileDecriptor.StreamContents = new VirtualFileDataObject.MyAction<Delay.VirtualFileDataObject.Tuple<Stream, string>>(GetFileData); fileDescriptors.Add(fileDecriptor); } vfdo.SetData(fileDescriptors); vfdo.PreferredDropEffect = DragDropEffects.Copy; fsFilesList.DoDragDrop(vfdo, DragDropEffects.Copy); return true; }