我有一個非常簡單的倒計時計時器。我希望標籤的顏色(數字)隨着計時器滴答而改變。我想從綠色開始,然後在計時器滴答00:00時淡入(過渡)到紅色。將標籤的顏色從1降到另一個
計時器工作的很好,一旦計時器打到00:00,我也可以得到標籤變成紅色。我希望它漸漸消失。這是代碼的一部分。
'handles the label ticking down'
Private Sub tmrCountdown_Tick(sender As Object, e As EventArgs) Handles tmrCountdown.Tick
Dim ts As TimeSpan = TargetDT.Subtract(DateTime.Now)
If ts.Milliseconds > 0 Then
lblTime.Text = ts.ToString("mm\:ss")
lblTime.ForeColor = Color.FromArgb(0, 255, 0)
Else
lblTime.ForeColor = Color.FromArgb(255, 0, 0) 'changes label color to red when it hits 00:00'
'stops the timer once the label reaches 00:00
lblTime.Text = "00:00"
'Plays sound when timer hits 00:00'
My.Computer.Audio.Play(My.Resources.alarm, AudioPlayMode.BackgroundLoop)
tmrCountdown.Stop()
End If
End Sub
淡入你的意思是一個梯度?只需定義其值轉換爲紅色/黃色/綠色的「波段」還有一些中間顏色不直觀。 – Plutonix 2014-09-03 20:44:21
淡入淡出我的意思是,它從一種顏色開始,轉換到另一種顏色。所以它從純綠色變爲純紅色。 – MrGerrm 2014-09-03 20:51:25
那麼,只要減少綠色值,並增加顏色製造商使用的紅色值,因爲時間在0上關閉,即所謂的漸變。 – Plutonix 2014-09-03 20:54:02