Beispiel #1
0
 internal virtual void OnPointerReleasedInternal(object sender, PointerRoutedEventArgs args)
 {
     if (!args.Handled)
     {
         PointerReleased?.Invoke(sender, args);
     }
 }
        internal void ProcessTouch(string actionType, XPointerEventArgs args)
        {
            switch (actionType)
            {
            case "Cancelled":
                PointerLost?.Invoke(this, args);
                break;

            case "Entered":
                PointerEntered?.Invoke(this, args);
                break;

            case "Exited":
                PointerExited?.Invoke(this, args);
                break;

            case "Moved":
                PointerMoved?.Invoke(this, args);
                break;

            case "Pressed":
                PointerPressed?.Invoke(this, args);
                break;

            case "Released":
                PointerReleased?.Invoke(this, args);
                break;
            }
        }
Beispiel #3
0
        protected override bool OnUp(MotionEvent e)
        {
            try
            {
                var args = GetPointerEventArgs(e, 0);

                PointerReleased?.Invoke(Target, args);

                return(args.Handled);
            }
            catch (Exception ex)
            {
                Windows.UI.Xaml.Application.Current.RaiseRecoverableUnhandledExceptionOrLog(ex, this);
                return(false);
            }
        }
        private void PointerDetectUIElement_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            PointerPoint win10PointerPoint = e.GetCurrentPoint(PointerDetectUIElement);

            lock (PointerDictLock)
            {
                if (PointerDict.ContainsKey(win10PointerPoint.PointerId))
                {
                    RXPointer pointer = PointerDict[win10PointerPoint.PointerId] as RXPointer;
                    pointer.UpdatePointer(win10PointerPoint, PointerState.Released);
                    PointerReleased?.Invoke(this, pointer);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Beispiel #5
0
 void ICoreWindowEvents.RaisePointerReleased(PointerEventArgs args)
 => PointerReleased?.Invoke(this, args);
        public bool OnTouch(MotionEvent e)
        {
            int pointerIndex = ((int)(e.Action & MotionEventActions.PointerIndexMask)) >> ((int)(MotionEventActions.PointerIndexShift));
            int pointerId    = e.GetPointerId(pointerIndex);
            int down         = (int)(e.ActionMasked & MotionEventActions.PointerDown);
            int up           = (int)(e.ActionMasked & MotionEventActions.PointerUp);

            switch (e.ActionMasked)
            {
            case MotionEventActions.Down:
            case MotionEventActions.PointerDown:
            {
                /*
                 * Touch touch = new Touch(pointerId);
                 * touch.Position = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex));
                 * _Touches.Add(pointerId, touch);
                 * OnTouchAction?.Invoke(touch, TouchMotionAction.Down);
                 */
                if (PointerDict.ContainsKey(pointerId))         //这种情况多半是我在进入断点后把手移开了,就当是释放了手指就好了吧
                {
                    //throw new NotImplementedException();
                    Pointer pointer = PointerDict[pointerId];
                    Vector2 pos     = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex));
                    pointer.UpdatePointer(PointerState.Released);
                    PointerReleased?.Invoke(this, pointer);
                    pointer.UpdatePointer(PointerState.Exited);
                    PointerDict.Remove(pointerId);
                    PointerExited?.Invoke(this, pointer);
                }
                else
                {
                    Pointer pointer = new Pointer(this, pointerId);
                    Vector2 pos     = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex));
                    pointer.UpdatePointer(pos, PointerState.Entered);
                    PointerDict.Add(pointerId, pointer);
                    PointerEntered?.Invoke(this, pointer);
                    pointer.UpdatePointer(pos, PointerState.Pressed);
                    PointerPressed?.Invoke(this, pointer);
                    //Log.Info(TAG, "DOWN:" + pointer.ToString());
                }

                break;
            }

            case MotionEventActions.Up:
            case MotionEventActions.PointerUp:
            {
                //Touch touch = _Touches[pointerId];
                //_Touches.Remove(pointerId);
                //OnTouchAction?.Invoke(touch, TouchMotionAction.Up);
                if (PointerDict.ContainsKey(pointerId))
                {
                    Pointer pointer = PointerDict[pointerId];
                    Vector2 pos     = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex));
                    pointer.UpdatePointer(PointerState.Released);
                    PointerReleased?.Invoke(this, pointer);
                    pointer.UpdatePointer(PointerState.Exited);
                    PointerDict.Remove(pointerId);
                    PointerExited?.Invoke(this, pointer);
                    //Log.Info(TAG, "UP:" + pointer.ToString());
                }
                else
                {
                    //throw new NotImplementedException();
                }


                break;
            }

            case MotionEventActions.Move:
            {
                foreach (var pair in PointerDict)
                {
                    int pIndex = e.FindPointerIndex(pair.Key);
                    if (pIndex < 0)
                    {
                        continue;
                    }
                    Vector2 currentPos = new Vector2(e.GetX(pIndex), e.GetY(pIndex));
                    if (pair.Value.PointerPoint != currentPos)
                    {
                        //pair.Value.PointerPoint = currentPos;
                        pair.Value.UpdatePointer(currentPos);
                        PointerMoved?.Invoke(this, pair.Value);
                        //Log.Info(TAG, "MOVE:" + pair.Value.ToString());
                    }
                }
                break;
            }
            }
            return(true);
        }
Beispiel #7
0
        protected override void Update()
        {
            base.Update();
            lock (_SketchPointersReadyToEnterLock)
            {
                SketchPointersList.AddRange(_SketchPointersReadyToEnter);
                _SketchPointersReadyToEnter.Clear();
            }
            Queue <PointerInfoCache> cacheQueue;

            lock (_PointerInfoCachesLock)
            {
                cacheQueue = new Queue <PointerInfoCache>(_PointerInfoCaches);
                _PointerInfoCaches.Clear();
            }
            while (cacheQueue.Count != 0)
            {
                PointerInfoCache cache = cacheQueue.Dequeue();
                if (cache.CacheEvent == PointerInfoCacheEvent.Moved)
                {
                    cache.HitLayer = cache.SketchPointer.LatestPointerInfoCache.HitLayer;
                }
                cache.SketchPointer.LatestPointerInfoCache = cache;
                if (cache.CacheEvent == PointerInfoCacheEvent.Pressed)
                {
                    foreach (var sketchObject in SketchEngine.SketchObjectList)
                    {
                        if (sketchObject is IInputComponent)
                        {
                            if ((sketchObject as IInputComponent).StartRegion.IsOverlapPoint(cache.SketchPointer.Point))
                            {
                                cache.HitLayer = (sketchObject as IInputComponent).Level;
                                break;
                            }
                        }
                    }
                    cache.SketchPointer.LatestPointerInfoCache = cache;
                }
                switch (cache.CacheEvent)
                {
                case PointerInfoCacheEvent.Entered:
                    PointerEntered?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Pressed:
                    PointerPressed?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Moved:
                    PointerMoved?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Released:
                    PointerReleased?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Exited:
                    PointerExited?.Invoke(this, cache.SketchPointer);
                    break;
                }
            }

            lock (_SketchPointersReadyToExitLock)
            {
                foreach (var readyToExtiPointer in _SketchPointersReadyToExit)
                {
                    SketchPointersList.Remove(readyToExtiPointer);
                }
                _SketchPointersReadyToExit.Clear();
            }
        }