General Category > Tips & Tricks
Glass Buttons
Godra:
And here you can find a nice looking Glass Button which can easily be converted to AHMI control:
http://lukesw.net/articles/GlassButton.aspx
The link above doesn't seem to be valid any longer, so try either of these:
https://www.codeproject.com/Articles/17695/Creating-a-Glass-Button-using-GDI
https://www.codeproject.com/Articles/18000/Enhanced-GlassButton-using-GDI
Download demo file that contains the library, add this library as reference to both AdvancedHMI and AdvancedHMIControls projects and then download and add the attached GlassButtonHMI.vb file to the PurchasedControls folder as ExistingItem.
It supports an image showing in the button (check the attached picture with icon file used as image).
Animated GIFs are also supported and you can find some here:
https://www.animatedimages.org
The only way to control animation is to have the button disabled, but still visible, and once enabled by some event the animation will be running (maybe there is another way but I still need to discover it).
* Edit: There is a simpler and safer way of adding this control to AHMI. Read bachphi's post on the 2nd page.
Archie:
Nice find. I split this into it's own thread so it wouldn't get lost in the other thread.
Godra:
Separate thread should work better.
This button could be used as just image holder, without functioning as button, that way animated GIF could have a good purpose (but could serve as a button as well).
I do have a question for you if there is possibility to create PLCAddressEnabled property to control the current Enabled property through a PLC address instead of creating a code (or list of steps for doing it)?
Archie:
You can add PLC control of any property by adding this line of code to the class similar to this:
Public Property PLCAddressEnabled as string
The SubscriptionHandler searches the control for a property that matches the name after PLCAddress and hooks it to a subscription.
Godra:
Either I am doing it wrong or it just doesn't work.
This "Enabled" property appears to be inherited from Windows Button control, since I have:
Class GlassButton --> Inherits Button
Class GlassButtonHMI --> Inherits GlassButton
Here is the property I created:
--- Code: --- '*****************************************
'* Property - Address in PLC to Link to
'*****************************************
Private _PLCAddressEnabled As String = ""
<System.ComponentModel.Category("PLC Properties")> _
Public Property PLCAddressEnabled() As String
Get
Return _PLCAddressEnabled
End Get
Set(ByVal value As String)
If _PLCAddressEnabled <> value Then
_PLCAddressEnabled = value
'* When address is changed, re-subscribe to new address
SubscribeToCommDriver()
End If
End Set
End Property
--- End code ---
This new property shows and I can enter a PLC address but it just doesn't do anything to Enabled property.
I did try to create a new Enabled property in the GlassButton class, which overloads the Enabled property of the Windows Button control, but that didn't work either.
It's not a big deal to have this property, but if there is a way it would be nice to have (at least in my opinion).
Navigation
[0] Message Index
[#] Next page
Go to full version