I have a button which you have to click and it measures the reactiontime. In the 2 player mode ( 15 clicks for the player 10 and 15 clicks for player 2). The time I give out in two labels. But why is the text of the labelSummary2 the text of the other label? ( I want to get the reactiontimes in both labels so I'm able to compare them...)
public Form1()
{
InitializeComponent();
_Stopwatch = new Stopwatch();
_Stopwatch2 = new Stopwatch();
_ReactionTimes = new List<TimeSpan>();
_ReactionTimes2 = new List<TimeSpan>();
}
private void txbStart_MouseClick(object sender, MouseEventArgs e)
{
if (Spielzuege2 >= 16)
{
_Stopwatch2.Reset();
_Stopwatch2.Start();
}
else
{
_Stopwatch.Reset();
_Stopwatch.Start();
}
}
private void btnRot_Click(object sender, EventArgs e)
{
if (Spielzuege2 >= 16)
{
_Stopwatch2.Stop();
_ReactionTimes2.Add(_Stopwatch2.Elapsed);
labelSummary2.Text = String.Format("Player 2: Current: {0:0.000} s Minimum: {1:0.000} s Maximum: {2:0.000} s", _ReactionTimes.Last().TotalSeconds, _ReactionTimes.Min().TotalSeconds, _ReactionTimes.Max().TotalSeconds);
}
else
{
_Stopwatch.Stop();
_ReactionTimes.Add(_Stopwatch.Elapsed);
labelSummary.Text = String.Format("Player 1: Current: {0:0.000} s Minimum: {1:0.000} s Maximum: {2:0.000} s", _ReactionTimes.Last().TotalSeconds, _ReactionTimes.Min().TotalSeconds, _ReactionTimes.Max().TotalSeconds);
}
}
Replace following code for your button click event :
private void btnRot_Click(object sender, EventArgs e)
{
if (Spielzuege2 >= 16)
{
_Stopwatch2.Stop();
_ReactionTimes2.Add(_Stopwatch2.Elapsed);
labelSummary2.Text = String.Format("Player 2: Current: {0:0.000} s Minimum: {1:0.000} s Maximum: {2:0.000} s", _ReactionTimes2.Last().TotalSeconds, _ReactionTimes2.Min().TotalSeconds, _ReactionTimes2.Max().TotalSeconds);
}
else
{
_Stopwatch.Stop();
_ReactionTimes.Add(_Stopwatch.Elapsed);
labelSummary.Text = String.Format("Player 1: Current: {0:0.000} s Minimum: {1:0.000} s Maximum: {2:0.000} s", _ReactionTimes.Last().TotalSeconds, _ReactionTimes.Min().TotalSeconds, _ReactionTimes.Max().TotalSeconds);
}
}