PageRenderTime 92ms CodeModel.GetById 84ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Visual Basic | 62 lines | 52 code | 10 blank | 0 comment | 0 complexity | 1217d39c8529afca4225dabbe25e3c06 MD5 | raw file
 1Public Class NoticeLabel
 2
 3    Public Property Message() As String
 4        Get
 5            Return lblMessage.Text
 6        End Get
 7        Set(ByVal value As String)
 8            lblMessage.Text = value
 9            lblMessage.Invalidate()
10        End Set
11    End Property
12
13    Public Enum IconType
14        [Error]
15        Warning
16        Info
17        Running
18        Passed
19        Waiting
20    End Enum
21
22    Private FIcon As IconType = IconType.Info
23
24    Public Property Icon() As IconType
25        Get
26            Return FIcon
27        End Get
28        Set(ByVal value As IconType)
29            FIcon = value
30            Select Case value
31                Case IconType.Error : PictureBox1.Image = My.Resources._Error
32                Case IconType.Info : PictureBox1.Image = My.Resources.Info
33                Case IconType.Passed : PictureBox1.Image = My.Resources.Passed
34                Case IconType.Running : PictureBox1.Image = My.Resources.Executing
35                Case IconType.Warning : PictureBox1.Image = My.Resources.Warning
36                Case IconType.Waiting : PictureBox1.Image = My.Resources.Waiting
37            End Select
38        End Set
39    End Property
40
41    Public Sub Change(ByVal newIcon As IconType, _
42                      ByVal message As String, _
43                      Optional ByVal showMessageBox As Boolean = False)
44
45        Me.Icon = newIcon
46        Me.Message = message
47
48        If showMessageBox Then
49            Dim Style As MsgBoxStyle = MsgBoxStyle.Information
50            Select Case newIcon
51                Case IconType.Error : Style = MsgBoxStyle.Critical
52                Case IconType.Warning : Style = MsgBoxStyle.Exclamation
53            End Select
54            MsgBox(message, Style)
55        End If
56
57        Me.Update()
58        Threading.Thread.Sleep(100)
59
60    End Sub
61
62End Class