写好了,楼主自己慢慢看吧!只实现了时间的功能 暂停这些都未实现- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Threading;
- namespace WindowsFormsApplication
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- TextBox.CheckForIllegalCrossThreadCalls = false;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Thread tr = new Thread(AddTime);
- tr.IsBackground = true;
- tr.Start();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- DateTime dt = DateTime.Now;
- textBox1.Text = dt.Hour.ToString();
- textBox2.Text = dt.Minute.ToString();
- textBox3.Text = dt.Second.ToString();
- }
- private void AddTime()
- {
- while (true)
- {
- TimeSpan ts = new TimeSpan(0, 0, 1);
- textBox3.Text = (int.Parse(textBox3.Text) + 1).ToString();
- if (textBox3.Text == "60")
- {
- textBox2.Text = (int.Parse(textBox2.Text) + 1).ToString();
- if (textBox2.Text == "60")
- {
- textBox1.Text = (int.Parse(textBox1.Text) + 1).ToString();
- if (textBox1.Text == "24")
- {
- textBox1.Text = "0";
- textBox2.Text = "0";
- textBox3.Text = "0";
- }
- }
- }
- Thread.Sleep(ts);
- }
- }
-
- }
- }
复制代码
|