Пример #1
0
        /// <summary>
        /// Updates the value of the <see cref="Gesture"/> property based on the current property values of this binding.
        /// </summary>
        private void UpdateGestureFromBinding()
        {
            if (updating)
            {
                return;
            }

            updating = true;

            Gesture = new GamePadGesture(Button, PlayerIndex);

            updating = false;
        }
Пример #2
0
        public static Boolean TryParse(String str, IFormatProvider provider, out GamePadGesture gesture)
        {
            Contract.Require(str, nameof(str));

            gesture = null;

            if (String.IsNullOrWhiteSpace(str))
            {
                return(false);
            }

            var parts     = str.Split(':');
            var partIndex = parts.Length == 1 ? null : parts[0].Trim();
            var partEnum  = parts.Length == 1 ? parts[0].Trim() : parts[1].Trim();

            var index = AnyPlayerIndex;

            if (partIndex != null)
            {
                if (partIndex.StartsWith("P", StringComparison.OrdinalIgnoreCase))
                {
                    if (!Int32.TryParse(partIndex.Substring(1), out index) || index < 0)
                    {
                        return(false);
                    }
                }
                else if (!String.Equals("ANY", partIndex, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }

            var button = GamePadButton.None;

            if (!Enum.TryParse(partEnum, true, out button))
            {
                return(false);
            }

            gesture = new GamePadGesture(button, index);
            return(true);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GamePadBinding"/> class.
 /// </summary>
 /// <param name="command">The command associated with the specified gesture.</param>
 /// <param name="gesture">The gesture associated with the specified command.</param>
 public GamePadBinding(ICommand command, GamePadGesture gesture)
     : base(command, gesture)
 {
 }
Пример #4
0
 public static Boolean TryParse(String str, out GamePadGesture gesture)
 {
     return(TryParse(str, null, out gesture));
 }