당신은 클릭 수를 계산하는 Button1을 다시 사용할 수 있지만 코드 주위에 보호하려는 경우 당신이 추가 할 수있는 새로운 타이머를 시작하고 싶었다면에 라벨 이름을 바꿉니다.
bool hasTimerStarted = false;
int numberOfClicks = 0;
private void button1_Click(object sender, EventArgs e)
{
if(!hasTimerStarted)
{
button1.Enabled = true;
timer1.Start();
hasTimerStarted = true;
}
++numberOfClicks;
}
타이머가 만료되면 카운트를 재설정하고 타이머가 시작되었습니다.
private void timer1_Tick(object sender, EventArgs e)
{
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds/10);
label3.Text = elapsedTime;
labelClicks.Text = "User clicked " + clicksNo.toString() + "nt times..";
if (stopWatch.ElapsedMilliseconds >= this.minutes * 60 * 1000)
{
timer1.Stop();
MessageBox.Show("Time elapsed.");
hasTimerStarted = false;
numberOfClicks = 0;
}
}
클릭 수? – Grzenio
그리고 문제의 세부 사항은 ...? –
특정 버튼이나 앱 또는 OS에서 클릭을 추적하려면 여기에 추가하십시오. –