I went a bit beyond in playing around.
Here is what I have now.
Public Class PilotLightEx
Inherits AdvancedHMIControls.PilotLight
Private Textx As Single
Private Texty As Single
Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)
Dim myTextSize As New SizeF
If Me.Value = True Then
myTextSize = e.Graphics.MeasureString(LightColorOnText, Me.Font)
CenterText(myTextSize)
e.Graphics.DrawString(LightColorOnText, Me.Font, Brushes.Black, Textx, Texty)
Else
myTextSize = e.Graphics.MeasureString(LightColorOffText, Me.Font)
CenterText(myTextSize)
e.Graphics.DrawString(LightColorOffText, Me.Font, Brushes.Wheat, Textx, Texty)
End If
End Sub
Private m_LightColorOnText As String = "ON"
Public Property LightColorOnText As String
Get
Return m_LightColorOnText
End Get
Set(value As String)
m_LightColorOnText = value
End Set
End Property
Private m_LightColorOffText As String = "Off"
Public Property LightColorOffText As String
Get
Return m_LightColorOffText
End Get
Set(value As String)
m_LightColorOffText = value
End Set
End Property
Private Sub CenterText(txtSize As SizeF)
If Me.LegendPlate = LegendPlates.Large Then
Texty = ((Me.Height * 0.68)) - (txtSize.Height / 2)
Else
Texty = (Me.Height * 0.59) - (txtSize.Height / 2)
End If
Textx = (Me.Width / 2) - (txtSize.Width / 2)
End Sub
End Class
The height Centering code is a little hokey but effective.
I tried messing with the colors, but ran into a roadblock making the properties.
I haven't played with it yet, but would like a way for the font to be different.
I'm sure you know better ways to do this, but it does work.