Ejemplo n.º 1
0
        private void OnCountdownTimerTicked()
        {
            string[] texts = { "harry up", "move your ass", "le'ts go", "go go go ", "a lil bit more please", "speed up mother f****r", "you can do it", "come on" };
            if (!isInTicked)
            {
                ProgressAnimationLength = 1000;
                isInTicked = true;
            }
            ProgressPracentage = (float)(_timer.TimeLeft.TotalSeconds / _timer.RequestedTime.TotalSeconds);
            Speed = (int)_locationService.Speed;

            CountdownTimer = _timer.TimeLeft;
            if (CountdownTimer.CompareTo(new TimeSpan(0, 0, 0, 3, 0)) == 0)
            {
                _textToSpeach.SpeakNow("3");
                Console.WriteLine("beep3");
            }
            else if (CountdownTimer.CompareTo(new TimeSpan(0, 0, 0, 2, 0)) == 0)
            {
                _textToSpeach.SpeakNow("2");

                Console.WriteLine("beep2");
            }
            else if (CountdownTimer.CompareTo(new TimeSpan(0, 0, 0, 1, 0)) == 0)
            {
                _textToSpeach.SpeakNow("1");

                Console.WriteLine("beep1");
            }

            if (UserExercizeMode == ExercizeMode.Running && CountdownTimer > TimeSpan.FromSeconds(5))
            {
                //SetNotificationTimePeriod();
                //TimerPickersViewModel[(int)UserExercizeMode].Time
                //lastNotifiedTime = DateTime.Now;
                //check speed


                if (lastNotifiedTime == null)
                {
                    if (_locationService.IsSpeedMonotonicInc == false)
                    {
                        Console.WriteLine("notify runner to speed up");

                        _textToSpeach.SpeakNow(texts[RandomeWithoitRepeatInRow(0, texts.Length)]);

                        lastNotifiedTime = DateTime.Now;
                    }
                }
                else
                {
                    //if (((DateTime)lastNotifiedTime).CompareTo(DateTime.Now.Add(TimeSpan.FromSeconds(_locationService.PartialSpeedGraphSize))) <= 0)
                    if (DateTime.Now.CompareTo(((DateTime)lastNotifiedTime).Add(new TimeSpan(0, 0, _locationService.PartialSpeedGraphSize))) >= 0)
                    {
                        if (_locationService.IsSpeedMonotonicInc == false)
                        {
                            Console.WriteLine("notify runner to speed up");
                            _textToSpeach.SpeakNow(texts[RandomeWithoitRepeatInRow(0, texts.Length)]);
                            lastNotifiedTime = DateTime.Now;
                        }
                    }
                }

                // for user that run for an hour it posible to notify every 5 minutes but for user that run for 10 seconds
            }



            //looking for speed and play some cheer sound if UserExercizeMode == Running;
        }