コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public override bool IsPass()
 {
     if (!IsDone)
     {
         if (BandManagement.GetValue(SensorType) > Value)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
 public override bool IsPass()
 {
     if (!IsDone)
     {
         if (BandManagement.GetValue(BandSensorType.Calories) > WorkoutManagement.PlanData.TotalCals - 2)
         {
             IsDone = true;
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
 public override bool IsPass()
 {
     if (!IsDone)
     {
         if (BandManagement.GetValue(BandSensorType.HeartRate) > WorkoutManagement.PlanData.AvgHeartRate - 3)
         {
             IsDone = true;
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        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";
        }
コード例 #9
0
        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);
        }