Exemplo n.º 1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Elapsed = Elapsed.Add(TimeSpan.FromSeconds(1));

            if (CurrentActivity == Activity.Working && Elapsed.TotalSeconds >= config.Working * 60)
            {
                AddHistory(Elapsed.TotalMinutes, true);
                pomodoros++;
                if (pomodoros == config.Pomorodos)
                {
                    ChangeState(Activity.LongBreak);
                }
                else
                {
                    ChangeState(Activity.ShortBreak);
                }
            }

            if ((CurrentActivity == Activity.ShortBreak && Elapsed.TotalSeconds >= config.ShortBreak * 60) ||
                (CurrentActivity == Activity.LongBreak && Elapsed.TotalSeconds >= config.LongBreak * 60))
            {
                AddHistory(Elapsed.TotalMinutes, false);
                ChangeState(Activity.Working);
            }
        }
Exemplo n.º 2
0
                public override void OnNext(TSource value)
                {
                    lock (_gate)
                    {
                        var next = Elapsed.Add(_delay);

                        _queue.Enqueue(new Reactive.TimeInterval <TSource>(value, next));

                        _evt.Release();
                    }
                }
Exemplo n.º 3
0
                public override void OnCompleted()
                {
                    DisposeUpstream();

                    lock (_gate)
                    {
                        var next = Elapsed.Add(_delay);

                        _completeAt   = next;
                        _hasCompleted = true;

                        _evt.Release();
                    }
                }
 private void Tick(object me, ElapsedEventArgs args)
 {
     Elapsed = Elapsed.Add(TimeSpan.FromSeconds(Speed));
     if (PauseTime.HasValue && RealTime >= PauseTime.Value)
     {
         IsPaused   = true;
         IsRealtime = ShowRealTimeWhenPaused;
         StopTick();
     }
     if (IsCompleted)
     {
         StopTick();
     }
 }
Exemplo n.º 5
0
        private void UpdateCounter()
        {
            //if (Elapsed.TotalMilliseconds >= StartTime.TotalMilliseconds)
            //{
            //    return;
            //}

            Elapsed       = Elapsed.Add(TimeSpan.FromMilliseconds(+100));
            ElapsedString = Elapsed.ToString(@"mm\:ss");
            Current       = StartTime.Subtract(Elapsed);
            if (Current.TotalMilliseconds <= StartTime.TotalMilliseconds * 0.4)
            {
                Background = Brushes.Red;
            }
        }
Exemplo n.º 6
0
        async void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Elapsed = Elapsed.Add(TimeSpan.FromSeconds(1));
            if (IsRunning && Elapsed.TotalSeconds == pomodoroDutation * 60)
            {
                IsRunning = false;
                IsInBreak = true;
                Elapsed   = TimeSpan.Zero;

                await SavePomodoroAsync();
            }
            if (IsInBreak && Elapsed.TotalSeconds == pomodoroDutation * 60)
            {
                IsRunning = true;
                IsInBreak = false;
                Elapsed   = TimeSpan.Zero;
            }
        }
Exemplo n.º 7
0
                public override void OnNext(TSource value)
                {
                    var shouldRun = false;

                    lock (_gate)
                    {
                        var next = Elapsed.Add(_delay);

                        _queue.Enqueue(new Reactive.TimeInterval <TSource>(value, next));

                        shouldRun = _ready && !_active;
                        _active   = true;
                    }

                    if (shouldRun)
                    {
                        DrainQueue(_delay);
                    }
                }
Exemplo n.º 8
0
                public override void OnCompleted()
                {
                    DisposeUpstream();

                    var shouldRun = false;

                    lock (_gate)
                    {
                        var next = Elapsed.Add(_delay);

                        _completeAt   = next;
                        _hasCompleted = true;

                        shouldRun = _ready && !_active;
                        _active   = true;
                    }

                    if (shouldRun)
                    {
                        DrainQueue(_delay);
                    }
                }