📄 mainform.vb
字号:
mnuCyan.Image = My.Resources.Checked
Case "Fuchsia"
mnuFuchsia.Image = My.Resources.Checked
Case "Gray"
mnuGray.Image = My.Resources.Checked
Case "Green"
mnuGreen.Image = My.Resources.Checked
Case "Orange"
mnuOrange.Image = My.Resources.Checked
Case "Red"
mnuRed.Image = My.Resources.Checked
Case "Teal"
mnuTeal.Image = My.Resources.Checked
End Select
Dim filePath As String = gAppDataFolder & "\" & Settings.SelectedFolder & "\" & Settings.StationList & ".xml"
If Settings.SelectedFolder <> "" And Settings.StationList <> "" Then
ReadXml(filePath)
tabStationList.Text = GetStationListComment(filePath)
PopulateStationListView(Settings.SelectedFolder)
End If
' Set volume.
trkVolume.Value = Settings.Volume
Player.settings.volume = Settings.Volume
ToolTip2.SetToolTip(trkVolume, "音量 " & Settings.Volume.ToString & "%")
VolumeForm.ToolTip1.SetToolTip(VolumeForm.trkVolume, "音量 " & Settings.Volume.ToString & "%")
' Apply settings to radiobuttons.
SetStations(Me)
' Select last button used.
SelectButton(Me)
' Set AutoPlay.
If Settings.AutoPlay = True Then
mnuAutoPlay.Image = My.Resources.Checked
Else
mnuAutoPlay.Image = Nothing
End If
' Set DisplaySplash.
If Settings.DisplaySplashScreen = True Then
mnuDisplaySplashScreen.Image = My.Resources.Checked
Else
mnuDisplaySplashScreen.Image = Nothing
End If
' Set DisplayVisualizations.
If Settings.DisplayVisualizations = True Then
mnuDisplayVisualizations.Image = My.Resources.Checked
Else
mnuDisplayVisualizations.Image = Nothing
End If
' Set DisplayCoverArt.
If My.Settings.DisplayCoverArt = True Then
mnuDisplayCoverArt.Image = My.Resources.Checked
Else
mnuDisplayCoverArt.Image = Nothing
End If
' Set KeepOnTop.
If Settings.KeepOnTop = True Then
Me.TopMost = True
mnuKeepOnTop.Image = My.Resources.Checked
Else
Me.TopMost = False
mnuKeepOnTop.Image = Nothing
End If
' Set RotateStationInfo
If Settings.RotateStationInfo = True Then
mnuRotateStationInfo.Image = My.Resources.Checked
Else
mnuRotateStationInfo.Image = Nothing
End If
' Set StartAsIcon.
If Settings.StartAsIcon = True Then
mnuStartAsIcon.Image = My.Resources.Checked
Else
mnuStartAsIcon.Image = Nothing
End If
' Set StartWithWindows.
If Settings.StartWithWindows = True Then
mnuStartWithWindows.Image = My.Resources.Checked
Else
mnuStartWithWindows.Image = Nothing
End If
' Set ToolTips.
If Settings.ToolTips = True Then
mnuDisplayTooltips.Image = My.Resources.Checked
Else
mnuDisplayTooltips.Image = Nothing
End If
' Set ToolTip on Player.
ToolTip2.SetToolTip(Player, "双击全屏显示")
End Sub
''' <summary>
''' Close and dispose of Player, disable info timer, save settings, and exit application .
''' </summary>
Private Sub AppExit()
Try
tmrInfo.Enabled = False
If Player IsNot Nothing Then
If Player.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Player.Ctlcontrols.stop()
End If
Player.close()
Player.Dispose()
End If
Catch comExc As COMException
Dim hr As Integer = comExc.ErrorCode
Dim Message As String = "HRESULT = " & hr.ToString() & vbCrLf & comExc.Message
' If error occurs, cancel topmost.
If Me.TopMost = True Then Me.TopMost = False
MessageBox.Show("AppExit: COM Exception:" & vbCrLf & Message, My.Application.Info.Title, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Try
If Me.WindowState = FormWindowState.Normal Then
' Save window position
My.Settings.XPosition = Me.Location.X
My.Settings.YPosition = Me.Location.Y
' Minimize and don't show in taskbar before closing.
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
End If
' Save current volume level.
My.Settings.Volume = Settings.Volume
My.Settings.Save()
Application.Exit()
Catch ex As ArgumentException
' If error occurs, cancel topmost.
If Me.TopMost = True Then Me.TopMost = False
MessageBox.Show("Error closing application. The system returned the following information:" & vbCrLf & _
ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
End Sub
''' <summary>
''' Reset all options, including station buttons, to default values.
''' </summary>
Private Sub ResetSettings()
Try
Dim i As Integer
' Reset all option settings.
My.Settings.PropertyValues.Item("AutoPlay").PropertyValue = True
My.Settings.PropertyValues.Item("Color").PropertyValue = "Gray"
My.Settings.PropertyValues.Item("DisplayCoverArt").PropertyValue = False
My.Settings.PropertyValues.Item("DisplayVisualizations").PropertyValue = True
My.Settings.PropertyValues.Item("DisplaySplashScreen").PropertyValue = True
My.Settings.PropertyValues.Item("KeepOnTop").PropertyValue = False
My.Settings.PropertyValues.Item("LastButtonSelected").PropertyValue = ""
My.Settings.PropertyValues.Item("RotateStationInfo").PropertyValue = False
My.Settings.PropertyValues.Item("SelectedFolder").PropertyValue = ""
My.Settings.PropertyValues.Item("StartAsIcon").PropertyValue = False
My.Settings.PropertyValues.Item("StartWithWindows").PropertyValue = False
My.Settings.PropertyValues.Item("StationList").PropertyValue = "CBS Radio"
My.Settings.PropertyValues.Item("ToolTips").PropertyValue = True
My.Settings.PropertyValues.Item("Volume").PropertyValue = 50
My.Settings.PropertyValues.Item("XPosition").PropertyValue = GetCenterBounds(Me).X
My.Settings.PropertyValues.Item("YPosition").PropertyValue = GetCenterBounds(Me).Y
' Reset all station button settings.
For i = 1 To 18
My.Settings.PropertyValues.Item("Station" & CStr(i) & "Name").PropertyValue = ""
My.Settings.PropertyValues.Item("Station" & CStr(i) & "Location").PropertyValue = ""
My.Settings.PropertyValues.Item("Station" & CStr(i) & "Format").PropertyValue = ""
My.Settings.PropertyValues.Item("Station" & CStr(i) & "Website").PropertyValue = ""
My.Settings.PropertyValues.Item("Station" & CStr(i) & "Uri").PropertyValue = ""
Next
Catch ex As NullReferenceException
' If error occurs, cancel topmost.
If Me.TopMost = True Then Me.TopMost = False
MessageBox.Show("Failed to reset settings. The system returned the following information:" & vbCrLf & vbCrLf & _
ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub ClearStructures()
' Clear NetworkInfo structure to prevent errors from missing data.
NetworkInfo.Bandwidth = ""
NetworkInfo.BitRate = ""
NetworkInfo.LostPackets = ""
NetworkInfo.MaximumBandwidth = ""
NetworkInfo.MaximumBitRate = ""
NetworkInfo.ReceivedPackets = ""
NetworkInfo.ReceptionQuality = ""
NetworkInfo.RecoveredPackets = ""
NetworkInfo.SourceProtocol = ""
NetworkInfo.SourceUrl = ""
NetworkInfo.Url = ""
' Clear StationInfo structure to prevent errors from missing data.
StationInfo.AdUrl = ""
StationInfo.Author = ""
StationInfo.Copyright = ""
StationInfo.CoverArt = ""
StationInfo.CurrentPlaylistName = ""
StationInfo.CurrentPosition = ""
StationInfo.MoreInfoRef = ""
StationInfo.Name = ""
StationInfo.SourceUrl = ""
StationInfo.Status = ""
StationInfo.Title = ""
End Sub
#End Region
#Region " Header Label Events "
Private Sub lblHeader_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblHeader.DoubleClick
' Form can't be topmost when other form is shown.
If Settings.KeepOnTop = True Then
Me.TopMost = False
End If
AboutDialog.ShowDialog()
' Make form topmost again, if set.
If Settings.KeepOnTop = True Then
Me.TopMost = True
End If
End Sub
Private Sub lblHeader_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblHeader.MouseEnter
ToolTip2.SetToolTip(lblHeader, "Version: " & My.Application.Info.Version.ToString)
End Sub
#End Region
#Region " Link Label Events "
Private Sub llbWebsite_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llbWebsite.LinkClicked
Try
Dim startInfo As New ProcessStartInfo(llbWebsite.Text)
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
#End Region
#Region " MenuStrip Mouse Events - Form Move "
''' <summary>
''' Responds to the left mouse button down on MenuStrip1.
''' For each movement, the form is moved correspondingly.
''' </summary>
Private Sub MenuStrip1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MenuStrip1.MouseDown
' If the left mouse is pressed, release form for movement
If e.Button = Windows.Forms.MouseButtons.Left Then
MenuStrip1.Cursor = Cursors.Hand
ToolTip2.SetToolTip(MenuStrip1, "")
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, CType(HTCAPTION, UIntPtr), CType(0, UIntPtr))
End If
End Sub
''' <summary>
''' Changes cursor back to default.
''' </summary>
Private Sub MenuStrip1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MenuStrip1.MouseUp
MenuStrip1.Cursor = Cursors.Default
End Sub
''' <summary>
''' Removes ToolTip.
''' </summary>
Private Sub MenuStrip1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MenuStrip1.MouseMove
ToolTip2.SetToolTip(MenuStrip1, "Move")
MenuStrip1.Cursor = Cursors.Default
End Sub
#End Region
#Region " Minimize PictureBox Events "
''' <summary>
''' Don't close the form when the "-" is clicked; just hide it.
''' </summary>
Private Sub picMinimize_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picMinimize.MouseDown
picMinimize.Image = My.Resources.Minimize_Mouse_Down
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
Me.Opacity = 0
NotifyIcon1.Visible = True
NotifyIcon1.ContextMenuStrip = Me.NotifyIconContextMenu
' Display balloon tip with info setup by PlayStation.
If NotifyIcon1.Visible = True Then
NotifyIcon1.ShowBalloonTip(2000)
End If
' If topmost is set, disable it now because icon is shown.
If Settings.KeepOnTop = True Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -