ProgaOra/20240311/WindowsFormsApp1/Form1.cs

102 lines
2.3 KiB
C#
Raw Permalink 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();
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;
}
private void button2_Click(object sender, EventArgs e)
{
stop = DateTime.Now;
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
2024-03-18 10:19:12 +00:00
string formatted_time = $"{currSpan.ToString("mm")}:{currSpan.ToString("ss")}:{currSpan.ToString("fff")}";
if (Data.data.Count > 0)
{
if (Data.data[Data.data.Count - 1] != formatted_time)
{
Data.data.Add(formatted_time);
}
}
else
{
Data.data.Add(formatted_time);
}
label1.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-18 10:19:12 +00:00
label1.Text += $"{item}\n";
2024-03-13 11:08:11 +00:00
}
2024-03-18 10:19:12 +00:00
2024-03-11 09:54:11 +00:00
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
2024-03-13 11:08:11 +00:00
{
}
2024-03-18 10:19:12 +00:00
2024-03-13 11:08:11 +00:00
private void timer2_Tick(object sender, EventArgs e)
{
currSpan = DateTime.Now - start;
2024-03-18 10:19:12 +00:00
textBox1.Text = currSpan.ToString();
2024-03-13 11:08:11 +00:00
}
public void InitTimer()
{
timer1 = new Timer();
timer1.Tick += new EventHandler(timer2_Tick);
2024-03-18 10:19:12 +00:00
timer1.Interval = 1; // in miliseconds
2024-03-13 11:08:11 +00:00
}
private void label2_Click(object sender, EventArgs e)
{
}
2024-03-17 18:54:30 +00:00
public static class Data
{
public static List<string> data = new List<string>();
}
2024-03-11 09:54:11 +00:00
}
}