Imports System.ComponentModel
'===============================
'------ Abu Ehab ---------------
'===============================
<ToolboxBitmap(GetType(TheButton), "BtnIcon.bmp")> Public Class TheButton
Inherits Button
Public Sub New()
Me.BackgroundImageLayout = ImageLayout.Stretch
Me.BackgroundImage = My.Resources.L
Me.ForeColor = Color.White
Me.Cursor = Cursors.Hand
End Sub
Dim Sund As Boolean = False
Public Property PlaySound() As Boolean
Get
Return Sund
End Get
Set(ByVal value As Boolean)
Sund = value
TheOptions()
End Set
End Property
#Region " Hide Colors Properties "
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Overrides Property BackgroundImage() As System.Drawing.Image
Get
Return MyBase.BackgroundImage
End Get
Set(ByVal value As System.Drawing.Image)
MyBase.BackgroundImage = value
End Set
End Property
<Bindable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Overrides Property BackColor() As System.Drawing.Color
Get
Return MyBase.BackColor
End Get
Set(ByVal value As System.Drawing.Color)
MyBase.BackColor = value
End Set
End Property
#End Region
Public Sub TheOptions()
Select Case Sund
Case YourSound.PlaySound
My.Computer.Audio.Play(My.Resources.ClickSound, AudioPlayMode.WaitToComplete)
End Select
End Sub
#Region " Events "
Private Sub TheButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
If Sund Then
My.Computer.Audio.Play(My.Resources.ClickSound, AudioPlayMode.WaitToComplete)
End If
End Sub
Private Sub TheButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.BackgroundImage = My.Resources.D
End Sub
Private Sub TheButton_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseHover
Me.BackgroundImage = My.Resources.h
End Sub
Private Sub TheButton_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
Me.BackgroundImage = My.Resources.L
End Sub
#End Region
End Class
Public Enum YourSound
PlaySound
StopSound
End Enum