static void Main(string[] args)
 {
     MobileReceiver aMobile = Mobile.GetAMobile();
     ICommand command = new TurnMobileOn(aMobile);
     MobileButtonInvoker invoker = new MobileButtonInvoker(command);
     invoker.Press();
     command = new PressHome(aMobile);
     invoker = new MobileButtonInvoker(command);
     invoker.Press();
     command = new PressBack(aMobile);
     invoker = new MobileButtonInvoker(command);
     invoker.Press();
     command = new VolumeUp(aMobile);
     invoker = new MobileButtonInvoker(command);
     invoker.Press();
     invoker.Press();
     invoker.PressBack();
     command = new VolumeDown(aMobile);
     invoker = new MobileButtonInvoker(command);
     invoker.Press();
     command = new TurnMobileOff(aMobile);
     invoker = new MobileButtonInvoker(command);
     invoker.Press();
     invoker.PressBack();
     Console.ReadLine();
 }
Beispiel #2
0
        /// <summary>
        /// Registers global hot keys.
        /// </summary>
        /// <param name="hWnd">Main window handle</param>
        public HotKeys(IntPtr hWnd)
        {
            this.handle = hWnd;

            // Register numeric keys
            RegisterHotKey(this.handle, 0, 0, 96);
            RegisterHotKey(this.handle, 1, 0, 97);
            RegisterHotKey(this.handle, 2, 0, 98);
            RegisterHotKey(this.handle, 3, 0, 99);
            RegisterHotKey(this.handle, 4, 0, 100);
            RegisterHotKey(this.handle, 5, 0, 101);
            RegisterHotKey(this.handle, 6, 0, 102);
            RegisterHotKey(this.handle, 7, 0, 103);
            RegisterHotKey(this.handle, 8, 0, 104);
            RegisterHotKey(this.handle, 9, 0, 105);

            // Register hot keys
            RegisterHotKey(this.handle, Add.GetHashCode(), 0, Add);
            RegisterHotKey(this.handle, Current.GetHashCode(), MOD, Current);
            RegisterHotKey(this.handle, Cycle.GetHashCode(), MOD, Cycle);
            RegisterHotKey(this.handle, Next.GetHashCode(), MOD, Next);
            RegisterHotKey(this.handle, Pause.GetHashCode(), MOD, Pause);
            RegisterHotKey(this.handle, Previous.GetHashCode(), MOD, Previous);
            RegisterHotKey(this.handle, VIPAdd.GetHashCode(), MOD, VIPAdd);
            RegisterHotKey(this.handle, VolumeDown.GetHashCode(), MOD, VolumeDown);
            RegisterHotKey(this.handle, VolumeUp.GetHashCode(), MOD, VolumeUp);
        }
Beispiel #3
0
 private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.Delta < 0)
     {
         VolumeDown?.Invoke(this, new EventsArgs <int>(-1));
     }
     else
     {
         VolumeUp?.Invoke(this, new EventsArgs <int>(1));
     }
 }
 public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
 {
     if (keyCode == Keycode.VolumeDown)
     {
         VolumeDown?.Invoke(this, new EventsArgs <int>(-1));
         return(true);
     }
     else if (keyCode == Keycode.VolumeUp)
     {
         VolumeUp?.Invoke(this, new EventsArgs <int>(1));
         return(true);
     }
     return(base.OnKeyDown(keyCode, e));
 }
Beispiel #5
0
        public void TestVolumeDownRadio()
        {
            int expected = 4;

            Device       device  = new Radio();
            Command      command = new VolumeDown(device);
            DeviceButton button  = new DeviceButton(command);

            for (int i = 0; i < 6; i++)
            {
                button.press();
            }

            Assert.AreEqual(expected, device.volume);
        }
Beispiel #6
0
        public void TestVolumeDownTV()
        {
            int expected = 5;

            Device       device  = new Television();
            Command      command = new VolumeDown(device);
            DeviceButton button  = new DeviceButton(command);

            for (int i = 0; i < 5; i++)
            {
                button.press();
            }

            Assert.AreEqual(expected, device.volume);
        }
        public async Task Initialize()
        {
            _gesturesService = GesturesServiceEndpointFactory.Create();
            _gesturesService.StatusChanged += (s, args) => StatusChanged?.Invoke(s, args);
            await _gesturesService.ConnectAsync();

            _dismissNotificationGesture            = new DismissGesture("DismissCall");
            _dismissNotificationGesture.Triggered += async(s, args) => {
                DismissNotification?.Invoke(s, args);
                await _gesturesService.UnregisterGesture(_answerCallGesture);

                await _gesturesService.UnregisterGesture(_dismissNotificationGesture);
            };
            // Phone Gestures
            _hangUpGesture            = new HangUpGesture("HangUpCall");
            _hangUpGesture.Triggered += async(s, args) => {
                HangUpCall?.Invoke(s, args);
                await _gesturesService.UnregisterGesture(_hangUpGesture);
            };

            _answerCallGesture            = new Gesture("AnswerCall", new OnPhonePose("OnPhoneDown", PoseDirection.Down), new OnPhonePose("OnPhoneLeft", PoseDirection.Left));
            _answerCallGesture.Triggered += async(s, args) => {
                AnswerCall?.Invoke(s, args);
                await _gesturesService.UnregisterGesture(_answerCallGesture);

                await _gesturesService.UnregisterGesture(_dismissNotificationGesture);

                await Task.Delay(1000).ContinueWith(async t =>
                {
                    await _gesturesService.RegisterGesture(_hangUpGesture);
                });
            };

            // Source Selection Gestures
            _selectSourceGesture            = new TapGesture("SelectSource");
            _selectSourceGesture.Triggered += (s, args) => {
                _currentSource = (_currentSource + 1) % 4;
                switch (_currentSource)
                {
                case 0:
                    SelectSourcePhone?.Invoke(s, args);
                    break;

                case 1:
                    SelectSourceRadio?.Invoke(s, args);
                    break;

                case 2:
                    SelectSourceMedia?.Invoke(s, args);
                    break;

                case 3:
                    SelectSourceUsb?.Invoke(s, args);
                    break;
                }
            };
            await _gesturesService.RegisterGesture(_selectSourceGesture);

            // Volume Gestures
            _volumeToggleMuteGesture            = new Gesture("VolumeToggleMute", new ClamPose("ClamOpen", clamOpen: true), new ClamPose("ClamClose", clamOpen: false));
            _volumeToggleMuteGesture.Triggered += (s, args) => VolumeToggleMute?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_volumeToggleMuteGesture);

            _volumeUpGesture            = new Gesture("VolumeUp", new PointingFingerPose("Point"), new HandMotion("ClockwiseCircle", new[] { VerticalMotionSegment.ClockwiseArcRightUpward, VerticalMotionSegment.ClockwiseArcRightDownward, VerticalMotionSegment.ClockwiseArcLeftDownward, VerticalMotionSegment.ClockwiseArcLeftUpward }));
            _volumeUpGesture.Triggered += (s, args) => VolumeUp?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_volumeUpGesture);

            _volumeDownGesture            = new Gesture("VolumeDown", new PointingFingerPose("Point"), new HandMotion("CounterClockwiseCircle", new[] { VerticalMotionSegment.CounterClockwiseArcRightDownward, VerticalMotionSegment.CounterClockwiseArcRightUpward, VerticalMotionSegment.CounterClockwiseArcLeftUpward, VerticalMotionSegment.CounterClockwiseArcLeftDownward }));
            _volumeDownGesture.Triggered += (s, args) => VolumeDown?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_volumeDownGesture);

            // Next Channel
            _nextChannelGesture            = GenerateSwipeGesure("SwipeLeft", PoseDirection.Left);
            _nextChannelGesture.Triggered += (s, args) => NextChannel?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_nextChannelGesture);

            // Control A/C
            _tempratureUpGesture            = GenerateSwipeGesure("SwipeUp", PoseDirection.Up);
            _tempratureUpGesture.Triggered += (s, args) => TemperatureUp?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_tempratureUpGesture);

            _tempratureDownGesture            = GenerateSwipeGesure("SwipeDown", PoseDirection.Down);
            _tempratureDownGesture.Triggered += (s, args) => TemperatureDown?.Invoke(s, args);
            await _gesturesService.RegisterGesture(_tempratureDownGesture);
        }