Author Topic: GraphicIndicator  (Read 1842 times)

WellsCPak

  • Newbie
  • *
  • Posts: 28
    • View Profile
GraphicIndicator
« on: June 29, 2015, 03:37:47 PM »
I was playing with the GraphicIndicator component as an LED-style indicator. It's watching a bit for on or off state and showing the on or off light accordingly.

I was wondering if there's a way to change the image alignment within the control?
Or turn off the "stretch" setting so it displays the image at its native size instead of resizing it to fit the control.

I traced the code until I hit the Object Browser for the MfgControl.AdvancedHMI.Controls.dll and I can't seem to go any farther or find the code controlling the paint event for the control.
Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: GraphicIndicator
« Reply #1 on: June 29, 2015, 04:35:51 PM »
You might be able to modify the GraphicIndicator.vb code and add something like this:

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim g As Graphics = e.Graphics

        If ValueSelect1 Then
            If GraphicSelect1 IsNot Nothing Then
                    'g.DrawImage(GraphicSelect1, 0, 0, Me.Width, Me.Height)
                   g.DrawImage(GraphicSelect1, 0, 0)
              End If
        ElseIf ValueSelect2 Then
            If GraphicSelect2 IsNot Nothing Then
                     ' g.DrawImage(GraphicSelect2, 0, 0, Me.Width, Me.Height)
                    g.DrawImage(GraphicSelect2, 0, 0)
            End If
        Else
            If GraphicAllOff IsNot Nothing Then
                   ' g.DrawImage(GraphicAllOff, 0, 0, Me.Width, Me.Height)
                    g.DrawImage(GraphicAllOff, 0, 0)
            End If
        End If
    End Sub


This will draw the images without stretching them. The commented DrawImage is the one that will stretch

WellsCPak

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: GraphicIndicator
« Reply #2 on: June 30, 2015, 08:15:28 AM »
Works like a charm! Thanks Archie!