In my program I need to change the available controls based on what the user does, so I have three different things to determine control visibility and play event.
for the play event here is a sample of what happens when a user clicks on play:
I can't figure out how to handle this with a case statement unless I define each state individually, and if I was how would I? Is there some better way?Code:Private Sub BtnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPlay.Click, StationsList.DoubleClick, FavoritesList.DoubleClick If My.Settings.ShowFavorites = True Then If My.Settings.PlayType = True Then If (Player1.playState = WMPPlayState.wmppsPlaying) Then If Player1.currentMedia.sourceURL = FavoritesList.CurrentRow.Cells(1).Value Then Player1.Ctlcontrols.pause() Else Player1.URL = FavoritesList.CurrentRow.Cells(1).Value End If Else Player1.URL = FavoritesList.CurrentRow.Cells(1).Value End If Else If (Player1.playState = WMPPlayState.wmppsPlaying) Then Player1.Ctlcontrols.pause() Else Player1.Ctlcontrols.play() End If End If Else End If If My.Settings.PlayType = True Then If (Player1.playState = WMPPlayState.wmppsPlaying) Then If Player1.currentMedia.sourceURL = StationsList.CurrentRow.Cells(1).Value Then Player1.Ctlcontrols.pause() Else Player1.URL = StationsList.CurrentRow.Cells(1).Value End If Else Player1.URL = StationsList.CurrentRow.Cells(1).Value End If Else If (Player1.playState = WMPPlayState.wmppsPlaying) Then Player1.Ctlcontrols.pause() Else Player1.Ctlcontrols.play() End If End If End Sub
Trying to read this code is very hard and it looks a little like spaghetti code. Maybe Fettucini code.




Reply With Quote