|
Public Class ColorObserver
Public Shared Event ColorUpdated()
Private Shared _SelectedColor As Colors
Public Enum Colors
Red = 0
White = 1
Blue = 2
End Enum
#Region "Singleton Design Patern"
REM Use a Singleton Design patern to ensure that this class can only be instanciated once
Public Shared s As ColorObserver
Public Shared flag As Boolean
Private Sub New()
'private constructor disallowing other to create object directly
End Sub
Public Shared Function getSingletonObject() As ColorObserver
If flag = False Then
'First instance
'return a new object
s = New ColorObserver
flag = True
Return s
Else
'future object request
'return an already created object
Return s
End If
End Function
#End Region
#Region "Color Functions"
Public Property Color() As Colors
Get
Return _SelectedColor
End Get
Set(ByVal Color As Colors)
_SelectedColor = Color
RaiseEvent ColorUpdated()
End Set
End Property
#End Region
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here