Пример #1
0
 public DisplayText()
 {
     queue             = new ConcurrentQueue <Response>();
     currentCode       = new ScanCode();
     _rawReceiveData   = new StringBuilder();
     _parseReceiveData = new StringBuilder();
     packetRawData     = new StringBuilder();
     InputString       = string.Empty;
 }
        private void GenerateVisibleKeyPress(ScanCode currentCode)
        {
            ushort key = currentCode.Code;

            if (currentCode.isControlDown)
            {
                currentCode.isControlDown = false;
                currentCode.isControlUp   = false;
                key |= ScanCodeHelper.CONTROL_KEY << 8;
            }

            if (ScanCodeHelper.Instance.VirtualKeyCodes.ContainsKey(key))
            {
                VirtualKeyCode code = ScanCodeHelper.Instance.VirtualKeyCodes[key];

                switch (code)
                {
                case VirtualKeyCode.LEFT: {
                    Index--;
                    break;
                }

                case VirtualKeyCode.RIGHT: {
                    if (Index < (InputString.Length - 1))
                    {
                        Index++;
                    }
                    break;
                }

                case VirtualKeyCode.BACK: {
                    if (Index > 0)
                    {
                        Index--;
                    }
                    break;
                }

                case VirtualKeyCode.SPACE: {
                    Index++;
                    break;
                }

                default: break;
                }

                UiDispatcherHelper.BeginInvokeOnUi(() => {
                    InputSimulator.SimulateKeyPress(code);
                });
            }
        }
Пример #3
0
        private void SimulateKeyPress(ScanCode currentCode)
        {
            ushort key   = currentCode.Code;
            byte   shift = ScanCodeHelper.CONTROL_KEY;

            if (currentCode.isControlDown)
            {
                currentCode.isControlDown = false;
                currentCode.isControlUp   = false;
                key |= (ushort)(shift << 8);
            }

            if (ScanCodeHelper.Instance.VirtualKeyCodes.ContainsKey(key))
            {
                VirtualKeyCode code = ScanCodeHelper.Instance.VirtualKeyCodes[key];

                if (code == VirtualKeyCode.LEFT)
                {
                    Index--;
                }

                if (code == VirtualKeyCode.RIGHT && Index < InputString.Length - 1)
                {
                    Index++;
                }

                if (code == VirtualKeyCode.SPACE)
                {
                    Index++;
                }

                if (code == VirtualKeyCode.BACK && Index != 0)
                {
                    Index--;
                }

                UiDispatcherHelper.BeginInvokeOnUi(() =>
                {
                    InputSimulator.SimulateKeyPress(code);
                });
            }
        }