コード例 #1
0
        public static TResult KeyNotificationSwitch <TResult>(KeyNotification notification, TResult defaultResult,
                                                              Func <KeyDownNotification, TResult> onDown,
                                                              Func <KeyUpNotification, TResult> onUp,
                                                              Func <KeyPressNotification, TResult> onPress,
                                                              Func <KeyboardLostNotification, TResult> onDeviceLost)
            where TResult : class
        {
            switch (notification.Kind)
            {
            case KeyNotificationKind.KeyDown:
                return(onDown?.Invoke((KeyDownNotification)notification) ?? defaultResult);

            case KeyNotificationKind.KeyPress:
                return(onPress?.Invoke((KeyPressNotification)notification) ?? defaultResult);

            case KeyNotificationKind.KeyUp:
                return(onUp?.Invoke((KeyUpNotification)notification) ?? defaultResult);

            case KeyNotificationKind.DeviceLost:
                return(onDeviceLost?.Invoke((KeyboardLostNotification)notification) ?? defaultResult);

            default:
                return(defaultResult);
            }
        }
コード例 #2
0
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration();
            key = new KeyNotification();
            configuration.AddEventHandler(key);
            repository = new FakeUserAccountRepository();
            subject = new TestUserAccountService(configuration, repository);
        }
コード例 #3
0
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration();
            key           = new KeyNotification();
            configuration.AddEventHandler(key);
            repository         = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
        public void Init()
        {
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration
            {
                RequireAccountVerification = false
            };
            key = new KeyNotification();
            configuration.AddEventHandler(key);
            repository = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
コード例 #5
0
        private void HandleKeyNotification(KeyNotification n, CallerInfo caller)
        {
            var keyEvent = new CefKeyEvent()
            {
                //Modifiers = (CefEventFlags)((int)(FKeyboard.Modifiers) >> 15)
            };

            switch (n.Kind)
            {
            case KeyNotificationKind.KeyDown:
                var keyDown = n as KeyDownNotification;
                keyEvent.EventType      = CefKeyEventType.KeyDown;
                keyEvent.WindowsKeyCode = (int)keyDown.KeyCode;
                keyEvent.NativeKeyCode  = (int)keyDown.KeyCode;
                break;

            case KeyNotificationKind.KeyPress:
                var keyPress = n as KeyPressNotification;
                keyEvent.EventType           = CefKeyEventType.Char;
                keyEvent.Character           = keyPress.KeyChar;
                keyEvent.UnmodifiedCharacter = keyPress.KeyChar;
                keyEvent.WindowsKeyCode      = (int)keyPress.KeyChar;
                keyEvent.NativeKeyCode       = (int)keyPress.KeyChar;
                break;

            case KeyNotificationKind.KeyUp:
                var keyUp = n as KeyUpNotification;
                keyEvent.EventType      = CefKeyEventType.KeyUp;
                keyEvent.WindowsKeyCode = (int)keyUp.KeyCode;
                keyEvent.NativeKeyCode  = (int)keyUp.KeyCode;
                break;

            default:
                break;
            }
            webRenderer.BrowserHost.SendKeyEvent(keyEvent);
        }
コード例 #6
0
        public static TResult KeyNotificationSwitch <TResult>(KeyNotification notification, TResult defaultResult,
                                                              Func <KeyDownNotification, TResult> onDown            = null,
                                                              Func <KeyUpNotification, TResult> onUp                = null,
                                                              Func <KeyPressNotification, TResult> onPress          = null,
                                                              Func <KeyboardLostNotification, TResult> onDeviceLost = null)
        {
            switch (notification.Kind)
            {
            case KeyNotificationKind.KeyDown:
                return(onDown != null?onDown((KeyDownNotification)notification) : defaultResult);

            case KeyNotificationKind.KeyPress:
                return(onPress != null?onPress((KeyPressNotification)notification) : defaultResult);

            case KeyNotificationKind.KeyUp:
                return(onUp != null?onUp((KeyUpNotification)notification) : defaultResult);

            case KeyNotificationKind.DeviceLost:
                return(onDeviceLost != null?onDeviceLost((KeyboardLostNotification)notification) : defaultResult);

            default:
                return(defaultResult);
            }
        }