Пример #1
        public Keyboard(Character [,] keySet, int maxDepth)
            keys = keySet;
            _maxDepth = maxDepth;

            DimensionX = keys.GetUpperBound(1);
            DimensionY = keys.GetUpperBound(0);

            // Set up the keyboard character meta data
Пример #2
        // Decided it would be more efficient to use
        // the list of possible valid words from the dictionary and evaluate them then
        // against the keyboard Knight Move permutations using PLinq.
        private static string[] FindValidWords(Character[,] characterSet)
            string fileName = @"..\..\Data\SINGLE.TXT";
            string[] filteredDictionary; // PLinq is more efficient with arrays.
            Keyboard board = new Keyboard(characterSet, SEARCH_DEPTH);

            using (StreamReader sr = new StreamReader(fileName))
                filteredDictionary = sr.Lines().ToArray();

            string[] finalWordList = (from word in filteredDictionary.AsParallel()
                                      where board.ValidateWord(new Word(word))
                                      select word).ToArray();

            return finalWordList;
Пример #3
        /// <summary>
        /// Special keys return more than just a single character
        /// </summary>
        /// <returns>All keys relating to the special keys</returns>
        public List<Character> SpecialKeys(Character currentChar)
            List<Character> charList = new List<Character>();

            // Check if we are on a special key like the spacebar/shift/enter
            // If we are return all the other keys that do not have the same location
            if (this.CurrentCharacter().Id.HasValue)
                charList = (from chr in CharacterList
                            where chr.Id.Value == currentChar.Id.Value
                                && chr.LocationX != currentChar.LocationX
                                && chr.LocationY != currentChar.LocationY
                            select chr).ToList();

            return charList;