예제 #1
0
    void Update()
    {
        AssignTouches();

        //compare _touchCache to latest touches
        foreach (Touch t in touches)
        {
            if (!_touchCache.Exists(x => x.fingerId == t.fingerId))
            {
                _touchCache.Add(new TouchInstance(t));
                _touchCache.OrderBy(x => x.fingerId);
            }
        }

        //update TouchInstances in reverse
        //so they can remove themselves when finished
        if (_touchCache.Count > 0)
        {
            for (int i = _touchCache.Count - 1; i >= 0; i--)
            {
                _touchCache[i].Update();
            }
        }

        Pinch.Update();
    }
예제 #2
0
        /// <summary>
        /// get all the current tap gestures
        /// </summary>
        private void GetGestures()
        {
            //go through the taps and get all the new ones
            while (TouchPanel.IsGestureAvailable)
            {
                GestureSample gesture = TouchPanel.ReadGesture();
                switch (gesture.GestureType)
                {
                case GestureType.Tap:
                {
                    var position = ConvertCoordinate(gesture.Position);
                    Clicks.Add(new ClickEventArgs()
                        {
                            Position = position,
                            Button   = MouseButton.Left
                        });
                }
                break;

                case GestureType.DoubleTap:
                {
                    var position = ConvertCoordinate(gesture.Position);
                    Clicks.Add(new ClickEventArgs()
                        {
                            Position    = position,
                            Button      = MouseButton.Left,
                            DoubleClick = true,
                        });
                }
                break;

                case GestureType.Flick:
                {
                    AddFlickEvent(gesture.Delta);
                }
                break;

                case GestureType.Pinch:
                {
                    var position1 = ConvertCoordinate(gesture.Position);
                    var position2 = ConvertCoordinate(gesture.Position2);

                    if (null == Pinch)
                    {
                        Pinch = new PinchManager(position1, position2);
                    }
                    else
                    {
                        Pinch.Update(position1, position2);
                    }
                }
                break;

                case GestureType.PinchComplete:
                {
                    if (null == Pinch)
                    {
                        Pinch = new PinchManager()
                        {
                            Finished = true
                        };
                    }
                    else
                    {
                        Pinch.Finished = true;
                    }
                }
                break;

                case GestureType.Hold:
                {
                    var position = ConvertCoordinate(gesture.Position);
                    Holds.Add(new HoldEventArgs()
                        {
                            Position = position
                        });
                }
                break;
                }
            }
        }