private OnScreenKeyboardWatcherRaiseEvents SetDisplayMode(DisplayMode displayMode)
        {
            // обработка первой установки
            var setDisplayMode = displayMode.ToPublicDisplayMode();

            if (_displayMode == OnScreenKeyboardDisplayMode.None)
            {
                _displayMode = setDisplayMode;
                return(OnScreenKeyboardWatcherRaiseEvents.None);
            }

            if (_displayMode == setDisplayMode)
            {
                // ничего не изменилось
                return(OnScreenKeyboardWatcherRaiseEvents.None);
            }



            var ret             = OnScreenKeyboardWatcherRaiseEvents.DisplayModeChanged;
            var oldStateVisible = (_displayMode == OnScreenKeyboardDisplayMode.Floating) || (_displayMode == OnScreenKeyboardDisplayMode.Docked);
            var newStateVisible = (setDisplayMode == OnScreenKeyboardDisplayMode.Floating) || (setDisplayMode == OnScreenKeyboardDisplayMode.Docked);

            if (oldStateVisible ^ newStateVisible)
            {
                // поменялась видимость
                if (newStateVisible)
                {
                    ret |= OnScreenKeyboardWatcherRaiseEvents.KeyboardOpened;
                }
                else
                {
                    ret |= OnScreenKeyboardWatcherRaiseEvents.KeyboardClosed;
                }
            }

            if (newStateVisible)
            {
                if (!_openedSince.HasValue)
                {
                    _openedSince = DateTime.Now;
                }
            }
            else
            {
                _openedSince = null;
            }
            _displayMode = setDisplayMode;
            return(ret);
        }