2013-11-01 32 views
0

我有一個按鈕,您必須點擊它才能測量反應時間。在2人模式下(15人點擊10人,15人點擊2人)。我給出了兩個標籤的時間。但爲什麼labelSummary2的文本是另一個標籤的文本? (我想獲得reactiontimes在這兩個標籤,使我能夠對它們進行比較......)秒錶標籤輸出

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

回答

0

替換以下爲您的按鈕點擊事件代碼:

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); 
    } 
} 
1

您正在使用_ReactionTimes列表,以填補這兩個標籤,而不是使用_ReactionTimes2labelSummary2

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);