/// <summary> /// Causes the device to vibrate for the specified duration. /// </summary> /// <param name="vibrateController">This is used to control /// the vibration on the device.</param> /// <param name="durationMS">The duration for which to vibrate, /// in milliseconds. Default is 100 MS.</param> /// <param name="repetitions">The number of times to repeat the cycle /// of vibration and pausing.</param> /// <param name="intervalMS">The pause time in milliseconds between repetitions.</param> /// <returns></returns> public static Task VibrateAsync(this IVibrateController vibrateController, uint durationMS = 100, uint intervalMS = 0, uint repetitions = 0) { var durationTimeSpan = TimeSpan.FromMilliseconds(durationMS); return(Task.Run(async() => { for (int i = 0; i < repetitions + 1; i++) { vibrateController.Start(durationTimeSpan); await Task.Delay(durationTimeSpan); if (intervalMS > 0) { await Task.Delay((int)intervalMS); } } })); }
public IncomingCallDialogViewModel(UDCListModel udc, IVibrateController vibCon) { Answered = false; this.vibCon = vibCon; this.udc = udc; }
private void StartObserving() { vibrateController = IoC.Get<IVibrateController>(); if (compassObs == null) compassObs = Sensors.GetCurrentCompassSmooth(0.2) //compassObs = Sensors.GetCurrentMotionAsCompass() .SubscribeOn(ThreadPoolScheduler.Instance) .ObserveOn(ReactiveExtensions.SyncScheduler) .Subscribe(cd => { if (cd.IsValid && cd.IsSupported && cd.Reading.HasValue) { var reading = cd.Reading.Value; if (headingChanged != null) { var heading = reading.TrueHeading; var displayOrientation = ((PhoneApplicationFrame)App.Current.RootVisual).Orientation; switch (displayOrientation) { case PageOrientation.LandscapeLeft: heading += 90; break; case PageOrientation.LandscapeRight: heading -= 90; break; case PageOrientation.PortraitDown: heading += 180; break; case PageOrientation.PortraitUp: break;// no change } heading %= 360; if (reading.HeadingAccuracy <= 20 && reading.HeadingAccuracy < lastAccuracy && lastAccuracy > 20) vibrateController.Start(TimeSpan.FromMilliseconds(200)); headingChanged(this, new HeadingAndAccuracy(heading, reading.HeadingAccuracy)); } lastAccuracy = reading.HeadingAccuracy; } else { lastAccuracy = 180; headingChanged(this, new HeadingAndAccuracy(0, 180)); } }); }