using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 新年倒计时
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private DateTime goal = new DateTime(2020, 1, 1, 00, 00, 00);
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Size = new Size(450, 255);
            result.Font = label1.Font;
            player.URL = "media\\By2 - 2020爱你爱你.mp3";
        }

        private void dtNow_Tick(object sender, EventArgs e)
        {
            try
            {
                TimeSpan d = goal.Subtract(DateTime.Now);
                result.Text = string.Format("{0}时 {1}分 {2}秒", d.Hours, d.Minutes, d.Seconds);
                if (d.Seconds < 0)
                {
                    result.Text = "00时 00分 00秒";
                    return;
                }

                if (d.Hours < 1)
                {
                    _1hour.Value = d.Minutes * 60 + d.Seconds;
                }
                if (d.Hours == 0 && d.Minutes == 0 && d.Seconds == 10)
                {
                    _10s();
                }

            }
            catch (Exception err)
            { Console.WriteLine(err.Message); }
            finally { Console.WriteLine(DateTime.Now); }
        }
        private void _10s()
        {
            _10s f = new _10s();
            player.URL = null;
            f.Show();
        }
    }
}
