Ejemplo n.º 1
0
        private void countDown(object sender, EventArgs e)
        {
            if (final != DateTime.MinValue)
            {
                timeLeft = final - DateTime.Now;
            }

            else
            {
                timeLeft = timeLeft.Subtract(new TimeSpan(0, 0, 1));
            }

            int days  = timeLeft.Days % 7;
            int weeks = (timeLeft.Days - days) / 7;

            string countDownText = BaseCountDownText + "\n" + weeks + "                 " + days + "                  " + timeLeft.Hours +
                                   "               " + timeLeft.Minutes + "                    " + timeLeft.Seconds;

            lblCountDown.Text = countDownText;

            if (timeLeft == new TimeSpan(0, 0, 0, 0))
            {
                CountDownTimer.Stop();
                MessageBox.Show("Time's up");
            }
        }
Ejemplo n.º 2
0
        private void btnCountSpecific_Click(object sender, EventArgs e)
        {
            int days  = Convert.ToInt16(nudDays.Value);
            int hours = Convert.ToInt16(nudHours.Value);
            int mins  = Convert.ToInt16(nudMins.Value);
            int secs  = Convert.ToInt16(nudSecs.Value);

            CountDownTimer.Start();
            timeLeft = new TimeSpan(days, hours, mins, secs);
            final    = DateTime.MinValue;
        }
Ejemplo n.º 3
0
 private void btnResume_Click(object sender, EventArgs e)
 {
     CountDownTimer.Start();
 }
Ejemplo n.º 4
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     CountDownTimer.Stop();
 }
Ejemplo n.º 5
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     CountDownTimer.Start();
     final = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day
                          , dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second);
 }