Ejemplo n.º 1
0
        private void ReactToPublishableKeyDownStateChanges()
        {
            foreach (var key in KeyValues.KeysWhichCanBePressedOrLockedDown
                     .Where(k => k.FunctionKey != null && k.FunctionKey.Value.ToVirtualKeyCode() != null))
            {
                var keyCopy = key; //Access to foreach variable in modified

                keyStateService.KeyDownStates[key].OnPropertyChanges(s => s.Value)
                .Subscribe(value =>
                {
                    if (keyStateService.SimulateKeyStrokes)
                    {
                        // ReSharper disable PossibleInvalidOperationException
                        var virtualKeyCode = keyCopy.FunctionKey.Value.ToVirtualKeyCode().Value;
                        // ReSharper restore PossibleInvalidOperationException

                        if (value.IsDownOrLockedDown())
                        {
                            publishService.KeyDown(virtualKeyCode);
                        }
                        else
                        {
                            publishService.KeyUp(virtualKeyCode);
                        }
                    }
                });
            }
        }