public override void Update(GameTime gameTime)
        {
            CurrentCycle.Update(gameTime);

            SourceRectangle.Y = CycleIndex * SourceRectangle.Height;
            SourceRectangle.X = CurrentCycle.FrameIndex * SourceRectangle.Width;
        }
Example #2
0
        private void TimerTick(object sender, EventArgs e)
        {
            if (CurrentCycle == null || CurrentCycle.Tick())
            {
                if (!WaitingCycles.Any())
                {
                    CreateCycles();
                }

                CurrentCycle = WaitingCycles.Dequeue();

                CycleCount++;

                _progress.Value    = 0f;
                _progress.MaxValue = 25f;
            }



            if (CurrentCycle.InBreak)
            {
                _lastColorIndex = (_lastColorIndex + 3) % 360;


                _progress.MaxValue = CurrentCycle.MaxBreakMinutes;

                SetForeColors(Properties.Resources.Spectre.GetPixel(_lastColorIndex, 0));
                _progress.Value = _progress.MaxValue - CurrentCycle.SecondProgress / 60f;

                Text           = new TimeSpan(0, 0, (int)(CurrentCycle.MaxBreakMinutes * 60) - CurrentCycle.SecondProgress).ToString("mm':'ss") + " - Break";
                lblStatus.Text = new TimeSpan(0, 0, (int)(CurrentCycle.MaxBreakMinutes * 60) - CurrentCycle.SecondProgress).ToString("mm':'ss") + "\r\n" + CycleCount.ToString();
            }
            else
            {
                if (CurrentCycle.SecondProgress % 60 == 0)
                {
                    _lastColorIndex = (_lastColorIndex + 1) % 360;
                    SetForeColors(Properties.Resources.Spectre.GetPixel(_lastColorIndex, 0));
                }

                _progress.MaxValue = CurrentCycle.MaxWorkMinutes;
                _progress.Value    = CurrentCycle.SecondProgress / 60f;

                Text           = new TimeSpan(0, 0, (int)(CurrentCycle.MaxWorkMinutes * 60) - CurrentCycle.SecondProgress).ToString("mm':'ss") + " - Pomodoro";
                lblStatus.Text = new TimeSpan(0, 0, (int)(CurrentCycle.MaxWorkMinutes * 60) - CurrentCycle.SecondProgress).ToString("mm':'ss") + "\r\n" + CycleCount.ToString();
            }

            if (CurrentCycle.InBreak != _inBreakBuffer)
            {
                _inBreakBuffer = CurrentCycle.InBreak;

                Running = false;
                if (CurrentCycle.InBreak)
                {
                    lblStatus.Text = "Break Time";
                }
                else
                {
                    lblStatus.Text = "Break Over";
                }

                _blinkTimer.Start();
            }
        }