Example #1
0
        public override void BeginInit()
        {
            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys = new List<ModifierKeyBase>();
            _allLogicalKeys = new List<ILogicalKey>();
            _allOnScreenKeys = new List<OnScreenKey>();

            _sections = new ObservableCollection<OnScreenKeyboardSection>();

            var mainSection = new OnScreenKeyboardSection();
            var mainKeys = GetMainKeys();

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);
            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(3, GridUnitType.Star)});
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);

            _modifierKeys.AddRange(_allLogicalKeys.OfType<ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }
        public override void BeginInit()
        {
            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys = new List<ModifierKeyBase>();
            _allLogicalKeys = new List<ILogicalKey>();
            _allOnScreenKeys = new List<OnScreenKey>();

            _sections = new ObservableCollection<OnScreenKeyboardSection>();
            var mainSection = new OnScreenKeyboardSection();
            var mainKeys = GetMainKeys();

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);
            ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) });
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);

            var specialSection = new OnScreenKeyboardSection();
            var specialKeys = new ObservableCollection<OnScreenKey>
                                  {
                                      new OnScreenKey { GridRow = 0, GridColumn = 0, Key = new ChordKey("Select All", VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A), GridWidth = new GridLength(2, GridUnitType.Star)},
                                      new OnScreenKey { GridRow = 0, GridColumn = 1, Key = new ChordKey("Undo", VirtualKeyCode.CONTROL, VirtualKeyCode.VK_Z) },
                                      new OnScreenKey { GridRow = 1, GridColumn = 0, Key = new ChordKey("Copy", VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C) },
                                      new OnScreenKey { GridRow = 1, GridColumn = 1, Key = new ChordKey("Cut", VirtualKeyCode.CONTROL, VirtualKeyCode.VK_X) },
                                      new OnScreenKey { GridRow = 1, GridColumn = 2, Key = new ChordKey("Paste", VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V) },
                                      new OnScreenKey { GridRow = 2, GridColumn = 0, Key = new VirtualKey(VirtualKeyCode.DELETE, "Del") },
                                      new OnScreenKey { GridRow = 2, GridColumn = 1, Key = new VirtualKey(VirtualKeyCode.HOME, "Home") },
                                      new OnScreenKey { GridRow = 2, GridColumn = 2, Key = new VirtualKey(VirtualKeyCode.END, "End") },
                                      new OnScreenKey { GridRow = 3, GridColumn = 0, Key = new VirtualKey(VirtualKeyCode.PRIOR, "PgUp") },
                                      new OnScreenKey { GridRow = 3, GridColumn = 1, Key = new VirtualKey(VirtualKeyCode.UP, "Up") },
                                      new OnScreenKey { GridRow = 3, GridColumn = 2, Key = new VirtualKey(VirtualKeyCode.NEXT, "PgDn") },
                                      new OnScreenKey { GridRow = 4, GridColumn = 0, Key = new VirtualKey(VirtualKeyCode.LEFT, "Left") },
                                      new OnScreenKey { GridRow = 4, GridColumn = 1, Key = new VirtualKey(VirtualKeyCode.DOWN, "Down") },
                                      new OnScreenKey { GridRow = 4, GridColumn = 2, Key = new VirtualKey(VirtualKeyCode.RIGHT, "Right") },
                                  };

            specialSection.Keys = specialKeys;
            specialSection.SetValue(ColumnProperty, 1);
            _sections.Add(specialSection);
            ColumnDefinitions.Add(new ColumnDefinition());
            Children.Add(specialSection);

            _allLogicalKeys.AddRange(specialKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(specialSection.Keys);

            _modifierKeys.AddRange(_allLogicalKeys.OfType<ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }
Example #3
0
        public override void BeginInit()
        {
            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys    = new List <ModifierKeyBase>();
            _allLogicalKeys  = new List <ILogicalKey>();
            _allOnScreenKeys = new List <OnScreenKey>();

            _sections = new ObservableCollection <OnScreenKeyboardSection>();

            var mainSection = new OnScreenKeyboardSection();
            var mainKeys    = new ObservableCollection <OnScreenKey>
            {
                new OnScreenKey {
                    GridRow = 0, GridColumn = 0, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_3, new List <string> {
                        "`", "~"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 1, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_1, new List <string> {
                        "1", "!"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 2, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_2, new List <string> {
                        "2", "@"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 3, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_3, new List <string> {
                        "3", "#"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 4, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_4, new List <string> {
                        "4", "$"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 5, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_5, new List <string> {
                        "5", "%"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 6, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_6, new List <string> {
                        "6", "^"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 7, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_7, new List <string> {
                        "7", "&"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 8, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_8, new List <string> {
                        "8", "*"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 9, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_9, new List <string> {
                        "9", "("
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 10, Key = new ShiftSensitiveKey(VirtualKeyCode.VK_0, new List <string> {
                        "0", ")"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 11, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_MINUS, new List <string> {
                        "-", "_"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 12, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_PLUS, new List <string> {
                        "=", "+"
                    })
                },
                new OnScreenKey {
                    GridRow = 0, GridColumn = 13, Key = new VirtualKey(VirtualKeyCode.BACK, "წაშლა"), GridWidth = new GridLength(2, GridUnitType.Star)
                },

                new OnScreenKey {
                    GridRow = 1, GridColumn = 0, Key = new VirtualKey(VirtualKeyCode.TAB, "Tab"), GridWidth = new GridLength(1.5, GridUnitType.Star)
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 1, Key = new CaseSensitiveKey(VirtualKeyCode.VK_Q, new List <string> {
                        "q", "Q"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 2, Key = new CaseSensitiveKey(VirtualKeyCode.VK_W, new List <string> {
                        "w", "W"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 3, Key = new CaseSensitiveKey(VirtualKeyCode.VK_E, new List <string> {
                        "e", "E"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 4, Key = new CaseSensitiveKey(VirtualKeyCode.VK_R, new List <string> {
                        "r", "R"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 5, Key = new CaseSensitiveKey(VirtualKeyCode.VK_T, new List <string> {
                        "t", "T"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 6, Key = new CaseSensitiveKey(VirtualKeyCode.VK_Y, new List <string> {
                        "y", "Y"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 7, Key = new CaseSensitiveKey(VirtualKeyCode.VK_U, new List <string> {
                        "u", "U"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 8, Key = new CaseSensitiveKey(VirtualKeyCode.VK_I, new List <string> {
                        "i", "I"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 9, Key = new CaseSensitiveKey(VirtualKeyCode.VK_O, new List <string> {
                        "o", "O"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 10, Key = new CaseSensitiveKey(VirtualKeyCode.VK_P, new List <string> {
                        "p", "P"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 11, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_4, new List <string> {
                        "[", "{"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 12, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_6, new List <string> {
                        "]", "}"
                    })
                },
                new OnScreenKey {
                    GridRow = 1, GridColumn = 13, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_5, new List <string> {
                        "\\", "|"
                    }), GridWidth = new GridLength(1.3, GridUnitType.Star)
                },

                new OnScreenKey {
                    GridRow = 2, GridColumn = 0, Key = new TogglingModifierKey("Caps", VirtualKeyCode.CAPITAL), GridWidth = new GridLength(1.7, GridUnitType.Star)
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 1, Key = new CaseSensitiveKey(VirtualKeyCode.VK_A, new List <string> {
                        "a", "A"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 2, Key = new CaseSensitiveKey(VirtualKeyCode.VK_S, new List <string> {
                        "s", "S"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 3, Key = new CaseSensitiveKey(VirtualKeyCode.VK_D, new List <string> {
                        "d", "D"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 4, Key = new CaseSensitiveKey(VirtualKeyCode.VK_F, new List <string> {
                        "f", "F"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 5, Key = new CaseSensitiveKey(VirtualKeyCode.VK_G, new List <string> {
                        "g", "G"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 6, Key = new CaseSensitiveKey(VirtualKeyCode.VK_H, new List <string> {
                        "h", "H"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 7, Key = new CaseSensitiveKey(VirtualKeyCode.VK_J, new List <string> {
                        "j", "J"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 8, Key = new CaseSensitiveKey(VirtualKeyCode.VK_K, new List <string> {
                        "k", "K"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 9, Key = new CaseSensitiveKey(VirtualKeyCode.VK_L, new List <string> {
                        "l", "L"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 10, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_1, new List <string> {
                        ";", ":"
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 11, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_7, new List <string> {
                        "\"", "\""
                    })
                },
                new OnScreenKey {
                    GridRow = 2, GridColumn = 12, Key = new VirtualKey(VirtualKeyCode.RETURN, "Enter"), GridWidth = new GridLength(1.8, GridUnitType.Star)
                },

                new OnScreenKey {
                    GridRow = 3, GridColumn = 0, Key = new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 1, Key = new CaseSensitiveKey(VirtualKeyCode.VK_Z, new List <string> {
                        "z", "Z"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 2, Key = new CaseSensitiveKey(VirtualKeyCode.VK_X, new List <string> {
                        "x", "X"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 3, Key = new CaseSensitiveKey(VirtualKeyCode.VK_C, new List <string> {
                        "c", "C"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 4, Key = new CaseSensitiveKey(VirtualKeyCode.VK_V, new List <string> {
                        "v", "V"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 5, Key = new CaseSensitiveKey(VirtualKeyCode.VK_B, new List <string> {
                        "b", "B"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 6, Key = new CaseSensitiveKey(VirtualKeyCode.VK_N, new List <string> {
                        "n", "N"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 7, Key = new CaseSensitiveKey(VirtualKeyCode.VK_M, new List <string> {
                        "m", "M"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 8, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_COMMA, new List <string> {
                        ",", "<"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 9, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_PERIOD, new List <string> {
                        ".", ">"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 10, Key = new ShiftSensitiveKey(VirtualKeyCode.OEM_2, new List <string> {
                        "/", "?"
                    })
                },
                new OnScreenKey {
                    GridRow = 3, GridColumn = 11, Key = new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)
                },

                new OnScreenKey {
                    GridRow = 4, GridColumn = 0, Key = new VirtualKey(VirtualKeyCode.SPACE, " "), GridWidth = new GridLength(5, GridUnitType.Star)
                },
            };

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(3, GridUnitType.Star)
            });
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);



            _modifierKeys.AddRange(_allLogicalKeys.OfType <ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }
Example #4
0
        public override void BeginInit()
        {
            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys = new List<ModifierKeyBase>();
            _allLogicalKeys = new List<ILogicalKey>();
            _allOnScreenKeys = new List<OnScreenKey>();

            _sections = new ObservableCollection<OnScreenKeyboardSection>();

            var mainSection = new OnScreenKeyboardSection();
            var mainKeys = new ObservableCollection<OnScreenKey>
                               {
                                   new OnScreenKey { GridRow = 0, GridColumn = 0, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_3, new List<string> { "`", "~" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 1, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_1, new List<string> { "1", "!" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 2, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_2, new List<string> { "2", "@" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 3, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_3, new List<string> { "3", "#" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 4, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_4, new List<string> { "4", "$" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 5, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_5, new List<string> { "5", "%" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 6, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_6, new List<string> { "6", "^" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 7, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_7, new List<string> { "7", "&" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 8, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_8, new List<string> { "8", "*" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 9, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_9, new List<string> { "9", "(" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_0, new List<string> { "0", ")" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_MINUS, new List<string> { "-", "_" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 12, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_PLUS, new List<string> { "=", "+" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 13, Key =  new VirtualKey(VirtualKeyCode.BACK, "Bksp"), GridWidth = new GridLength(2, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 1, GridColumn = 0, Key =  new VirtualKey(VirtualKeyCode.TAB, "Tab"), GridWidth = new GridLength(1.5, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 1, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Q, new List<string> { "q", "Q" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_W, new List<string> { "w", "W" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_E, new List<string> { "e", "E" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_R, new List<string> { "r", "R" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_T, new List<string> { "t", "T" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Y, new List<string> { "y", "Y" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_U, new List<string> { "u", "U" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 8, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_I, new List<string> { "i", "I" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 9, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_O, new List<string> { "o", "O" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 10, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_P, new List<string> { "p", "P" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_4, new List<string> { "[", "{" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 12, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_6, new List<string> { "]", "}" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 13, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_5, new List<string> { "\\", "|" }), GridWidth = new GridLength(1.3, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 2, GridColumn = 0, Key =  new TogglingModifierKey("Caps", VirtualKeyCode.CAPITAL), GridWidth = new GridLength(1.7, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 2, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_A, new List<string> { "a", "A" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_S, new List<string> { "s", "S" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_D, new List<string> { "d", "D" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_F, new List<string> { "f", "F" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_G, new List<string> { "g", "G" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_H, new List<string> { "h", "H" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_J, new List<string> { "j", "J" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 8, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_K, new List<string> { "k", "K" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 9, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_L, new List<string> { "l", "L" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_1, new List<string> { ";", ":" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_7, new List<string> { "\"", "\"" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 12, Key =  new VirtualKey(VirtualKeyCode.RETURN, "关闭软键盘"), GridWidth = new GridLength(1.8, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 3, GridColumn = 0, Key =  new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 3, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Z, new List<string> { "z", "Z" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_X, new List<string> { "x", "X" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_C, new List<string> { "c", "C" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_V, new List<string> { "v", "V" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_B, new List<string> { "b", "B" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_N, new List<string> { "n", "N" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_M, new List<string> { "m", "M" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 8, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_COMMA, new List<string> { ",", "<" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 9, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_PERIOD, new List<string> { ".", ">" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_2, new List<string> { "/", "?" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 11, Key =  new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 4, GridColumn = 0, Key =  new VirtualKey(VirtualKeyCode.SPACE, " "), GridWidth = new GridLength(5, GridUnitType.Star)},
                               };

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);
            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(3, GridUnitType.Star)});
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);

            _modifierKeys.AddRange(_allLogicalKeys.OfType<ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }
Example #5
0
        public override void BeginInit()
        {
            InputMethodSwitcher.ToRus();

            SetValue(FocusManager.IsFocusScopeProperty, true);
            _modifierKeys = new List<ModifierKeyBase>();
            _allLogicalKeys = new List<ILogicalKey>();
            _allOnScreenKeys = new List<OnScreenKey>();

            _sections = new ObservableCollection<OnScreenKeyboardSection>();

            var mainSection = new OnScreenKeyboardSection();
            var mainKeys = new ObservableCollection<OnScreenKey>
                               {
                                   new OnScreenKey { GridRow = 0, GridColumn = 0, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_3, new List<string> { "ё", "Ё" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 1, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_1, new List<string> { "1", "!" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 2, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_2, new List<string> { "2", "\"" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 3, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_3, new List<string> { "3", "№" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 4, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_4, new List<string> { "4", ";" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 5, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_5, new List<string> { "5", "%" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 6, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_6, new List<string> { "6", ":" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 7, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_7, new List<string> { "7", "?" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 8, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_8, new List<string> { "8", "*" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 9, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_9, new List<string> { "9", "(" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.VK_0, new List<string> { "0", ")" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_MINUS, new List<string> { "-", "_" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 12, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_PLUS, new List<string> { "=", "+" })},
                                   new OnScreenKey { GridRow = 0, GridColumn = 13, Key =  new VirtualKey(VirtualKeyCode.BACK, "Bksp"), GridWidth = new GridLength(2, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 1, GridColumn = 0, Key =  new VirtualKey(VirtualKeyCode.TAB, "Tab"), GridWidth = new GridLength(1.5, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 1, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Q, new List<string> { "й", "Й" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_W, new List<string> { "ц", "Ц" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_E, new List<string> { "у", "У" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_R, new List<string> { "к", "К" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_T, new List<string> { "е", "Е" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Y, new List<string> { "н", "Н" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_U, new List<string> { "г", "Г" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 8, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_I, new List<string> { "ш", "Ш" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 9, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_O, new List<string> { "щ", "Щ" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 10, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_P, new List<string> { "з", "З" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 11, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_4, new List<string> { "х", "Х" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 12, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_6, new List<string> { "ъ", "Ъ" })},
            //                                   new OnScreenKey { GridRow = 1, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_4, new List<string> { "[", "{" })},
            //                                   new OnScreenKey { GridRow = 1, GridColumn = 12, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_6, new List<string> { "]", "}" })},
                                   new OnScreenKey { GridRow = 1, GridColumn = 13, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_5, new List<string> { "\\", "/" }), GridWidth = new GridLength(1.3, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 2, GridColumn = 0, Key =  new TogglingModifierKey("Caps", VirtualKeyCode.CAPITAL), GridWidth = new GridLength(1.7, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 2, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_A, new List<string> { "ф", "Ф" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_S, new List<string> { "ы", "Ы" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_D, new List<string> { "в", "В" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_F, new List<string> { "а", "А" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_G, new List<string> { "п", "П" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_H, new List<string> { "р", "Р" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_J, new List<string> { "о", "О" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 8, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_K, new List<string> { "л", "Л" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 9, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_L, new List<string> { "д", "Д" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 10, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_1, new List<string> { "ж", "Ж" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 11, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_7, new List<string> { "э", "Э" })},
            //                                   new OnScreenKey { GridRow = 2, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_1, new List<string> { ";", ":" })},
            //                                   new OnScreenKey { GridRow = 2, GridColumn = 11, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_7, new List<string> { "\"", "\"" })},
                                   new OnScreenKey { GridRow = 2, GridColumn = 12, Key =  new VirtualKey(VirtualKeyCode.RETURN, "Enter"), GridWidth = new GridLength(1.8, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 3, GridColumn = 0, Key =  new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)},
                                   new OnScreenKey { GridRow = 3, GridColumn = 1, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_Z, new List<string> { "я", "Я" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 2, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_X, new List<string> { "ч", "Ч" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 3, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_C, new List<string> { "с", "С" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 4, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_V, new List<string> { "м", "М" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 5, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_B, new List<string> { "и", "И" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 6, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_N, new List<string> { "т", "Т" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 7, Key =  new CaseSensitiveKey(VirtualKeyCode.VK_M, new List<string> { "ь", "Ь" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 8, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_COMMA, new List<string> { "б", "Б" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 9, Key =  new CaseSensitiveKey(VirtualKeyCode.OEM_PERIOD, new List<string> { "ю", "Ю" })},
            //                                   new OnScreenKey { GridRow = 3, GridColumn = 8, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_COMMA, new List<string> { ",", "<" })},
            //                                   new OnScreenKey { GridRow = 3, GridColumn = 9, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_PERIOD, new List<string> { ".", ">" })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 10, Key =  new ShiftSensitiveKey(VirtualKeyCode.OEM_2, new List<string> { ".", "," })},
                                   new OnScreenKey { GridRow = 3, GridColumn = 11, Key =  new InstantaneousModifierKey("Shift", VirtualKeyCode.SHIFT), GridWidth = new GridLength(2.4, GridUnitType.Star)},

                                   new OnScreenKey { GridRow = 4, GridColumn = 0, Key =  new SwitchLanguageKey("ENG", "En", this), },
                                   new OnScreenKey { GridRow = 4, GridColumn = 1, Key =  new StringKey("@", "@"), },
                                   new OnScreenKey { GridRow = 4, GridColumn = 2, Key =  new VirtualKey(VirtualKeyCode.SPACE, " "), GridWidth = new GridLength(5, GridUnitType.Star)},
                               };

            mainSection.Keys = mainKeys;
            mainSection.SetValue(ColumnProperty, 0);
            _sections.Add(mainSection);

            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(3, GridUnitType.Star)});
            Children.Add(mainSection);

            _allLogicalKeys.AddRange(mainKeys.Select(x => x.Key));
            _allOnScreenKeys.AddRange(mainSection.Keys);

            _modifierKeys.AddRange(_allLogicalKeys.OfType<ModifierKeyBase>());
            _allOnScreenKeys.ForEach(x => x.OnScreenKeyPress += OnScreenKeyPress);

            SynchroniseModifierKeyState();

            base.BeginInit();
        }