Ejemplo n.º 1
0
        bool IVirtualKeyboard.TryGetText(uint virtualKey, VirtualKeyModifiers virtualKeyModifiers, out string text, out bool isDeadKey)
        {
            try
            {
                if (VirtualKeyModifiers.Oem1 == (virtualKeyModifiers & VirtualKeyModifiers.Oem1))
                {
                    if (!Oem1Modifier.HasValue)
                    {
                        text      = String.Empty;
                        isDeadKey = false;
                        return(false);
                    }
                }

                if (Oem1Modifier.HasValue && KeyboardState.IsKeySet(Oem1Modifier.Value))
                {
                    virtualKeyModifiers |= VirtualKeyModifiers.Oem1;
                }

                if (VirtualKeyModifiers.Oem2 == (virtualKeyModifiers & VirtualKeyModifiers.Oem2))
                {
                    if (!Oem2Modifier.HasValue)
                    {
                        text      = String.Empty;
                        isDeadKey = false;
                        return(false);
                    }
                }

                if (Oem2Modifier.HasValue && KeyboardState.IsKeySet(Oem2Modifier.Value))
                {
                    virtualKeyModifiers |= VirtualKeyModifiers.Oem2;
                }

                var key      = KeyInterop.KeyFromVirtualKey((int)virtualKey);
                var keyState = new KeyState(key, virtualKeyModifiers);
                isDeadKey = false;
                return(_keyMap.TryGetValue(keyState, out text));
            }
            finally
            {
                _keyboardState.Clear();
            }
        }