Пример #1
0
        public static string GetActionDescription(KeyBindingInfo keyBindingInfo)
        {
            Binding binding = Bindings.GetBindingByKeyBindingInfo(keyBindingInfo);

            if (binding != null)
            {
                return(binding.Description);
            }

            return(string.Empty);
        }
Пример #2
0
        public Binding GetBindingByKeyBindingInfo(KeyBindingInfo keyBindingInfo)
        {
            foreach (Binding binding in Bindings)
            {
                if (binding.KeyBindingInfo.Key.Equals(keyBindingInfo.Key))
                {
                    return(binding);
                }
            }

            return(null);
        }
Пример #3
0
        public static bool TryAssignCombination(string description, KeyBindingInfo keyBindingInfo)
        {
            Binding binding = Bindings.GetBindingByKeyBindingInfo(keyBindingInfo);

            if ((binding != null) && (binding.Description != description))
            {
                return(false);
            }
            else
            {
                ForceAssignCombination(description, keyBindingInfo);
            }

            return(true);
        }
Пример #4
0
        public static void ForceAssignCombination(string description, KeyBindingInfo keyBindingInfo)
        {
            Binding newBinding = Bindings.GetBindingByDescription(description);

            if (newBinding != null)
            {
                Binding oldBinding = Bindings.GetBindingByKeyBindingInfo(keyBindingInfo);

                if (oldBinding != null)
                {
                    oldBinding.KeyBindingInfo = new KeyBindingInfo();
                }

                newBinding.KeyBindingInfo = keyBindingInfo;
            }
        }
Пример #5
0
        public static bool IsKeyBindingDown(ActionType actionType)
        {
            KeyBindingInfo keyBindingInfo = Bindings.GetBindingByAction(actionType).KeyBindingInfo;
            bool           result         = false;

            if (keyBindingInfo.Type == ControllerType.Keyboard)
            {
                Keys keyboardKey = (Keys)keyBindingInfo.Key;
                result = KeyboardManager.IsKeyDown(keyboardKey);
            }
            else if (keyBindingInfo.Type == ControllerType.Mouse)
            {
                ButtonStatus mouseButton = (ButtonStatus)keyBindingInfo.Key;
                result = mouseButton.IsDown;
            }
            else if (keyBindingInfo.Type == ControllerType.Pad)
            {
                //@TODO implement
            }

            return(result);
        }
Пример #6
0
 public Binding(string description, ActionType action, KeyBindingInfo keyBindingInfo)
 {
     Description    = description;
     Action         = action;
     KeyBindingInfo = keyBindingInfo;
 }
Пример #7
0
 private static void AddCombination(string description, ActionType actionType, KeyBindingInfo keyBinding)
 {
     Bindings.Bindings.Add(new Binding(description, actionType, keyBinding));
 }