102 lines
2.3 KiB
C#
102 lines
2.3 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 WindowsFormsApp1
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
DateTime start = new DateTime();
|
|
DateTime stop = new DateTime();
|
|
TimeSpan currSpan = new TimeSpan();
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
InitTimer();
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
timer1.Enabled = false;
|
|
button1.Enabled = true;
|
|
|
|
|
|
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 = "";
|
|
foreach (var item in Data.data)
|
|
{
|
|
label1.Text += $"{item}\n";
|
|
}
|
|
|
|
}
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
currSpan = DateTime.Now - start;
|
|
textBox1.Text = currSpan.ToString();
|
|
}
|
|
|
|
public void InitTimer()
|
|
{
|
|
timer1 = new Timer();
|
|
timer1.Tick += new EventHandler(timer2_Tick);
|
|
timer1.Interval = 1; // in miliseconds
|
|
|
|
}
|
|
|
|
private void label2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
public static class Data
|
|
{
|
|
public static List<string> data = new List<string>();
|
|
}
|
|
}
|
|
}
|