/// <summary> /// Handler for Pointer Moved event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnPointerMoved(object sender, PointerRoutedEventArgs e) { var ptrPt = _parentLbItem != null?e.GetCurrentPoint(_parentLbItem) : e.GetCurrentPoint(AssociatedObject); var isValidPointer = (((e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)) && (((DragButton == DragButtonType.MouseLeftButton) && (ptrPt.Properties.IsLeftButtonPressed)) || ((DragButton == DragButtonType.MouseRightButton) && (ptrPt.Properties.IsRightButtonPressed)) || ((DragButton == DragButtonType.MouseMiddleButton) && (ptrPt.Properties.IsMiddleButtonPressed)))) || ((e.Pointer.PointerDeviceType == PointerDeviceType.Pen) && (DragButton == DragButtonType.Pen)) || ((e.Pointer.PointerDeviceType == PointerDeviceType.Touch) && (DragButton == DragButtonType.Touch)); if (!isValidPointer) { return; } // Get the location var position = ptrPt.RawPosition; var fElem = AssociatedObject as FrameworkElement; if ((fElem == null) || (_parentFwPanel == null)) { return; } // Get the location with respect to the parent var positionInParent = e.GetCurrentPoint(_parentFwPanel).RawPosition; await _parentFwPanel.FluidDragAsync(_parentLbItem ?? AssociatedObject, position, positionInParent); }
private async void OnPreviewMouseMove(object sender, MouseEventArgs e) { var isDragging = false; switch (DragButton) { case MouseButton.Left: if (e.LeftButton == MouseButtonState.Pressed) { isDragging = true; } break; case MouseButton.Middle: if (e.MiddleButton == MouseButtonState.Pressed) { isDragging = true; } break; case MouseButton.Right: if (e.RightButton == MouseButtonState.Pressed) { isDragging = true; } break; case MouseButton.XButton1: if (e.XButton1 == MouseButtonState.Pressed) { isDragging = true; } break; case MouseButton.XButton2: if (e.XButton2 == MouseButtonState.Pressed) { isDragging = true; } break; } if (!isDragging) { return; } var position = _parentLbItem != null?e.GetPosition(_parentLbItem) : e.GetPosition(AssociatedObject); var fElem = AssociatedObject as FrameworkElement; if ((fElem == null) || (_parentFwPanel == null)) { return; } var positionInParent = e.GetPosition(_parentFwPanel); await _parentFwPanel.FluidDragAsync(_parentLbItem ?? AssociatedObject, position, positionInParent); }