помогите создать светофор с таймером
не получается создать сфетофор ,не разберусь как использовать таймер помогите пожалуйсто
Код:
Public Class Form4
Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
TimerModeLight.Enabled = True
End Sub
Private Sub TimerModeLight_Tick(sender As System.Object, e As System.EventArgs) Handles TimerModeLight.Tick
Static blnTam As Boolean = False
Static bytCiklRepetition As Byte
Static bytCiklRedYellowGreen As Byte
Select Case bytCiklRedYellowGreen
Case 0 '5с горит "Красный"
TimerModeLight.Interval = 5000
OvalGreen.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalRed.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 1
Case 1 '2с горит "Красный и Желтый"
TimerModeLight.Interval = 2000
OvalYellow.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 2
Case 2 '5с горит "Зеленый"
TimerModeLight.Interval = 5000
OvalRed.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalYellow.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalGreen.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 3
Case 3 'через 5с "Зеленый" будет мигать(интервал мигания 1с)
TimerModeLight.Interval = 1000
If blnTam Then
OvalGreen.FillStyle = PowerPacks.FillStyle.Solid
blnTam = False
bytCiklRepetition += 1
'"Зеленый" будет мигать 5 раз
If bytCiklRepetition = 5 Then
bytCiklRepetition = 0
bytCiklRedYellowGreen = 0
blnTam = False
End If
Else
OvalGreen.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
blnTam = True
End If
End Select
End Sub
End Class
Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
TimerModeLight.Enabled = True
End Sub
Private Sub TimerModeLight_Tick(sender As System.Object, e As System.EventArgs) Handles TimerModeLight.Tick
Static blnTam As Boolean = False
Static bytCiklRepetition As Byte
Static bytCiklRedYellowGreen As Byte
Select Case bytCiklRedYellowGreen
Case 0 '5с горит "Красный"
TimerModeLight.Interval = 5000
OvalGreen.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalRed.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 1
Case 1 '2с горит "Красный и Желтый"
TimerModeLight.Interval = 2000
OvalYellow.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 2
Case 2 '5с горит "Зеленый"
TimerModeLight.Interval = 5000
OvalRed.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalYellow.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
OvalGreen.FillStyle = PowerPacks.FillStyle.Solid
bytCiklRedYellowGreen = 3
Case 3 'через 5с "Зеленый" будет мигать(интервал мигания 1с)
TimerModeLight.Interval = 1000
If blnTam Then
OvalGreen.FillStyle = PowerPacks.FillStyle.Solid
blnTam = False
bytCiklRepetition += 1
'"Зеленый" будет мигать 5 раз
If bytCiklRepetition = 5 Then
bytCiklRepetition = 0
bytCiklRedYellowGreen = 0
blnTam = False
End If
Else
OvalGreen.FillStyle = PowerPacks.FillStyle.OutlineShapedDiamond
blnTam = True
End If
End Select
End Sub
End Class