Created
August 7, 2015 13:40
-
-
Save wolf99/c941e811d512245db3d8 to your computer and use it in GitHub Desktop.
A Halt/Go display user control that inherits from a Label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class HaltGoLabel | |
Inherits Label | |
Enum HaltGoState | |
Go = 0 | |
Halt = 1 | |
End Enum | |
Private _state As HaltGoState | |
Public Property GoBackColor As System.Drawing.Color = Color.LimeGreen | |
Public Property GoForeColor As System.Drawing.Color = SystemColors.WindowText | |
Public Property HaltBackColor As System.Drawing.Color = Color.Red | |
Public Property HaltForeColor As System.Drawing.Color = SystemColors.Window | |
Public Property GoText As String = "OK" | |
Public Property HaltText As String = "!" | |
Public Property State() As HaltGoState | |
Get | |
Return _state | |
End Get | |
Set(ByVal value As HaltGoState) | |
If value = HaltGoState.Go Then | |
Go() | |
Else | |
Halt() | |
End If | |
End Set | |
End Property | |
Public Sub New() | |
MyBase.New() | |
Me.Layout(Nothing, Nothing) | |
End Sub | |
Private Shadows Sub Layout(ByVal sender As Object, e As System.EventArgs) Handles MyBase.Layout | |
Dim resize As Font = New Font("Microsoft Sans Serif", 8.25, FontStyle.Regular) | |
Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle | |
Me.TextAlign = ContentAlignment.MiddleCenter | |
Me.AutoSize = False | |
Me.Font = resize | |
Me.Height = 20 | |
Me.Width = 35 | |
If _state = HaltGoState.Go Then | |
Go() | |
Else | |
Halt() | |
End If | |
End Sub | |
Public Sub Go() | |
Me.ForeColor = GoForeColor | |
Me.BackColor = GoBackColor | |
Me.Text = GoText | |
_state = HaltGoState.Go | |
End Sub | |
Public Sub Halt() | |
Me.ForeColor = HaltForeColor | |
Me.BackColor = HaltBackColor | |
Me.Text = HaltText | |
_state = HaltGoState.Halt | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment