public partial class form1 : form { stopwatch s = new stopwatch(); public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { } private void button1_click(object sender, eventargs e) { if (button1.text == "start") { button1.text = "stop"; button2.text = "caputre"; s.start(); } else if (button1.text == "stop") { button1.text = "start"; button2.text = "reset"; s.stop(); } } private void button2_click(object sender, eventargs e) { if (s.isrunning == true) { button2.text = "cap"; label1.text = label2.text;
}
} else { s.reset(); label2.text = s.elapsed.tostring(); }
private void timer1_tick(object sender, eventargs e) { if (s.isrunning == true) { label2.text = s.elapsed.tostring(); } }