示例#1
0
        internal static Movement Create(TouchPoint previous, TouchPoint current)
        {
            Movement movement = new Movement();
            if (previous == null)
            {
                movement.Direction = MovementDirection.New;
                movement.XMovement = 0;
                movement.YMovement = 0;
                movement.InactiveMillis = 0;
            }
            else
            {
                movement.XMovement = current.FocalPointX - previous.FocalPointX;
                // Y is flipped because positive needs to be UP
                movement.YMovement = previous.FocalPointY - current.FocalPointY;
                // Add last 1 if it didn't break threshold
                if (previous.Movement != null && previous.Movement.Magnitude < MOVEMENT_THRESHOLD)
                {
                    movement.XMovement += previous.Movement.XMovement;
                    movement.YMovement += previous.Movement.YMovement;
                    movement.InactiveMillis = previous.Movement.InactiveMillis;
                }
                movement.Magnitude = previous.DistanceTo(current);

                if (movement.Magnitude >= MOVEMENT_THRESHOLD)
                {
                    movement.Direction = movement.FindDirection();
                }
                else
                {
                    movement.Direction = MovementDirection.None;
                    movement.InactiveMillis += TouchMouse.SAMPLING_RATE;
                }
            }

            return movement;
        }
示例#2
0
        internal void CreateMovement(TouchPoint previousPoint)
        {
            if (previousPoint != null)
            {
                previousPoint.HasBeenFollowed = true;
            }

            if (previousPoint != null && previousPoint.Movements != null)
            {
                Movements = previousPoint.Movements;
            }
            else
            {
                Movements = new List<Movement>();
            }

            Movement = Movement.Create(previousPoint, this);
            if (Movement.Direction != MovementDirection.None && Movement.Direction != MovementDirection.New)
            {
                Movements.Add(Movement);
            }
        }
示例#3
0
 internal double DistanceTo(TouchPoint otherPoint)
 {
     return MathHelpers.PythagoreanDistance(FocalPointX - otherPoint.FocalPointX, FocalPointY - otherPoint.FocalPointY);
 }
示例#4
0
 internal static TouchPoint Create(int x, int y)
 {
     TouchPoint touchPoint = new TouchPoint()
     {
         Top = y,
         Bottom = y,
         Left = x,
         Right = x,
         FocalPointX = x,
         FocalPointY = y,
     };
     return touchPoint;
 }