基本信息
源码名称:C# 简单的定时器 示例代码
源码大小:0.03M
文件格式:.rar
开发语言:C#
更新时间:2017-07-06
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 4 元×
微信扫码支付:4 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//add by kj
//using System.Collections;
namespace 定时器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// 单选框
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
button2.Enabled = false;
numericUpDown1.Enabled = false;
numericUpDown2.Enabled = false;
button1.Enabled = true;
ndhour.Enabled = true;
ndminute.Enabled = true;
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
button1.Enabled = false;
ndhour.Enabled = false;
ndminute.Enabled = false;
button2.Enabled = true;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
}
}
private System.DateTime dtDes;
private System.DateTime dtDes2;
private void timer1_Tick(object sender, System.EventArgs e)
{
if(DateTime.Now>dtDes)
{
timer1.Enabled=false;
// this.Show();
// this.textBox1.Text = "该吃饭了";
// this.Activate();
MessageBox.Show("不要玩了,时间到了,吃饭去吧", "吃饭喽");
}
}
private void button1_Click(object sender, EventArgs e)
{
timer2.Enabled = false;//屏蔽定时器2
dtDes = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, (int)ndhour.Value, (int)ndminute.Value, 0, 0);
timer1.Enabled = true;
this.Hide();
}
private void timer2_Tick(object sender, System.EventArgs e)
{
if (DateTime.Now > dtDes2)
{
timer2.Enabled = false;
// this.Show();
// this.textBox1.Text = "该吃饭了";
// this.Activate();
MessageBox.Show("不要玩了,时间到了,吃饭去吧", "吃饭喽");
}
}
private void button2_Click(object sender, EventArgs e)
{/***/
int minute_tmp = (int)numericUpDown1.Value DateTime.Today.Minute;
int sec_tmp = (int)numericUpDown2.Value DateTime.Today.Second;
timer1.Enabled = false;
dtDes2 = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Today.Hour, minute_tmp, sec_tmp, 0);
timer2.Enabled = true;
this.Hide();
}
}
}