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 CustomResourceProperty(Image imagePreview, string grfPath1, string grfPath2, string ext, int row, int column, DbAttribute attribute) { _imageResource = new Image(); _imageResource.Margin = new Thickness(3); _imageResource.Width = 22; _imagePreview = imagePreview; _grfPath1 = grfPath1; _grfPath2 = grfPath2; _textBox = new TextBox(); _textBox.Margin = new Thickness(3); _imageResource.Stretch = Stretch.None; _imageResource.HorizontalAlignment = HorizontalAlignment.Left; _imageResource.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); imagePreview.Stretch = Stretch.None; imagePreview.HorizontalAlignment = HorizontalAlignment.Left; imagePreview.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); _gridRow = row; _gridColumn = column; _ext = ext; _attribute = attribute; _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged); VirtualFileDataObject.SetDraggable(_imageResource, _wrapper1); VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper2); }
/// <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(); } }
public CustomManagerProperty(TextBox textBox, string grfPath, string ext, int row, int col, int rSpan, int cSpan) { _image = new Image { Stretch = Stretch.None, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; _image.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); _viewer = new ScrollViewer(); Grid grid = new Grid(); //grid.ColumnDefinitions.Add(new ColumnDefinition) WpfUtilities.SetGridPosition(_viewer, row, rSpan, col, cSpan); _viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.Content = _image; _textBox = textBox; _grfPath = grfPath.Trim('\\'); _ext = ext; _attribute = null; _textBox.TextChanged += _textBox_TextChanged; VirtualFileDataObject.SetDraggable(_image, _wrapper); _viewer.SizeChanged += delegate { _viewer.MaxHeight = _viewer.ActualHeight; }; }
protected void GetActionComplete(VirtualFileDataObject vdo) { if (ActionCompleted != null) { ActionCompleted(this, (DragDropEffects)vdo.PerformedDropEffect); } }
protected void GetActionStarted(VirtualFileDataObject vdo) { if (ActionStarted != null) { ActionStarted(this, (DragDropEffects)vdo.PreferredDropEffect); } }
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); }
public MultiGrfExplorer(MultiGrfReader metaGrf, string explorerPath, string filter, string selected) : base("Meta GRF explorer", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize) { InitializeComponent(); ShowInTaskbar = true; _explorerPath = explorerPath.ToLower(); _metaGrf = metaGrf; //metaGrf.Lock(); if (filter != "") { _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry).Where(p => p.RelativePath.IndexOf(filter, StringComparison.OrdinalIgnoreCase) > -1)); } else { _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry)); } _entriesAll.AddRange(_entries); foreach (FileEntry entry in _entries) { entry.DataImage = entry.DisplayRelativePath; } _loadEncoding(); ListViewDataTemplateHelper.GenerateListViewTemplateNew(_items, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.RangeColumnInfo { Header = "File name", DisplayExpression = "DataImage", ToolTipBinding = "RelativePath", IsFill = true, MinWidth = 60, TextWrapping = TextWrapping.Wrap }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Type", DisplayExpression = "FileType", FixedWidth = 40, TextAlignment = TextAlignment.Right, ToolTipBinding = "FileType" }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Size", DisplayExpression = "DisplaySize", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "DisplaySize" }, }, new MetaGrfSorter(), new string[] { }); _items.MouseDoubleClick += new MouseButtonEventHandler(_items_MouseDoubleClick); _items.ItemsSource = _entries; VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper); ApplicationShortcut.Link(ApplicationShortcut.Copy, _copyItems, _items); ApplicationShortcut.Link(ApplicationShortcut.Confirm, () => _buttonSelect_Click(null, null), _items); this.Loaded += delegate { _items.SelectedItem = _entries.FirstOrDefault(p => String.CompareOrdinal(p.DisplayRelativePath, selected.ToDisplayEncoding(true) + ".bmp") == 0); _items.ScrollToCenterOfView(_items.SelectedItem); }; this.Owner = WpfUtilities.TopWindow; }
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; }
private void Stop(VirtualFileDataObject o) { MTAInvoke(() => this.dlg.Hide()); }
private void Start(VirtualFileDataObject o) { MTAInvoke(() => this.dlg.Show()); }