Archived
1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SomeLab/CS/lab15/15_4/Form1.cs
2026-03-19 19:39:01 +08:00

59 lines
1.4 KiB
C#

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 _15_4
{
public partial class Form1 : Form
{
long ticks = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "开始")
{
button1.Text = "暂停";
timer1.Start();
}
else
{
button1.Text = "开始";
timer1.Stop();
}
}
private void button2_Click(object sender, EventArgs e)
{
button1.Text = "开始";
timer1.Stop();
Timer.Text = "00:00:00:00";
}
private void timer1_Tick(object sender, EventArgs e)
{
ticks++;
long hours = ticks / 360000;
long minutes = (ticks - hours * 360000) / 6000;
long seconds = (ticks - hours * 360000 - minutes * 6000) / 100;
long ms = ticks - hours * 360000 - minutes * 6000 - seconds * 100;
Timer.Text = string.Format("{0:00}:{1:00}:{2:00}:{3:00}",hours,minutes,seconds,ms);
}
private void Form1_Load(object sender, EventArgs e)
{
ticks = 0;
}
}
}