Example #1
0
        public bool ProcessTouch(TouchLocation touch)
        {
            bool touchHandled = false;
            bool isInside     = Destination.Contains((int)touch.Position.X,
                                                     (int)touch.Position.Y);

            switch (touch.State)
            {
            case TouchLocationState.Pressed:
                if (isInside)
                {
                    isPressed    = true;
                    touchId      = touch.Id;
                    touchHandled = true;
                }
                break;

            case TouchLocationState.Moved:
                if (touchId.HasValue && touchId.Value == touch.Id)
                {
                    isPressed    = isInside;
                    touchHandled = true;
                }
                break;

            case TouchLocationState.Released:
                if (touchId.HasValue && touchId.Value == touch.Id)
                {
                    if (isInside && Click != null)
                    {
                        Click(this, EventArgs.Empty);
                    }

                    touchId      = null;
                    isPressed    = false;
                    touchHandled = true;
                }
                break;
            }
            return(touchHandled);
        }