A
Austin Althouse
Guest
Hello,
I am stumped on an issue and I can't figure out why it is doing this. My application uses a tab control, which automatically switches to the next tab control at the set interval. When the appropriate slide is showing, it reads the appropriate line of text. However, it recently and randomly started repeating the last tabpage's and then saying the current tappage instead of just saying the current tabpage. I do not have it coded to do this and it randomly started doing this.
Here is my code:
Auto Slideshow of Tabpages:
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
Dim g As Graphics = e.Graphics
Dim _TextBrush As Brush
' Get the item from the collection.
Dim _TabPage As TabPage = TabControl1.TabPages(e.Index)
' Get the real bounds for the tab rectangle.
Dim _TabBounds As Rectangle = TabControl1.GetTabRect(e.Index)
If (e.State = DrawItemState.Selected) Then
' Draw a different background color, and don't paint a focus rectangle.
_TextBrush = New SolidBrush(Color.Red)
g.FillRectangle(Brushes.Gray, e.Bounds)
Else
_TextBrush = New System.Drawing.SolidBrush(e.ForeColor)
e.DrawBackground()
End If
' Use our own font.
Dim _TabFont As New Font("Arial", 10.0, FontStyle.Bold, GraphicsUnit.Pixel)
' Draw string. Center the text.
Dim _StringFlags As New StringFormat()
_StringFlags.Alignment = StringAlignment.Center
_StringFlags.LineAlignment = StringAlignment.Center
g.DrawString(_TabPage.Text, _TabFont, _TextBrush, _TabBounds, New StringFormat(_StringFlags))
End Sub
Private Sub LFI_Panel_Timer_Tick(sender As Object, e As EventArgs) Handles LFI_Panel_Timer.Tick
If TabControl1.SelectedIndex < TabControl1.TabCount - 1 Then
TabControl1.SelectedIndex = TabControl1.SelectedIndex + 1
Else
'Go to the first tab
TabControl1.SelectedIndex = 0
End If
Narration Code:
Private Sub TabPage1_Enter(sender As Object, e As EventArgs) Handles TabPage1.Enter
Task.Run(AddressOf CurrentConditionsVoice)
End Sub
'THE ABOVE IS DONE FOR EACH TAB PAGE ONLY THE ADDRESSOF IS DIFFERENT.
Private Sub CurrentConditionsVoice()
My.Settings.RaiseAudio = "0"
speaker.Volume = 100
Delay(0)
If My.Settings.speaking = "Yes" Then
speaker.Volume = 20
ElseIf My.Settings.speaking = "No" Then
speaker.Volume = 100
End If
speaker.Rate = 1
speaker.SpeakAsync("Currently in your area")
speaker.SpeakAsync(Label43.Text)
Dim a As String = Label44.Text
Select Case True
'Thunderstorm Group
Case a = ("Thunderstorms") : speaker.Speak("With a thunderstorm.")
Case a = ("Thunderstorms and Rain") : speaker.Speak("With a thunderstorm.")
Case a = ("Heavy Thunderstorm") : speaker.Speak("With a heavy thunderstorm.")
Case a = ("Thunderstorm In The Vicinity") : speaker.Speak("With a thunderstorm in the vicinity.")
Case a = ("Thunderstorm Heavy Rain Fog and Breezy") : speaker.Speak("With a thunderstorm with foggy and breezy conditions.")
'Drizzle Group
Case a = ("Drizzle") : speaker.Speak("With drizzle.")
Case a = ("Shower") : speaker.Speak("With a showers.")
'Rain Group
Case a = ("Light Rain") : speaker.Speak("With light rain.")
Case a = ("Light Rain") : speaker.Speak("With light rain and some fog.")
Case a = ("Heavy Rain") : speaker.Speak("With heavy rain.")
Case a = ("Freezing Rain") : speaker.Speak("With freezing rain.")
'Snow Group
Case a = ("Light Snow") : speaker.Speak("With light snow.")
Case a = ("Light Snow and Fog/Mist") : speaker.Speak("With light snow and some fog.")
Case a = ("Snow") : speaker.Speak("With snow.")
Case a = ("Heavy Snow") : speaker.Speak("With heavy snow.")
Case a = ("Sleet") : speaker.Speak("With sleet.")
Case a = ("Wintery Mix") : speaker.Speak("With a mix of wintery preciptation.")
Case a = ("Flurries") : speaker.Speak("With flurries.")
'Atmosphere Group
Case a = ("Mist") : speaker.Speak("With mist.")
Case a = ("Smoke") : speaker.Speak("With smoky conditions.")
Case a = ("Haze") : speaker.Speak("With haze.")
Case a = ("sand, dust whirls") : speaker.Speak("With sand and dust whrils.")
Case a = ("Fog") : speaker.Speak("With foggy conditions.")
Case a = ("Fog/Mist") : speaker.Speak("with foggy conditions.")
Case a = ("sand") : speaker.Speak("With sandy conditions.")
Case a = ("dust") : speaker.Speak("With dusty conditions.")
Case a = ("volcanic ash") : speaker.Speak("With volcanic ash.")
Case a = ("squalls") : speaker.Speak("With squalls.")
Case a = ("tornado") : speaker.Speak("With a tornado.")
'Clear Group
Case a = ("Clear") : speaker.SpeakAsync("Under clear skies.")
Case a = ("Mostly Clear") : speaker.Speak("Under Mostly Clear skies.")
'Clouds Group
Case a = ("Partly Cloudy") : speaker.Speak("Under Partly Cloudy skies.")
Case a = ("Mostly Cloudy") : speaker.Speak("Under Mostly Cloudy skies.")
Case a = ("Cloudy") : speaker.Speak("Under Cloudy skies.")
'Windy Group
Case a = ("Partly Cloudy and Windy") : speaker.Speak("Under Partly Cloudy skies with windy conditions.")
Case a = ("Mostly Cloudy and Windy") : speaker.Speak("Under Mostly Cloudy skies with windy conditions.")
Case a = ("Cloudy and Windy") : speaker.Speak("Under Cloudy skies with windy conditions.")
Case a = ("Clear and Windy") : speaker.Speak("Under clear skies with windy conditions.")
Case a = ("Windy") : speaker.Speak("with windy conditions.")
Case a = ("Mostly Clear and Windy") : speaker.Speak("Under Mostly Clear skies with windy conditions.")
'Breezy Group
Case a = ("Clear and Breezy") : speaker.Speak("Under clear skies with breezy conditions.")
Case a = ("Overcast and Breezy") : speaker.Speak("With overcast skies and breezy conditions.")
Case a = ("Partly Cloudy and Breezy") : speaker.Speak("Under Partly Cloudy skies with breezy conditions.")
Case a = ("Mostly Cloudy and Breezy") : speaker.Speak("Under Mostly Cloudy skies with breezy conditions.")
Case a = ("Cloudy and Breezy") : speaker.Speak("Under Cloudy skies with breezy conditions.")
End Select
My.Settings.RaiseAudio = "1"
End Sub
'THE RAISE AUDIO IS FOR THE BUILD IN WINDOWS MEDIA PLAYER TO LOWER THE MUSIC VOLUME SO THE SPEECH CAN BE HEARD.
The above code has worked flawlessly. This issue started after I forgot to plugin my speakers or headset and it caused the program to give an AudioException because it couldn't find an audio output. What is going on with the application and how can I fix it?
Continue reading...
I am stumped on an issue and I can't figure out why it is doing this. My application uses a tab control, which automatically switches to the next tab control at the set interval. When the appropriate slide is showing, it reads the appropriate line of text. However, it recently and randomly started repeating the last tabpage's and then saying the current tappage instead of just saying the current tabpage. I do not have it coded to do this and it randomly started doing this.
Here is my code:
Auto Slideshow of Tabpages:
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
Dim g As Graphics = e.Graphics
Dim _TextBrush As Brush
' Get the item from the collection.
Dim _TabPage As TabPage = TabControl1.TabPages(e.Index)
' Get the real bounds for the tab rectangle.
Dim _TabBounds As Rectangle = TabControl1.GetTabRect(e.Index)
If (e.State = DrawItemState.Selected) Then
' Draw a different background color, and don't paint a focus rectangle.
_TextBrush = New SolidBrush(Color.Red)
g.FillRectangle(Brushes.Gray, e.Bounds)
Else
_TextBrush = New System.Drawing.SolidBrush(e.ForeColor)
e.DrawBackground()
End If
' Use our own font.
Dim _TabFont As New Font("Arial", 10.0, FontStyle.Bold, GraphicsUnit.Pixel)
' Draw string. Center the text.
Dim _StringFlags As New StringFormat()
_StringFlags.Alignment = StringAlignment.Center
_StringFlags.LineAlignment = StringAlignment.Center
g.DrawString(_TabPage.Text, _TabFont, _TextBrush, _TabBounds, New StringFormat(_StringFlags))
End Sub
Private Sub LFI_Panel_Timer_Tick(sender As Object, e As EventArgs) Handles LFI_Panel_Timer.Tick
If TabControl1.SelectedIndex < TabControl1.TabCount - 1 Then
TabControl1.SelectedIndex = TabControl1.SelectedIndex + 1
Else
'Go to the first tab
TabControl1.SelectedIndex = 0
End If
Narration Code:
Private Sub TabPage1_Enter(sender As Object, e As EventArgs) Handles TabPage1.Enter
Task.Run(AddressOf CurrentConditionsVoice)
End Sub
'THE ABOVE IS DONE FOR EACH TAB PAGE ONLY THE ADDRESSOF IS DIFFERENT.
Private Sub CurrentConditionsVoice()
My.Settings.RaiseAudio = "0"
speaker.Volume = 100
Delay(0)
If My.Settings.speaking = "Yes" Then
speaker.Volume = 20
ElseIf My.Settings.speaking = "No" Then
speaker.Volume = 100
End If
speaker.Rate = 1
speaker.SpeakAsync("Currently in your area")
speaker.SpeakAsync(Label43.Text)
Dim a As String = Label44.Text
Select Case True
'Thunderstorm Group
Case a = ("Thunderstorms") : speaker.Speak("With a thunderstorm.")
Case a = ("Thunderstorms and Rain") : speaker.Speak("With a thunderstorm.")
Case a = ("Heavy Thunderstorm") : speaker.Speak("With a heavy thunderstorm.")
Case a = ("Thunderstorm In The Vicinity") : speaker.Speak("With a thunderstorm in the vicinity.")
Case a = ("Thunderstorm Heavy Rain Fog and Breezy") : speaker.Speak("With a thunderstorm with foggy and breezy conditions.")
'Drizzle Group
Case a = ("Drizzle") : speaker.Speak("With drizzle.")
Case a = ("Shower") : speaker.Speak("With a showers.")
'Rain Group
Case a = ("Light Rain") : speaker.Speak("With light rain.")
Case a = ("Light Rain") : speaker.Speak("With light rain and some fog.")
Case a = ("Heavy Rain") : speaker.Speak("With heavy rain.")
Case a = ("Freezing Rain") : speaker.Speak("With freezing rain.")
'Snow Group
Case a = ("Light Snow") : speaker.Speak("With light snow.")
Case a = ("Light Snow and Fog/Mist") : speaker.Speak("With light snow and some fog.")
Case a = ("Snow") : speaker.Speak("With snow.")
Case a = ("Heavy Snow") : speaker.Speak("With heavy snow.")
Case a = ("Sleet") : speaker.Speak("With sleet.")
Case a = ("Wintery Mix") : speaker.Speak("With a mix of wintery preciptation.")
Case a = ("Flurries") : speaker.Speak("With flurries.")
'Atmosphere Group
Case a = ("Mist") : speaker.Speak("With mist.")
Case a = ("Smoke") : speaker.Speak("With smoky conditions.")
Case a = ("Haze") : speaker.Speak("With haze.")
Case a = ("sand, dust whirls") : speaker.Speak("With sand and dust whrils.")
Case a = ("Fog") : speaker.Speak("With foggy conditions.")
Case a = ("Fog/Mist") : speaker.Speak("with foggy conditions.")
Case a = ("sand") : speaker.Speak("With sandy conditions.")
Case a = ("dust") : speaker.Speak("With dusty conditions.")
Case a = ("volcanic ash") : speaker.Speak("With volcanic ash.")
Case a = ("squalls") : speaker.Speak("With squalls.")
Case a = ("tornado") : speaker.Speak("With a tornado.")
'Clear Group
Case a = ("Clear") : speaker.SpeakAsync("Under clear skies.")
Case a = ("Mostly Clear") : speaker.Speak("Under Mostly Clear skies.")
'Clouds Group
Case a = ("Partly Cloudy") : speaker.Speak("Under Partly Cloudy skies.")
Case a = ("Mostly Cloudy") : speaker.Speak("Under Mostly Cloudy skies.")
Case a = ("Cloudy") : speaker.Speak("Under Cloudy skies.")
'Windy Group
Case a = ("Partly Cloudy and Windy") : speaker.Speak("Under Partly Cloudy skies with windy conditions.")
Case a = ("Mostly Cloudy and Windy") : speaker.Speak("Under Mostly Cloudy skies with windy conditions.")
Case a = ("Cloudy and Windy") : speaker.Speak("Under Cloudy skies with windy conditions.")
Case a = ("Clear and Windy") : speaker.Speak("Under clear skies with windy conditions.")
Case a = ("Windy") : speaker.Speak("with windy conditions.")
Case a = ("Mostly Clear and Windy") : speaker.Speak("Under Mostly Clear skies with windy conditions.")
'Breezy Group
Case a = ("Clear and Breezy") : speaker.Speak("Under clear skies with breezy conditions.")
Case a = ("Overcast and Breezy") : speaker.Speak("With overcast skies and breezy conditions.")
Case a = ("Partly Cloudy and Breezy") : speaker.Speak("Under Partly Cloudy skies with breezy conditions.")
Case a = ("Mostly Cloudy and Breezy") : speaker.Speak("Under Mostly Cloudy skies with breezy conditions.")
Case a = ("Cloudy and Breezy") : speaker.Speak("Under Cloudy skies with breezy conditions.")
End Select
My.Settings.RaiseAudio = "1"
End Sub
'THE RAISE AUDIO IS FOR THE BUILD IN WINDOWS MEDIA PLAYER TO LOWER THE MUSIC VOLUME SO THE SPEECH CAN BE HEARD.
The above code has worked flawlessly. This issue started after I forgot to plugin my speakers or headset and it caused the program to give an AudioException because it couldn't find an audio output. What is going on with the application and how can I fix it?
Continue reading...