private void treeView_MouseMove(object sender, MouseEventArgs e) { try { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(ServerList); if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) || (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0)) { draggedItem = (TreeViewItem)ServerList.SelectedItem; if (draggedItem != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(ServerList, ServerList.SelectedValue, DragDropEffects.Move); //Checking target is not null and item is //dragging(moving) if ((finalDropEffect == DragDropEffects.Move) && (_target != null)) { // A Move drop was accepted if (!draggedItem.Header.ToString().Equals(_target.Header.ToString())) { CopyItem(draggedItem, _target); _target = null; draggedItem = null; } } } } } } catch (Exception) { } }
private void Child_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { /* * MouseButton? wpfButton = ConvertToWpf(e.Button); * if (!wpfButton.HasValue) * return; * * RaiseEvent(new System.Windows.Input.MouseButtonEventArgs(Mouse.PrimaryDevice, 0, wpfButton.Value) * { * RoutedEvent = Mouse.MouseMoveEvent, * Source = this, * }); */ if (!_drag) { return; } if (_lastPt.X == 0 && _lastPt.Y == 0) { return; } if (Math.Abs(_lastPt.X - e.Location.X) < 5 && Math.Abs(_lastPt.Y - e.Location.Y) < 5) { return; } //if (DragWindow == null) //{ // DragWindow = ((System.Windows.Forms.Control)sender).Capture = false; //} if (e.Button == MouseButtons.Left && DragWindow != null) { // it is necessary to release mouse capture, so thatExtendApplication.Current.DefaultWindow // WPF window will be able to capture mouse input ((System.Windows.Forms.Control)sender).Capture = false; // use helper to acquire window handle //var helper = new System.Windows.Interop. WindowInteropHelper( // DragWindow); IntPtr hwnd = ((System.Windows.Interop.HwndSource)PresentationSource.FromVisual(DragWindow)).Handle; // System.Windows.Interop.HwndSource hwndSource = System.Windows.PresentationSource.FromVisual(DragWindow) as System.Windows.Interop.HwndSource; //if (hwndSource != null) //{ System.Drawing.Rectangle fff = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point(0, 0)); Utility.DragMove(this.Handle); System.Windows.DragDropEffects allowedEffects = System.Windows.DragDropEffects.Move; if (System.Windows.DragDrop.DoDragDrop(this, this, allowedEffects) != System.Windows.DragDropEffects.None) { } //} } }
protected bool CanAcceptData(IDropInfo dropInfo, out System.Windows.DragDropEffects resultingEffect) { _projectBrowseControl._controller.ListView_DropCanAcceptData( dropInfo.Data is System.Windows.IDataObject ? GuiHelper.ToAltaxo((System.Windows.IDataObject)dropInfo.Data) : dropInfo.Data, dropInfo.KeyStates.HasFlag(DragDropKeyStates.ControlKey), dropInfo.KeyStates.HasFlag(DragDropKeyStates.ShiftKey), out var canCopy, out var canMove); resultingEffect = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove); return(canCopy | canMove); }
protected bool CanAcceptData(IDropInfo dropInfo, out System.Windows.DragDropEffects resultingEffect, out Type adornerType) { _projectBrowseControl._controller.PlotItems_DropCanAcceptData( dropInfo.Data is System.Windows.IDataObject ? GuiHelper.ToAltaxo((System.Windows.IDataObject)dropInfo.Data) : dropInfo.Data, dropInfo.TargetItem as Altaxo.Collections.NGTreeNode, GuiHelper.ToAltaxo(dropInfo.InsertPosition), dropInfo.KeyStates.HasFlag(DragDropKeyStates.ControlKey), dropInfo.KeyStates.HasFlag(DragDropKeyStates.ShiftKey), out var canCopy, out var canMove, out var itemIsSwallowingData); resultingEffect = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove); adornerType = itemIsSwallowingData ? DropTargetAdorners.Highlight : DropTargetAdorners.Insert; return(canCopy | canMove); }
public static DragEffects ToEto(this sw.DragDropEffects effects) { var action = DragEffects.None; if (effects.HasFlag(sw.DragDropEffects.Copy)) { action |= DragEffects.Copy; } if (effects.HasFlag(sw.DragDropEffects.Move)) { action |= DragEffects.Move; } if (effects.HasFlag(sw.DragDropEffects.Link)) { action |= DragEffects.Link; } return(action); }
/// <summary> /// Preview for the drag & drop /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void productsDataGrid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { rowIndex = GetCurrentRowIndex(e.GetPosition); if (rowIndex < 0) { return; } MainView_DataGrid.SelectedIndex = rowIndex; MyFile tempFile = MainView_DataGrid.Items[rowIndex] as MyFile; if (tempFile == null) { return; } System.Windows.DragDropEffects dragdropeffects = System.Windows.DragDropEffects.Move; if (DragDrop.DoDragDrop(MainView_DataGrid, tempFile, dragdropeffects) != System.Windows.DragDropEffects.None) { MainView_DataGrid.SelectedItem = tempFile; } }
/// <inheritdoc /> public void DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo) { }