Esempio 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");
            }
        }
Esempio 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;
        }
Esempio n. 3
0
 private void btnResume_Click(object sender, EventArgs e)
 {
     CountDownTimer.Start();
 }
Esempio n. 4
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     CountDownTimer.Stop();
 }
Esempio 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);
 }