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)); }
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); }