private bool Timer_Tick() { if (RunTimer) { try { if (CanSetTileData && BandClient != null) { SetTileData(); } } catch { } TotalTimeSpan = TotalTimeSpan.Add(TimeSpan.FromSeconds(1)); TotalTime.Text = TotalTimeSpan.Hours.ToString("00") + ":" + TotalTimeSpan.Minutes.ToString("00") + ":" + TotalTimeSpan.Seconds.ToString("00"); ExTimeSpan = ExTimeSpan.Add(TimeSpan.FromSeconds(1)); ExTime.Text = ExTimeSpan.Minutes.ToString("00") + ":" + ExTimeSpan.Seconds.ToString("00"); CalValue.Text = (BandManagement.GetValue(BandSensorType.Calories)).ToString("0"); CalChart(CalBar, WorkoutManagement.PlanData.TotalCals, BandManagement.GetValue(BandSensorType.Calories)); StepValue.Text = (BandManagement.GetValue(BandSensorType.Step)).ToString("0"); CalChart(StepBar, WorkoutManagement.PlanData.TotalSteps, BandManagement.GetValue(BandSensorType.Step)); HeartValue.Text = (BandManagement.GetValue(BandSensorType.HeartRate)).ToString("0"); CalChart(HeartBar, WorkoutManagement.PlanData.AvgHeartRate, BandManagement.GetValue(BandSensorType.HeartRate)); DistanceValue.Text = (BandManagement.GetValue(BandSensorType.Step) * 0.5).ToString("0"); CalChart(DistanceBar, WorkoutManagement.PlanData.TotalSteps * 0.5, BandManagement.GetValue(BandSensorType.Step) * 0.5); } return(true); }
public override void Execute() { PlaySoundAction PlaySound = new PlaySoundAction() { FileName = "Danger.mp3" }; PlaySound.Execute(); BandManagement.SendNotification("Stop now! Stop now!", Microsoft.Band.Portable.Notifications.VibrationType.NotificationAlarm); }
public override void Execute() { PlaySoundAction PlaySound = new PlaySoundAction() { FileName = "Come_on.mp3" }; PlaySound.Execute(); BandManagement.SendNotification("Come on, close to being goal", Microsoft.Band.Portable.Notifications.VibrationType.RampUp); }
public override bool IsPass() { if (!IsDone) { if (BandManagement.GetValue(SensorType) > Value) { return(true); } } return(false); }
public override bool IsPass() { if (!IsDone) { if (BandManagement.GetValue(BandSensorType.Calories) > WorkoutManagement.PlanData.TotalCals - 2) { IsDone = true; return(true); } } return(false); }
public override bool IsPass() { if (!IsDone) { if (BandManagement.GetValue(BandSensorType.HeartRate) > WorkoutManagement.PlanData.AvgHeartRate - 3) { IsDone = true; return(true); } } return(false); }
private async void StartWorkout() { if (BandClient != null) { ExIndex = -1; NextBtn.Text = "Next"; Browser.IsVisible = false; TotalTimeSpan = new TimeSpan(); BeginTime = DateTime.Now; SetWorkout(); await BandManagement.Start(); RunTimer = true; AppManagement.IsEventRuning = true; } }
private async void StopWorkout() { RunTimer = false; ExVideo.Stop(); AppManagement.IsEventRuning = false; SetTileBeginData(); BandManagement.Stop(); await HttpClient.Post <string>("http://aloraha.com/api/report", new AddReportReq() { PlanID = WorkoutManagement.PlanData.Id, AvgHeartRate = (float)BandManagement.GetValue(BandSensorType.HeartRate), TotalCals = (float)BandManagement.GetValue(BandSensorType.Calories), TotalSteps = (float)BandManagement.GetValue(BandSensorType.Step), BeginTime = BeginTime, Duration = (int)TotalTimeSpan.TotalSeconds }); Browser.IsVisible = true; Browser.Uri = "http://aloraha.com/report/workout//?inapp"; }
protected override async void OnAppearing() { base.OnAppearing(); if (!IsFirstTime) { return; } IsFirstTime = false; await BandManagement.Init(); BandClient = BandManagement.BandClient; if (BandClient != null) { await CreateBandTitle(); SetTileBeginData(); BandClient.TileManager.TileButtonPressed += TileManager_TileButtonPressed; Device.StartTimer(TimeSpan.FromSeconds(1), Timer_Tick); } else { try { await DisplayAlert("Band connection", "Please connect to MS Band", "OK"); } catch { } } await Task.Delay(3000); ExImage.IsVisible = false; ExImage.VerticalOptions = LayoutOptions.Fill; ExImage.HorizontalOptions = LayoutOptions.Fill; ExImage.Aspect = Aspect.AspectFill; ExImage.WidthRequest = ExGrid.Width; ExImage.HeightRequest = ExVideo.HeightRequest = ExGrid.Width / 16 * 9; ExGrid.Children.Add(ExImage); ExGrid.Children.Add(ExVideo); }