PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/PowerSong/Custom Controls/Widget.vb

#
Visual Basic | 46 lines | 37 code | 9 blank | 0 comment | 0 complexity | 278f2b6781ba8bba6f17857ff49852a8 MD5 | raw file
 1Public Class Widget
 2
 3    Private FArea As New RectangleF(0.1, 0.1, 0.8, 0.8)
 4
 5    Public Property Area() As RectangleF
 6        Get
 7            Return FArea
 8        End Get
 9        Set(ByVal value As RectangleF)
10            Dim OldArea As RectangleF = FArea
11            FArea = value
12            If OldArea <> value Then RaiseEvent AreaChanged(Me)
13        End Set
14    End Property
15
16    Private FTarget As Object = Nothing
17
18    Public Property Target() As Object
19        Get
20            Return FTarget
21        End Get
22        Set(ByVal value As Object)
23            Dim OldTarget As Object = FTarget
24            FTarget = value
25            If OldTarget IsNot value Then RaiseEvent TargetChanged(Me, value)
26        End Set
27    End Property
28
29    Public Event AreaChanged(ByVal widget As Widget)
30    Public Event TargetChanged(ByVal widget As Widget, ByVal newValue As Object)
31    Public Event Draw(ByVal graphics As Graphics, ByVal region As Rectangle)
32
33    Public Sub New(ByVal target As Object)
34        FTarget = target
35    End Sub
36
37    Public Sub New(ByVal target As Object, ByVal area As RectangleF)
38        FTarget = target
39        FArea = area
40    End Sub
41
42    Friend Sub RaiseDrawEvent(ByVal graphics As Graphics, ByVal region As Rectangle)
43        RaiseEvent Draw(graphics, region)
44    End Sub
45
46End Class