Esempio n. 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 MouseGesture(MouseAction, Modifiers);

            updating = false;
        }
Esempio n. 2
0
        public static Boolean TryParse(String str, IFormatProvider provider, out MouseGesture gesture)
        {
            Contract.Require(str, nameof(str));

            gesture = null;

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

            var mouseAction = MouseAction.None;
            var modifiers   = ModifierKeys.None;

            var parts = str.Split('+').Select(x => x.Trim()).ToArray();

            for (int i = 0; i < parts.Length; i++)
            {
                var isModifier = (i + 1 < parts.Length);
                if (isModifier)
                {
                    var modFromStr = GetModifierKeyFromString(parts[i]);
                    if (modFromStr == null || (modifiers & modFromStr.GetValueOrDefault()) != 0)
                    {
                        return(false);
                    }

                    modifiers |= modFromStr.GetValueOrDefault();
                }
                else
                {
                    if (!Enum.TryParse(parts[i], true, out mouseAction))
                    {
                        return(false);
                    }
                }
            }

            gesture = new MouseGesture(mouseAction, modifiers);
            return(true);
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseBinding"/> 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 MouseBinding(ICommand command, MouseGesture gesture)
     : base(command, gesture)
 {
 }
Esempio n. 4
0
 public static Boolean TryParse(String str, out MouseGesture gesture)
 {
     return(TryParse(str, null, out gesture));
 }