public void PopulateFile(List <VirtualFileDataObject.FileDescriptor> files, FileEntry parent, string path = "") { if (parent.BundleEntries.Count == 0) { return; } string name = this.OutputFullPaths ? parent.Path : path; VirtualFileDataObject.FileDescriptor fileDescriptor = new VirtualFileDataObject.FileDescriptor() { Name = name, StreamContents = () => { MemoryStream stream = new MemoryStream(); PackageFileEntry maxBundleEntry = parent.MaxBundleEntry(); Console.WriteLine("Extracted {0} from package: {1}", name, maxBundleEntry.PackageName.ToString()); byte[] bytes = parent.FileBytes(maxBundleEntry); if (bytes != null) { stream.Write(bytes, 0, bytes.Length); } return(stream); } }; files.Add(fileDescriptor); }
/// <summary> /// Performs the given action when mouse is moving with a the left button pressed. /// </summary> /// <param name="sender">UI container.</param> /// <param name="e">Mouse event captured</param> public void MouseMove(object sender, MouseEventArgs e) { if (sender is FrameworkElement item && e.LeftButton == MouseButtonState.Pressed) { var context = item.DataContext as DroppedDataContext; if (context == null) { return; } CreateDragDropWindow(item); var saveInfo = DragOutDataGetter(context); VirtualFileDataObject.FileDescriptor[] files = new VirtualFileDataObject.FileDescriptor[saveInfo.Keys.Count]; int count = 0; foreach (var info in saveInfo) { files[count++] = new VirtualFileDataObject.FileDescriptor { Name = info.Key, StreamContents = stream => { byte[] data = info.Value(); stream.Write(data, 0, data.Length); } } } ; VirtualFileDataObject obj = new VirtualFileDataObject(() => GiveFeedback(BaseWindow), files); VirtualFileDataObject.DoDragDrop(item, obj, DragDropEffects.Copy); subWindow.Close(); } }
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); }
private VirtualFileDataObject.FileDescriptor CreateFileDescriptor(string name, ProtectedBinary binary) { var descriptor = new VirtualFileDataObject.FileDescriptor(); descriptor.Name = "\\" + name; descriptor.Length = binary.Length; descriptor.StreamContents = stream => { var data = binary.ReadData(); stream.Write(data, 0, data.Length); }; return(descriptor); }
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; }