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); })); }
public KeyProviderTests() { passwordModeService = new PasswordModeService(); desktopLockEventService = Substitute.For <IDesktopLockEventService>(); desktopLockEventService.GetSessionSwitchStream().Returns(Observable.Never <SessionSwitchEventArgs>()); settingsProvider = Substitute.For <ISettingsProvider>(); }
public KeyProviderTests() { passwordModeService = new PasswordModeService(); desktopLockEventService = Substitute.For<IDesktopLockEventService>(); desktopLockEventService.GetSessionSwitchStream().Returns(Observable.Never<SessionSwitchEventArgs>()); }