Example #1
0
        protected virtual bool HandleControlStateOnTouch(Touch touch)
        {
            switch (touch.GetState(0))
            {
            case PointStateType.Down:
                ControlState += ControlState.Pressed;
                break;

            case PointStateType.Interrupted:
            case PointStateType.Up:
                if (ControlState.Contains(ControlState.Pressed))
                {
                    ControlState -= ControlState.Pressed;
                }
                break;

            default:
                break;
            }

            return(false);
        }
Example #2
0
        public bool GetValue(ControlState state, out T result)
        {
            if (All != null)
            {
                result = All;

                return(true);
            }

            result = default;

            int index = StateValueList.FindIndex(x => x.State == state);

            if (index >= 0)
            {
                result = StateValueList[index].Value;
                return(true);
            }

            if (state.IsCombined)
            {
                index = StateValueList.FindIndex(x => state.Contains(x.State));
                if (index >= 0)
                {
                    result = StateValueList[index].Value;
                    return(true);
                }
            }

            index = StateValueList.FindIndex(x => x.State == ControlState.Other);
            if (index >= 0)
            {
                result = StateValueList[index].Value;
                return(true);
            }

            return(false);
        }