Exemplo n.º 1
0
        public void AddCombo(Keys[] keys, Action func)
        {
            if (keys.Length == 0)
            {
                if (comboAction != null)
                {
                    throw new InvalidOperationException("Duplicate keycombos");
                }

                if (subNodes.Count != 0)
                {
                    throw new InvalidOperationException("Overlapping keycombos");
                }

                comboAction = func;
                return;
            }

            KeyComboNode node;

            if (subNodes.TryGetValue(keys[0], out node))
            {
                if (node.HasAction())
                {
                    throw new InvalidOperationException("Overlapping keycombos");
                }

                node.AddCombo(keys.Skip(1).ToArray(), func);
            }
            else
            {
                node = new KeyComboNode();
                node.AddCombo(keys.Skip(1).ToArray(), func);
                subNodes[keys[0]] = node;
            }
        }
Exemplo n.º 2
0
 public void AddCombo(Keys[] keys, Action func)
 {
     rootNode.AddCombo(keys, func);
 }