基本信息
源码名称:C# 定时器(倒计时)示例源码
源码大小:0.47M
文件格式:.7z
开发语言:C#
更新时间:2018-08-27
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

设定计时时间,时间到后音箱发出声音,再次循环,小计时器

生产岗位做节拍器提的需求



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 WindowsFormsTime
{
    public partial class Form1 : Form
    {
        public int A_stcnt;
        public int A_time;
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            A_stcnt = A_stcnt-1;
            if (A_stcnt <= 0)
            {
                A_stcnt = A_time;
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources._123);

               // player.SoundLocation = @"D:\kf-dzh\3.C#App\WindowsFormsTime\WindowsFormsTime\sound\123.wav";

                player.LoadAsync();
                player.Play();

               //system.Media.SystemSounds.Asterisk.Play();


            }
            lb_dsp.Text = A_stcnt.ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            A_time= Convert.ToInt32(tb_begin.Text);
            A_stcnt = A_time;
            lb_dsp.Text = A_time.ToString();
            tb_begin.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                A_time = Convert.ToInt32(tb_begin.Text);
                A_stcnt = A_time;
            }
            catch
            {
                MessageBox.Show( "请输入数字! "); 
                return;
            }

            tb_begin.Enabled = false;
        }

        private void label2_Click(object sender, EventArgs e)
        {
            if(tb_begin.Enabled == true)
            {
                tb_begin.Enabled = false;
            }
            else if (tb_begin.Enabled == false)
            {
                tb_begin.Enabled = true;
            }
        }
    }
}