Author Topic: GraphicIndicator Text Color  (Read 2686 times)

Morgan

  • Newbie
  • *
  • Posts: 44
    • View Profile
GraphicIndicator Text Color
« on: May 12, 2016, 11:01:08 AM »
Is there a way to change the GraphicIndicator's text color?  If the graphic is dark you cannot see the black text.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: GraphicIndicator Text Color
« Reply #1 on: May 12, 2016, 11:07:17 AM »
Use the ForeColor property set the Text color

Morgan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: GraphicIndicator Text Color
« Reply #2 on: May 12, 2016, 11:37:42 AM »
You can change the control's Font ForeColor to anything and it works but as soon as the Form is reloaded the text color changes back to Black.  The control's Font ForeColor is still the color that was set.

When you first create the control the font color is the same as the parent Form.  If you ever change it then it will always be black when the Form is loaded.
« Last Edit: May 12, 2016, 01:16:39 PM by Morgan »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: GraphicIndicator Text Color
« Reply #3 on: May 12, 2016, 05:06:29 PM »
This is a confirmed bug. Fortunately there is an easy work around.

- Go to Solution Explorer and expand down the AdvancedHMIControls project
- Under that project, open the GraphicIndicator.vb file
- Scroll all the way to the bottom and paste the following code just one line above "End Class"
Code: [Select]
    Protected Overrides Sub OnForeColorChanged(e As System.EventArgs)
        MyBase.OnForeColorChanged(e)

        If TextBrush Is Nothing Then
            TextBrush = New SolidBrush(MyBase.ForeColor)
        Else
            TextBrush.Color = MyBase.ForeColor
        End If

        Me.Invalidate()
    End Sub