I am trying to program a disco light machine in VB.Net. I have four ellipses on a WPF, and I want them to "light up" (=change the fill from white to some color), then wait for 0.5s, then change the fill back to white - all according to a pre-written sequence.
I am trying to use DispatherTimer but I don't actually know how to make it work. The ellipses are name pad0, pad1, etc...
Public Sub timer()
Dim t As New System.Windows.Threading.DispatcherTimer()
AddHandler t.Tick, AddressOf dispatcherTimer_Tick
t.Interval = New TimeSpan(0, 0, 1)
End Sub
Private Sub dispatcherTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub play_Click(sender As Object, e As RoutedEventArgs) Handles play.Click
Dim sequence = New Integer() {1, 0, 3, 2}
For i As Integer = 0 To 3
Select Case sequence(i)
Case 0
pad0.Fill = Brushes.Blue
**this is where I want the timer to run!**
padOff(pad0)
Case 1
pad1.Fill = Brushes.Yellow
**this is where I want the timer to run!**
padOff(pad1)
Case 2
pad2.Fill = Brushes.Green
**this is where I want the timer to run!**
padOff(pad2)
Case 3
pad3.Fill = Brushes.Red
**this is where I want the timer to run!**
padOff(pad3)
End Select
Next
End Sub
Public Sub padOff(ByVal pad As Shape)
pad.Fill = Brushes.White
End Sub