TODO int overflow fix
This commit is contained in:
@@ -14,7 +14,6 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
DateTime start = new DateTime();
|
||||
DateTime stop = new DateTime();
|
||||
TimeSpan duration = new TimeSpan();
|
||||
TimeSpan currSpan = new TimeSpan();
|
||||
public Form1()
|
||||
{
|
||||
@@ -31,29 +30,37 @@ namespace WindowsFormsApp1
|
||||
start = DateTime.Now;
|
||||
timer1.Enabled = true;
|
||||
button1.Enabled = false;
|
||||
|
||||
timer2.Start();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
stop = DateTime.Now;
|
||||
duration = stop - start;
|
||||
|
||||
|
||||
timer1.Enabled = false;
|
||||
button1.Enabled = true;
|
||||
|
||||
timer2.Stop();
|
||||
|
||||
//Data.lasttime = currSpan.ToString();
|
||||
Data.data.Add(currSpan.ToString());
|
||||
label2.Text = "";
|
||||
|
||||
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)
|
||||
{
|
||||
label2.Text += $"{item}\n";
|
||||
label1.Text += $"{item}\n";
|
||||
}
|
||||
//label2.Text = Data.lasttime;
|
||||
|
||||
}
|
||||
|
||||
private void label1_Click(object sender, EventArgs e)
|
||||
@@ -62,26 +69,22 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
textBox1.Text = DateTime.Now.ToString("HH:mm:ss:fff");
|
||||
}
|
||||
|
||||
private void textBox2_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void timer2_Tick(object sender, EventArgs e)
|
||||
{
|
||||
currSpan = DateTime.Now - start;
|
||||
textBox2.Text = currSpan.ToString();
|
||||
textBox1.Text = currSpan.ToString();
|
||||
}
|
||||
|
||||
public void InitTimer()
|
||||
{
|
||||
timer1 = new Timer();
|
||||
timer1.Tick += new EventHandler(timer2_Tick);
|
||||
timer1.Interval = 10; // in miliseconds
|
||||
timer1.Interval = 1; // in miliseconds
|
||||
|
||||
}
|
||||
|
||||
@@ -92,8 +95,6 @@ namespace WindowsFormsApp1
|
||||
|
||||
public static class Data
|
||||
{
|
||||
public static string lasttime = "";
|
||||
|
||||
public static List<string> data = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user