Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        /// <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();
            }
        }
Beispiel #3
0
        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");
        }