📄 mainform.vb
字号:
Settings.DisplayCoverArt = False
mnuDisplayCoverArt.Image = Nothing
End If
End If
' Save settings.
My.Settings.DisplayVisualizations = Settings.DisplayVisualizations
My.Settings.DisplayCoverArt = Settings.DisplayCoverArt
My.Settings.Save()
End Sub
''' <summary>
''' This only affects ToolTip1 and the radiobutton tooltips.
''' Other tooltips are always displayed.
''' </summary>
Private Sub mnuDisplayTooltips_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisplayTooltips.Click
If Settings.ToolTips = True Then
Settings.ToolTips = False
mnuDisplayTooltips.Image = Nothing
ElseIf Settings.ToolTips = False Then
Settings.ToolTips = True
mnuDisplayTooltips.Image = My.Resources.Checked
End If
' Save setting.
My.Settings.ToolTips = Settings.ToolTips
My.Settings.Save()
End Sub
Private Sub mnuStartAsIcon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStartAsIcon.Click
If Settings.StartAsIcon = True Then
Settings.StartAsIcon = False
mnuStartAsIcon.Image = Nothing
ElseIf Settings.StartAsIcon = False Then
Settings.StartAsIcon = True
mnuStartAsIcon.Image = My.Resources.Checked
End If
' Save setting.
My.Settings.StartAsIcon = Settings.StartAsIcon
My.Settings.Save()
End Sub
Private Sub mnuStartWithWindows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStartWithWindows.Click
If Settings.StartWithWindows = True Then
Settings.StartWithWindows = False
StartWindows(False)
mnuStartWithWindows.Image = Nothing
ElseIf Settings.StartWithWindows = False Then
Settings.StartWithWindows = True
StartWindows(True)
mnuStartWithWindows.Image = My.Resources.Checked
End If
' Save setting.
My.Settings.StartWithWindows = Settings.StartWithWindows
My.Settings.Save()
End Sub
Private Sub mnuResetSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuResetSettings.Click
Dim result As DialogResult
result = MessageBox.Show("Are you sure you want to reset all settings, including Station Buttons, to thier default value?", _
My.Application.Info.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If result = Windows.Forms.DialogResult.No Then
Exit Sub
Else
ResetSettings()
End If
End Sub
''' <summary>
''' Centers form in screen bounds, not size.
''' </summary>
Private Sub mnuCenterForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCenterForm.Click
Dim location As Point = GetCenterBounds(Me)
Me.Location = location
Settings.XPosition = location.X
Settings.YPosition = location.Y
My.Settings.XPosition = location.X
My.Settings.YPosition = location.Y
My.Settings.Save()
End Sub
Private Sub mnuDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnect.Click
Disconnect()
End Sub
Private Sub mnuRotateStationInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRotateStationInfo.Click
If Settings.RotateStationInfo = True Then
Settings.RotateStationInfo = False
mnuRotateStationInfo.Image = Nothing
' Enable timer and change interval so change is made.
tmrRotatePictureText.Enabled = True
tmrRotatePictureText.Interval = 5000
ElseIf Settings.RotateStationInfo = False Then
Settings.RotateStationInfo = True
mnuRotateStationInfo.Image = My.Resources.Checked
' Download image.
DownloadImage()
' Enable timer and change interval so change is made.
tmrRotatePictureText.Enabled = True
tmrRotatePictureText.Interval = 5000
End If
' Save setting.
My.Settings.RotateStationInfo = Settings.RotateStationInfo
My.Settings.Save()
End Sub
Private Sub mnuStatistics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuStatistics.Click
' Form can't be topmost when other form is shown.
If Settings.KeepOnTop = True Then
Me.TopMost = False
End If
StatisticsForm.ShowDialog()
' Make form topmost again, if set.
If Settings.KeepOnTop = True Then
Me.TopMost = True
End If
End Sub
Private Sub mnuMediaPlayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMediaPlayer.Click
' Form can't be topmost when other form is shown.
If Settings.KeepOnTop = True Then
Me.TopMost = False
End If
WmpAboutDialog.ShowDialog()
' Make form topmost again, if set.
If Settings.KeepOnTop = True Then
Me.TopMost = True
End If
End Sub
Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
' Form can't be topmost when other form is shown.
If Settings.KeepOnTop = True Then
Me.TopMost = False
End If
' StartPosition is set to manual when displaying AboutDialog from notifyicon menu.
AboutDialog.StartPosition = FormStartPosition.CenterParent
AboutDialog.ShowDialog()
' Make form topmost again, if set.
If Settings.KeepOnTop = True Then
Me.TopMost = True
End If
End Sub
Private Sub mnuMediaPlayerErrorMessages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMediaPlayerErrorMessages.Click
Try
Dim startInfo As New ProcessStartInfo("http://www.microsoft.com/windows/windowsmedia/player/9series/playererrors.aspx")
startInfo.WindowStyle = ProcessWindowStyle.Maximized
Process.Start(startInfo)
Catch ex As Net.WebException
' If error occurs, cancel topmost.
If Me.TopMost = True Then Me.TopMost = False
MessageBox.Show("Unable to open website. The system returned the following information:" & vbCrLf & _
ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub mnuMediaPlayerWebHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMediaPlayerWebHelp.Click
Try
If mWebHelp <> "" Then
Dim startInfo As New ProcessStartInfo(mWebHelp)
startInfo.WindowStyle = ProcessWindowStyle.Maximized
Process.Start(startInfo)
End If
Catch ex As Net.WebException
' If error occurs, cancel topmost.
If Me.TopMost = True Then Me.TopMost = False
MessageBox.Show("Unable to open website. The system returned the following information:" & vbCrLf & _
ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub mnuDownloadPlugIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDownloadPlugIn.Click
' Form can't be topmost when other form is shown.
If Settings.KeepOnTop = True Then
Me.TopMost = False
End If
DownloadPlugInDialog.ShowDialog()
' Make form topmost again, if set.
If Settings.KeepOnTop = True Then
Me.TopMost = True
End If
End Sub
#End Region
#Region " Form Button Events "
''' <summary>
''' Toggle Play/Stop.
''' </summary>
Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.Click
Play()
End Sub
''' <summary>
''' Toggle Mute/Unmute.
''' </summary>
Private Sub btnMute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMute.Click
Mute()
End Sub
''' <summary>
''' Change button border appearance when mouse enter and when it is down.
''' </summary>
Private Sub btnPlay_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnPlay.MouseDown
btnPlay.FlatAppearance.BorderColor = Color.DodgerBlue
End Sub
Private Sub btnPlay_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnPlay.MouseUp
btnPlay.FlatAppearance.BorderColor = Color.Black
End Sub
Private Sub btnPlay_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.MouseEnter
btnPlay.FlatAppearance.BorderColor = Color.DarkOrange
End Sub
Private Sub btnPlay_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.MouseLeave
btnPlay.FlatAppearance.BorderColor = Color.Black
End Sub
Private Sub btnMute_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMute.MouseDown
btnMute.FlatAppearance.BorderColor = Color.DodgerBlue
End Sub
Private Sub btnMute_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMute.MouseUp
btnMute.FlatAppearance.BorderColor = Color.Black
End Sub
Private Sub btnMute_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMute.MouseEnter
btnMute.FlatAppearance.BorderColor = Color.DarkOrange
End Sub
Private Sub btnMute_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMute.MouseLeave
btnMute.FlatAppearance.BorderColor = Color.Black
End Sub
#End Region
#Region " Download Image "
''' <summary>
''' Downloads gif image file from the Internet and displays it if it is above a certain size.
''' </summary>
Private Sub DownloadImage()
Const baseUrl As String = "http://art1.dc1.sonixtream.com/coverart/" ' CBS Radio Stations ONLY
Dim imageUrl As String = StationInfo.CoverArt
Dim filePath As String = My.Application.Info.DirectoryPath & "\DefautCoverArt.gif"
If imageUrl <> "" Then
Try
If StationInfo.CoverArt.Substring(0, 4) = "" Then
' No image information is available, use default cover art.
If File.Exists(filePath) Then
picStation.LoadAsync(filePath)
End If
ElseIf StationInfo.CoverArt.Substring(0, 4) <> "http" Then
' Incomplete URL is provided, exit if name are not provided.
If mSelectedName = "" Then
DisplayStationInfo()
Else
' Attempt to download and display image async.
imageUrl = baseUrl & StationInfo.CoverArt
picStation.LoadAsync(imageUrl)
End If
ElseIf StationInfo.CoverArt.Substring(0, 4) = "http" Then
' Attempt to download and display image async.
picStation.LoadAsync(imageUrl)
End If
Catch ex As InvalidOperationException
' Ignore and display station info.
Catch exc As FileNotFoundException
' Ignore and display station info.
Catch excep As IOException
' Ignore and display station info.
End Try
Else
' No image information is available, use default cover art.
If File.Exists(filePath) Then
picStation.LoadAsync(filePath)
End If
End If
End Sub
Private Sub DisplayStationInfo()
picStation.Image = Nothing
' Display name.
lblStation.Text = mSelectedName
' Display location.
lblLocation.Text = mSelectedLocation
' Display slogan.
lblSlogan.Text = StationInfo.Title
End Sub
#End Region
#Region " General Methods "
''' <summary>
''' Read options from settings and set variables and menus.
''' </summary>
Private Sub SetOptions()
' Set color.
SetColor(Me, Settings.Color)
' Set color on menu.
Select Case Settings.Color
Case "Blue"
mnuBlue.Image = My.Resources.Checked
Case "Cyan"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -