Beispiel #1
0
 public SelectionResult(KeyStateTree tree, TrieNode <ICombination, KeyEventCommand> candidateNode,
                        bool downInChord)
 {
     Tree          = tree;
     CandidateNode = candidateNode;
     DownInChord   = downInChord;
 }
Beispiel #2
0
        public static KeyStateTree GetOrCreateStateTree(string stateTree)
        {
            if (StateTrees.TryGetValue(stateTree, out var keyStateTree))
            {
                return(keyStateTree);
            }

            keyStateTree = new KeyStateTree(stateTree);
            StateTrees.Add(stateTree, keyStateTree);
            return(keyStateTree);
        }
Beispiel #3
0
        internal IMetaKey Add(IList <ICombination> sequence, KeyEvent keyEvent, KeyCommand command,
                              string stateTree = KeyStateTrees.Default)
        {
            foreach (var combination in sequence)
            {
                foreach (var keyInChord in combination.Chord)
                {
                    foreach (var code in keyInChord.Codes)
                    {
                        var key = (Key)code;
                        if (!key.IsCommonChordKey())
                        {
                            var keyStateTree = KeyStateTree.GetOrCreateStateTree(KeyStateTrees.ChordMap);
                            if (!keyStateTree.Contains(key))
                            {
                                MapOnHit(key.ToCombination(), key.ToCombination(), e => !e.IsVirtual, false);
                            }
                        }
                    }
                }
            }

            return(_hook.Add(sequence, new KeyEventCommand(keyEvent, command), stateTree));
        }