TODO int overflow fix

This commit is contained in:
szabomarton
2024-03-18 11:19:12 +01:00
parent a6d8fda3ac
commit ae34a5b001
42 changed files with 853 additions and 60 deletions

View File

@@ -32,12 +32,10 @@ namespace WindowsFormsApp1
this.components = new System.ComponentModel.Container();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
@@ -60,15 +58,6 @@ namespace WindowsFormsApp1
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(181, 81);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 13);
this.label1.TabIndex = 2;
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// timer1
//
this.timer1.Enabled = true;
@@ -77,46 +66,40 @@ namespace WindowsFormsApp1
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 106);
this.textBox1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.textBox1.Location = new System.Drawing.Point(115, 147);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 3;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
this.textBox1.Size = new System.Drawing.Size(135, 26);
this.textBox1.TabIndex = 4;
//
// textBox2
// label1
//
this.textBox2.Location = new System.Drawing.Point(128, 147);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 4;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F);
this.label1.ForeColor = System.Drawing.Color.Yellow;
this.label1.Location = new System.Drawing.Point(128, 190);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 26);
this.label1.TabIndex = 5;
this.label1.Click += new System.EventHandler(this.label2_Click);
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(128, 190);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 13);
this.label2.TabIndex = 5;
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Navy;
this.ClientSize = new System.Drawing.Size(362, 450);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
this.Name = "Form1";
this.Text = "Form1";
this.Text = "Stopper";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
@@ -127,12 +110,10 @@ namespace WindowsFormsApp1
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Label label2;
}
}

View File

@@ -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>();
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@@ -1 +1 @@
ffeb981a72357c13c78580d1de8dfcfdeab69b3831ebd504970e578b1a834c6f
8069502011d0681850e57a53d5a1673222f430a6

View File

@@ -2,7 +2,6 @@ C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\bin\Debug\WindowsForms
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.AssemblyReference.cache
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Form1.resources
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Properties.Resources.resources
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.GenerateResource.cache
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache
@@ -28,3 +27,4 @@ E:\Házi\Programozás\C#\Suli\ProgaOra\20240311\WindowsFormsApp1\obj\Debug\Windo
E:\Házi\Programozás\C#\Suli\ProgaOra\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache
E:\Házi\Programozás\C#\Suli\ProgaOra\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe
E:\Házi\Programozás\C#\Suli\ProgaOra\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.pdb
C:\Users\szabomarton\Desktop\C#\20240311\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Form1.resources