public SetData ( List |
||
fileDescriptors | List |
|
return | void |
public static void SetDraggable(Image imagePreview, GrfImageWrapper wrapper) { imagePreview.Dispatch(delegate { imagePreview.MouseMove += (e, a) => { if (a.LeftButton == MouseButtonState.Pressed) { VirtualFileDataObject virtualFileDataObject = new VirtualFileDataObject(); string name = (string)imagePreview.Tag; List <FileDescriptor> descriptors = new List <FileDescriptor> { new FileDescriptor { Name = name + (name.GetExtension() == null ? Imaging.GuessExtension(((BitmapSource)imagePreview.Source).Format) : ""), Argument = wrapper, StreamContents = (grfData, filePath, stream, argument) => { GrfImageWrapper image = (GrfImageWrapper)argument; if (image.Image != null) { GrfImage grfImage = image.Image; string outputPath = TemporaryFilesManager.GetTemporaryFilePath("image_{0:0000}") + Imaging.GuessExtension(grfImage.GrfImageType); grfImage.Save(outputPath); var data = File.ReadAllBytes(outputPath); stream.Write(data, 0, data.Length); image.Image.Save(outputPath); } } } }; virtualFileDataObject.Source = DragAndDropSource.Other; virtualFileDataObject.SetData(descriptors); try { DoDragDrop(null, virtualFileDataObject, DragDropEffects.Copy); } catch (Exception err) { ErrorHandler.HandleException(err); } } }; }); }
public static void SetDraggable(Image imagePreview, GrfImageWrapper wrapper) { imagePreview.Dispatch(delegate { imagePreview.MouseMove += (e, a) => { if (a.LeftButton == MouseButtonState.Pressed) { VirtualFileDataObject virtualFileDataObject = new VirtualFileDataObject(); string name = (string) imagePreview.Tag; List<FileDescriptor> descriptors = new List<FileDescriptor> { new FileDescriptor { Name = name + (name.GetExtension() == null ? Imaging.GuessExtension(((BitmapSource) imagePreview.Source).Format) : ""), Argument = wrapper, StreamContents = (grfData, filePath, stream, argument) => { GrfImageWrapper image = (GrfImageWrapper) argument; if (image.Image != null) { GrfImage grfImage = image.Image; string outputPath = TemporaryFilesManager.GetTemporaryFilePath("image_{0:0000}") + Imaging.GuessExtension(grfImage.GrfImageType); grfImage.Save(outputPath); var data = File.ReadAllBytes(outputPath); stream.Write(data, 0, data.Length); image.Image.Save(outputPath); } } } }; virtualFileDataObject.Source = DragAndDropSource.Other; virtualFileDataObject.SetData(descriptors); try { DoDragDrop(null, virtualFileDataObject, DragDropEffects.Copy); } catch (Exception err) { ErrorHandler.HandleException(err); } } }; }); }