⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stationeditdialog.vb

📁 一个界面很好的iRadio收音机 一个界面很好的iRadio收音机
💻 VB
字号:
Option Explicit On
Option Strict On

Imports System.Xml
Imports System.IO
Imports System.Text
Imports System.Windows.Forms

''' <copyright>Copyright ?2006 Herbert N Swearengen III</copyright>
'''
''' <notice>
''' This application maybe freely distributed and modified as long
''' as the copyright notice and EULA are retained. This applies to
''' both the compiled application and it's source code.
''' </notice>
Public Class StationEditDialog

#Region " Form Events "

    Private Sub StationEditDialog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim i As Integer

        ' Set color.
        SetColor(Me, Settings.Color)

        ' If the global station format collection is empty, populate it.
        If gFormat.Count = 0 Then
            GetFormatList()
        End If

        ' Populate combobox with format list.
        If gFormat.Count > 0 Then
            For i = 1 To gFormat.Count
                cboFormat.Items.Add(gFormat(i).ToString)
            Next
        End If

    End Sub

#End Region

#Region " pnlHeader Mouse Events - Move Form "

    ''' <summary>
    ''' Responds to the left mouse button down on pnlHeader.
    ''' For each movement, the form is moved correspondingly.
    ''' </summary>
    Private Sub pnlHeader_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles pnlHeader.MouseDown

        ' If the left mouse is pressed, release form for movement
        If e.Button = Windows.Forms.MouseButtons.Left Then
            ReleaseCapture()
            SendMessage(Handle, WM_NCLBUTTONDOWN, CType(HTCAPTION, UIntPtr), CType(0, UIntPtr))
        End If
    End Sub

#End Region

#Region " Button Events "

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        ' Prevents overwriting of text property with previous info.
        cboFormat.Items.Clear()
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnCancel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnCancel.MouseDown
        btnCancel.FlatAppearance.BorderColor = Color.DodgerBlue
    End Sub

    Private Sub btnCancel_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnCancel.MouseUp
        btnCancel.FlatAppearance.BorderColor = Color.Black
    End Sub

    Private Sub btnCancel_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.MouseEnter
        btnCancel.FlatAppearance.BorderColor = Color.DarkOrange
    End Sub

    Private Sub btnCancel_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.MouseLeave
        btnCancel.FlatAppearance.BorderColor = Color.Black
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        ' Prevents overwriting of text property with previous info.
        cboFormat.Items.Clear()
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnSave_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnSave.MouseDown
        btnSave.FlatAppearance.BorderColor = Color.DodgerBlue
    End Sub

    Private Sub btnSave_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnSave.MouseUp
        btnSave.FlatAppearance.BorderColor = Color.Black
    End Sub

    Private Sub btnSave_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.MouseEnter
        btnSave.FlatAppearance.BorderColor = Color.DarkOrange
    End Sub

    Private Sub btnSave_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.MouseLeave
        btnSave.FlatAppearance.BorderColor = Color.Black
    End Sub

#End Region

#Region " PictureBox Events "

    Private Sub picClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picClose.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub picClose_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles picClose.MouseEnter
        picClose.Image = My.Resources.Close_Mouse_Hover
    End Sub

    Private Sub picClose_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles picClose.MouseLeave
        picClose.Image = My.Resources.Close_Mouse_Up
    End Sub

#End Region

#Region " XML Methods "

    ''' <summary>
    ''' Use a XMLTextReader to read format file into collection.
    ''' </summary>>
    Private Shared Sub GetFormatList()
        Dim filePath As String = My.Application.Info.DirectoryPath & "\Format.xml"
        Dim reader As XmlReader = Nothing

        Try

            ' Setup up StreamReader to read XML.
            Dim myStreamReader As New StreamReader(filePath, Encoding.UTF8)

            ' Create XML reader.
            reader = XmlTextReader.Create(myStreamReader)

            ' Locate comment.
            While reader.Read = True
                If reader.NodeType = XmlNodeType.Element Then
                    If reader.Name = "format" Then   ' <format> node
                        ' Add format to collection.
                        gFormat.Add(reader.ReadElementString)
                    End If
                End If
            End While

            ' Close StreamReader, XMLTextReader.
            myStreamReader.Close()
            reader.Close()

        Catch ex As FileNotFoundException
            MessageBox.Show("The format list file:" & vbCrLf & filePath & vbCrLf & _
                            "was not found. Please restore this file or reinstall the program.", _
                            My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Catch exc As IOException
            MessageBox.Show("An error occurred reading the format list file""" & Path.GetFileName(filePath) & """." & vbCrLf & _
                            "The system returned the following information:" & vbCrLf & exc.Message, _
                            My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Catch excep As ArgumentNullException
            MessageBox.Show("An error occurred in ""GetFormatList."" The system returned the following information:" & vbCrLf & _
                            excep.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Catch except As XmlException
            MessageBox.Show("An error has occurred in ""GetFormatList."" The system returned the following information:" & _
                vbCrLf & except.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            If reader IsNot Nothing Then
                reader.Close()
            End If
        End Try

    End Sub

#End Region

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -