我有NumericUpDown1中,當我設置它它保存在選項的文本文件中的值值:如何在幾秒鐘內將計時器從倒計時轉換回數分鐘計時?
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
Options_DB.Set_Radar_Images_Time(numericUpDown1.Value);
}
定時器1區間設定在Form1設計到1000毫秒。
在定時器1 Tick事件,我有:
private void timer1_Tick(object sender, EventArgs e)
{
numbers_radar = Convert.ToInt64(numericUpDown1.Value);
}
現在我要指派的計時器滴答事件:label21.Text並顯示分鐘倒計時。 如果我將numericUpDown1設置爲10,那麼它會倒數10分鐘。
格式應該是:minutes:seconds(00:00)。
而且每次計時器達到1時,都應調用此方法:fileDownloadRadar(); 每次達到1時,計時器應重置爲numericUpDown1值並重新開始計算,最後每次調用方法fileDownloadRadar();
的NumericUpDown1中被設置爲最小值5和最大值60
編輯
現在,我想這個代碼,但我沒有看到任何label21改變啓動定時器時。 分鐘從0開始,但在這種情況下應該是29(numericUpDown1的值)。
我應該檢查分鐘和秒== 1或== 0嗎?什麼是邏輯1或0?
private void timer1_Tick(object sender, EventArgs e)
{
numOfMinutes = Convert.ToInt32(numericUpDown1.Value);
int seconds = numOfMinutes % 60;
int minutes = numOfMinutes/60;
seconds --;
string time = minutes + ":" + seconds;
label21.Text = time;
if (seconds == 1)
{
minutes --;
}
if (minutes == 1 && seconds == 1)
{
numOfMinutes = Convert.ToInt32(numericUpDown1.Value);
fileDownloadRadar();
}
}