Esempio n. 1
0
        private void ToggleKey(int row, int col)
        {
            BoardState[row, col] = !BoardState[row, col];

            if (BoardState[row, col])
            {
                OnMapKeyGroup.AddKey(GameMap[row, col]);
                OffMapKeyGroup.RemoveKey(GameMap[row, col]);
            }
            else
            {
                OffMapKeyGroup.AddKey(GameMap[row, col]);
                OnMapKeyGroup.RemoveKey(GameMap[row, col]);
            }
        }
Esempio n. 2
0
        // Crazy long function to print a string
        private static void writeSentence(CorsairKeyboard keyboard, string message, Color color1, Color color2, int typingTime)
        {
            ListKeyGroup      keyGroup1   = new ListKeyGroup(keyboard);
            List <MessageKey> activeKeys1 = new List <MessageKey>();

            keyGroup1.Brush = new SolidColorBrush(color1);

            ListKeyGroup      keyGroup2   = new ListKeyGroup(keyboard);
            List <MessageKey> activeKeys2 = new List <MessageKey>();

            keyGroup2.Brush = new SolidColorBrush(color2);

            int messageIndex = 0;

            foreach (char c in message)
            {
                Char   upperChar = Char.ToUpper(c);
                string c1        = modifyChar(upperChar);

                CorsairKey newKey = keyboard[GetKeyboardID(c1)];
                // Change colors if repeating character
                // Check for space bar and characters. How to map charactes
                if (keyGroup1.ContainsKey(newKey))
                {
                    // Add this char to the secondary key group
                    activeKeys2.Add(new MessageKey(c1, messageIndex));
                    keyGroup2.AddKey(newKey);

                    // Remove Char from other keygroup list
                    activeKeys1.RemoveAll(s => s.key == c1);
                    keyGroup1.RemoveKey(newKey);
                }
                else
                {
                    // Add this char to the primary key group
                    activeKeys1.Add(new MessageKey(c1, messageIndex));
                    keyGroup1.AddKey(newKey);
                    if (keyGroup2.ContainsKey(newKey))
                    {
                        // Remove Key from other keygroup list
                        activeKeys2.RemoveAll(s => s.key == c1);
                        keyGroup2.RemoveKey(newKey);
                    }
                }


                if (activeKeys1.Count > 0 && messageIndex - activeKeys1[0].index > 3)
                {
                    // Remove this key!
                    keyGroup1.RemoveKey(keyboard[GetKeyboardID(activeKeys1[0].key)]);
                    activeKeys1.RemoveAt(0);
                }
                if (activeKeys2.Count > 0 && messageIndex - activeKeys2[0].index > 3)
                {
                    // Remove this key!
                    keyGroup2.RemoveKey(keyboard[GetKeyboardID(activeKeys2[0].key)]);
                    activeKeys2.RemoveAt(0);
                }


                messageIndex++;
                keyboard.Update();
                Wait(typingTime);
            }
            keyGroup1.Detach();
            keyGroup2.Detach();
        }