Example #1
0
        public static void Add(InputManagerCommand command, Action <KeyEventArgs> a)
        {
            List <Action <KeyEventArgs> > actions = null;

            actionMap.TryGetValue(command, out actions);

            if (actions == null)
            {
                actions = new List <Action <KeyEventArgs> >();
            }

            actions.Add(a);
            actionMap[command] = actions;
        }
Example #2
0
        protected static void HandleKeys(object sender, KeyEventArgs e)
        {
            string k = e.Key.ToString() + "(:)" + IsShiftDown + "(:)" + IsCtrlDown + "(:)" + IsAltDown;

            InputManagerCommand cmd = InputManagerCommand.None;

            keyMap.TryGetValue(k, out cmd);

            if (cmd != InputManagerCommand.None)
            {
                List <Action <KeyEventArgs> > actions = null;
                if (actionMap.TryGetValue(cmd, out actions))
                {
                    foreach (Action <KeyEventArgs> a in actions)
                    {
                        a.Invoke(e);
                    }
                }
            }
        }
Example #3
0
        public static void Set(InputManagerCommand command, Key k, bool shift = false, bool ctrl = false, bool alt = false)
        {
            string key = k.ToString() + "(:)" + shift + "(:)" + ctrl + "(:)" + alt;

            keyMap[key] = command;
        }