Ejemplo n.º 1
0
        /// <summary>
        /// Handler for Pointer Released event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnPointerReleased(object sender, PointerRoutedEventArgs e)
        {
            var ptrPt = _parentLbItem != null?e.GetCurrentPoint(_parentLbItem) : e.GetCurrentPoint(AssociatedObject);

            var isValidPointer = ((e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) &&
                                  ((DragButton == DragButtonType.MouseLeftButton) || (DragButton == DragButtonType.MouseRightButton) ||
                                   (DragButton == DragButtonType.MouseMiddleButton))) ||
                                 ((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.EndFluidDragAsync(_parentLbItem ?? AssociatedObject, position, positionInParent, e.Pointer);
        }
Ejemplo n.º 2
0
        private async void OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton != DragButton)
            {
                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.EndFluidDragAsync(_parentLbItem ?? AssociatedObject, position, positionInParent);
        }