Beispiel #1
0
 public static void timerElapsed(object o, EventArgs e)
 {
     //DisplayAlert ("Alert", DateTime.Now.ToString() , "OK");
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         timer.setInterval(timer.getInterval() + 1000);
         label.Text = "Hello, " + DateTime.Now;
     });
 }
Beispiel #2
0
        public void timerElapsed(object o, EventArgs e)
        {
            Device.BeginInvokeOnMainThread(() =>  // this function is called each second
            {
                if (timerFlag)
                {
                    timer.setInterval(timer.getInterval());
                    timerTime -= 1000;      //-1s per second
                    if (timerTime < 0)      // what to do when timer reaches 00:00
                    {
                        if (phase % 2 == 0) //each even phase is a working phase
                        {
                            SetTimer(3);
                            rounds -= 1;
                        }
                        else     //odd phase = rest phase
                        {
                            if (phase == 7)
                            {
                                SetTimer(5);
                            }                                    // last phase is a relaxation phase
                            else
                            {
                                SetTimer(4);                     // otherwise, 5 min rest
                            }
                        }


                        if (phase > 7)
                        {
                            phase = 0;
                        }
                        else
                        {
                            phase += 1;
                        }

                        if (rounds == 0)
                        {
                            onReset();
                        }
                    }
                    else
                    {
                        onTick(timerTime);
                    }
                }
            });
        }
Beispiel #3
0
 public void StartWithInactivityInterval()
 {
     timer.stopTimer();
     timer.setInterval(InactivityIntervalInMs);
     timer.startTimer();
 }