ProgaOra/20240311/WindowsFormsApp1/Form1.cs

101 lines
2.3 KiB
C#
Raw Normal View History

2024-03-11 09:54:11 +00:00
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 WindowsFormsApp1
{
public partial class Form1 : Form
{
DateTime start = new DateTime();
DateTime stop = new DateTime();
TimeSpan duration = new TimeSpan();
2024-03-13 11:08:11 +00:00
TimeSpan currSpan = new TimeSpan();
2024-03-11 09:54:11 +00:00
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
2024-03-13 11:08:11 +00:00
InitTimer();
2024-03-11 09:54:11 +00:00
}
private void button1_Click(object sender, EventArgs e)
{
start = DateTime.Now;
timer1.Enabled = true;
button1.Enabled = false;
2024-03-13 11:08:11 +00:00
timer2.Start();
2024-03-11 09:54:11 +00:00
}
private void button2_Click(object sender, EventArgs e)
{
stop = DateTime.Now;
duration = stop - start;
2024-03-17 18:54:30 +00:00
2024-03-11 09:54:11 +00:00
timer1.Enabled = false;
button1.Enabled = true;
2024-03-13 11:08:11 +00:00
timer2.Stop();
2024-03-17 18:54:30 +00:00
//Data.lasttime = currSpan.ToString();
Data.data.Add(currSpan.ToString());
2024-03-13 11:08:11 +00:00
label2.Text = "";
2024-03-17 18:54:30 +00:00
foreach (var item in Data.data)
2024-03-13 11:08:11 +00:00
{
2024-03-17 18:54:30 +00:00
label2.Text += $"{item}\n";
2024-03-13 11:08:11 +00:00
}
2024-03-17 18:54:30 +00:00
//label2.Text = Data.lasttime;
2024-03-11 09:54:11 +00:00
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.Text = DateTime.Now.ToString("HH:mm:ss:fff");
}
2024-03-13 11:08:11 +00:00
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
currSpan = DateTime.Now - start;
textBox2.Text = currSpan.ToString();
}
public void InitTimer()
{
timer1 = new Timer();
timer1.Tick += new EventHandler(timer2_Tick);
timer1.Interval = 10; // in miliseconds
}
private void label2_Click(object sender, EventArgs e)
{
}
2024-03-17 18:54:30 +00:00
public static class Data
{
public static string lasttime = "";
public static List<string> data = new List<string>();
}
2024-03-11 09:54:11 +00:00
}
}