public void SetUp()
        {
            var container = new RhinoAutoMocker<ApplicationController>();
            var application = container.Get<IApplication>();
            var hotKeySpecification = container.Get<IHotKeySpecification>();
            var reportPesenter = container.Get<IReportPresenter>();
            var keyboard = container.Get<IKeyboard>();

            _presentationController = container.Get<IPresentationController>();
            _keyboardEventArgs = new KeyboardEventArgs{Handled = false};

            hotKeySpecification
                .Stub(spec => spec.IsSatisfiedBy(Arg<IKeyboard>.Is.Anything))
                .Return(true);

            keyboard
                .Stub(x => x.AltPressed)
                .Return(true);

            keyboard
                .Stub(x => x.CtrlPressed)
                .Return(true);

            keyboard
                .Stub(x => x.ShiftPressed)
                .Return(true);

            keyboard
                .Stub(x => x.KeyPressed)
                .Return(VirtualKeyCode.VK_T);

            var systemUnderTest = container.ClassUnderTest;

            keyboard.Raise(x=>x.KeyDown += null, this, _keyboardEventArgs);
        }
Beispiel #2
0
 private void OnKeyUp(object sender, KeyboardEventArgs args)
 {
     if(_taskChordSpecification.IsStatisfiedBy(args.Chord))
         _presentationController.ShowEntryView();
 }
Beispiel #3
0
		private void OnKeyDown(object sender, KeyboardEventArgs args){
			_pressedKeys.Add(_keyboard.KeyPressed);
			args.Handled = true;
		}
Beispiel #4
0
		private void OnKeyUp(object sender, KeyboardEventArgs args){
			if(_pressedKeys.OrderBy(x=>x).SequenceEqual(_expectedKeys)){
				Task.Factory.StartNew(()=>Struck(this, EventArgs.Empty));
				args.Handled = true;
			}
		}
        public void SetUp()
        {
            var container = new RhinoAutoMocker<ApplicationController>();
            var application = container.Get<IApplication>();
            var hotKeySpecification = container.Get<IHotKeySpecification>();
            var keyboard = container.Get<IKeyboard>();
            var keyboardEventArgs = new KeyboardEventArgs { Handled = false };

            _presentationController = container.Get<IPresentationController>();

            container.ClassUnderTest.Dispose();
        }
Beispiel #6
0
        private int KeyboardCallback(int nCode, Int32 wParam, IntPtr lParam)
        {
            if (nCode != Constants.HC_ACTION)
                return _user32.CallNextHook(_keyboardHookHandle, nCode, wParam, lParam);

            KeyboardHookStruct keyboardEventData = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
            var keyboardEventArgs = new KeyboardEventArgs(keyboardEventData.VirtualKeyCode, GetModifierKeyState());

            switch (wParam)
            {
                case Constants.WM_KEYDOWN:
                    if(_onKeyDown != null)
                        _onKeyDown(this, keyboardEventArgs);
                    break;
                case Constants.WM_KEYUP:
                    if(_onKeyUp != null)
                        _onKeyUp(this, keyboardEventArgs);
                    break;
            }

            if (keyboardEventArgs.Handled)
                return -1;

            return _user32.CallNextHook(_keyboardHookHandle, nCode, wParam, lParam);
        }