Skip to content

Instantly share code, notes, and snippets.

@wolf99
Created August 7, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolf99/c941e811d512245db3d8 to your computer and use it in GitHub Desktop.
Save wolf99/c941e811d512245db3d8 to your computer and use it in GitHub Desktop.
A Halt/Go display user control that inherits from a Label
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