Beispiel #1
0
        public IObservable <KeyPress> GetKeyStream()
        {
            // We are using an observable create to tie the lifetimes of the session switch stream and the keystream
            return(Observable.Create <KeyPress>(observer =>
            {
                // When desktop is locked we will not get the keyup, because we track the windows key
                // specially we need to set it to not being pressed anymore
                var sessionSwitchStreamSubscription = desktopLockEventService.GetSessionSwitchStream()
                                                      .Subscribe(ss =>
                {
                    if (ss.Reason == SessionSwitchReason.SessionLock)
                    {
                        winKeyPressed = false;
                    }
                }, observer.OnError);

                var keyStreamSubsription = interceptKeysSource.GetKeyStream()
                                           .Select(DetectWindowsKey)
                                           .Where(k => !IsModifierKeyPress(k) && k.KeyDirection == KeyDirection.Down)
                                           .Select(ToCarnacKeyPress)
                                           .Where(keypress => keypress != null)
                                           .Where(k => !passwordModeService.CheckPasswordMode(k.InterceptKeyEventArgs))
                                           .Subscribe(observer);

                return new CompositeDisposable(sessionSwitchStreamSubscription, keyStreamSubsription);
            }));
        }
Beispiel #2
0
 public IDisposable Subscribe(IObserver <KeyPress> observer)
 {
     return(interceptKeysSource
            .Select(DetectWindowsKey)
            .Where(k => !IsModifierKeyPress(k) && k.KeyDirection == KeyDirection.Down)
            .Select(ToCarnacKeyPress)
            .Where(k => !passwordModeService.CheckPasswordMode(k.InterceptKeyEventArgs))
            .Subscribe(observer));
 }