Example #1
0
        private void Update(List <TouchLocation> touches, ref TouchLocation?touch)
        {
            foreach (var touchLocation in touches)
            {
                if (touchLocation.Id == Id)
                {
                    touch = touchLocation;
                    break;
                }

                TouchLocation earliestTouchLocation;
                if (!touchLocation.TryGetPreviousLocation(out earliestTouchLocation))
                {
                    earliestTouchLocation = touchLocation;
                }

                if (Id == -1)
                {
                    if (TouchArea.Contains(earliestTouchLocation.Position.ToPoint()))
                    {
                        touch = earliestTouchLocation;
                        break;
                    }
                }
            }

            if (touch.HasValue)
            {
                Id = touch.Value.Id;
            }
            else
            {
                Id = -1;
            }
        }
Example #2
0
        public bool GetBooleanValue(List <TouchLocation> touches)
        {
            TouchLocation?touch = null;

            Update(touches, ref touch);

            bool result = false;

            if (!touch.HasValue)
            {
                result = false;
            }
            else if (touch.Value.State == TouchLocationState.Pressed)
            {
                result = true;
            }
            else if (touch.Value.State == TouchLocationState.Moved)
            {
                result = TouchArea.Contains(touch.Value.Position.ToPoint());
            }

            return(result);
        }