ReleasePointerCapture() public méthode

public ReleasePointerCapture ( [ value ) : void
value [
Résultat void
        public static void OnPointerReleased(UIElement sender, TouchSliderC slider, PointerRoutedEventArgs e)
        {
            sender.ReleasePointerCapture(e.Pointer);
            _isDragActive = false;

            if (_lastPoint != null &&
                (_lastPoint.Position.X < 0 || _lastPoint.Position.Y < 0 || _lastPoint.Position.X > slider._trackBackground.ActualWidth || _lastPoint.Position.Y > slider._trackBackground.ActualHeight))
                slider.RaiseOnPointerExited(e);
            e.Handled = true;
        }
Exemple #2
0
        private void PointerReleased(PointerPoint pointerPoint, UIElement target, Pointer pointer)
        {
            // To convert from DIPs (device independent pixels) to screen resolution pixels.
            var dipFactor = DisplayProperties.LogicalDpi / 96.0f;
            var pos = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) * dipFactor;

            var isTouch = pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch;

            _touchQueue.Enqueue((int)pointerPoint.PointerId, TouchLocationState.Released, pos, !isTouch);

            if (!isTouch)
            {
                // Mouse or stylus event.
                UpdateMouse(pointerPoint);

                // Release the captured pointer.
                if (target != null)
                    target.ReleasePointerCapture(pointer);
            }
        }
        /// <summary>
        /// Handler for the event when the user stops dragging the dragElement and releases it.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position where the user clicked w.r.t. the UIElement being dragged</param>
        /// <param name="positionInParent">Position where the user clicked w.r.t. the FluidWrapPanel (the parentFWPanel of the UIElement being dragged</param>
        internal async Task EndFluidDragAsync(UIElement child, Point position, Point positionInParent, Pointer pointer)
        {
            if ((child == null) || (!IsComposing) || (_dragElement == null))
                return;

            // Call the event handler core on the Dispatcher. (Improves efficiency!)
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                _dragElement.RenderTransform = CreateTransform(positionInParent.X - _dragStartPoint.X,
                                                               positionInParent.Y - _dragStartPoint.Y,
                                                               DragScale,
                                                               DragScale);

                child.Opacity = NORMAL_OPACITY;
                // Z-Index is set to 1 so that during the animation it does not go below other elements.
                child.SetValue(Canvas.ZIndexProperty, Z_INDEX_INTERMEDIATE);
                // Release the mouse capture
                child.ReleasePointerCapture(pointer);

                // Reference used to set the Z-Index to 0 during the UpdateFluidLayout
                _lastDragElement = _dragElement;

                _dragElement = null;
                _lastExchangeElement = null;

                InvalidateMeasure();
            });
        }
        /// <summary>
        /// Handler for the event when the user stops dragging the dragElement and releases it.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position where the user clicked w.r.t. the UIElement being dragged</param>
        /// <param name="positionInParent">Position where the user clicked w.r.t. the FluidWrapPanel</param>
        /// <param name="pointer">Pointer</param>
        internal void EndFluidDrag(UIElement child, Point position, Point positionInParent, Pointer pointer)
        {
            if ((child == null) || (!IsComposing) || (_dragElement == null))
                return;

            // Set the offset of the _dragElement's visual
            var visual = _fluidVisuals[_dragElement];
            visual.ImplicitAnimations = _implicitAnimationCollection;
            visual.Opacity = 1f;
            visual.Scale = Vector3.One;
            visual.Offset = new Vector3((float)(positionInParent.X - _dragStartPoint.X),
                                                            (float)(positionInParent.Y - _dragStartPoint.Y),
                                                            0);
            //visual.CenterPoint = new Vector3((float)(ItemWidth / 2), (float)(ItemHeight / 2), 0);

            // Z-Index is set to 1 so that during the animation it does not go below other elements.
            child.SetValue(Canvas.ZIndexProperty, ZIndexIntermediate);
            // Release the pointer capture
            child.ReleasePointerCapture(pointer);

            _dragElement = null;
            _lastExchangedElement = null;

            InvalidateArrange();
        }