UI Interest Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrapping a .NET Control in an XControl Example

Following up from some other posts about using .NET controls in LabVIEW I figured I'd post this example I wrote a while ago (disclaimer - I haven't done extensive testing and I really through it together in a hurry so no promises of quality).

Essentially I have created an XControl which hides the associated complexity of using .NET controls in LabVIEW.  If you plan on using a control more than once it's probably worth while -- XControls are fairly simple to use for use cases such as this gauge.

.NET Gauge in LabVIEW Example.png

In order for the demo to actually work you'll need to install the Dundas Gauge for Windows Forms package.  A free evaluation is was available here - http://www.dundas.com/Components/Downloads/index.aspx#gauge

Unfortunately the .NET control I was using is now EOL and no longer available.

Things you should know about XControls:

  • An XControl (xctl) contains numerous required files:
    • Data.ctl - defines the datatype of your XControl.  In this example it's simply a double precision numeric.
    • State.ctl - defines any state information your XControl needs.  In this example we store the path to the configuration XML file which determines how the gauge should look.
    • Facade.vi - this is the "meat" of the XControl.  It is a VI with an event structure that gets called by LabVIEW when something happens which might require redrawing the control (i.e. data change, panel resize, change from control to indicator etc.).  In this example I only really care about two events: 1. new data is written to my indicator and 2. the control's state is modified (by my property node).  I am not handling panel resizing events which get called when the user resizes your control (I could but then I'd have to figure out how to resize the Dundas gauge and I really didn't have time).
    • Property Read and Write VIs - this is how you add custom properties to your XControl.  In the example I have implemented a property for the XML Configuration File to pull the visual configuration from.
  • You can't have an array of XControls
  • XControls don't run constantly (your code gets called to handle events)
  • XControls get called even in edit mode (if it's on a front panel in memory you can't edit it)
Comments
Thoric
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

One (perhaps overly complicated) example of an XControl wrapper for a .NET control:

http://decibel.ni.com/content/docs/DOC-12073

Thoric (CLA, CLED, CTD and LabVIEW Champion)


GJMABerends
Member
Member
on

First of all, Great post

I have only a few notes, you can make arrays of XControls, just put the XControl in a cluster and that cluster in a array . Also you can disconnect your XControl so you can edit them at runtime. You need to close all references when you want to relink your XControl.

D60
Active Participant
Active Participant
on

Great Post!

Thanks for sharing, but the link: http://www.dundas.com/Components/Downloads/index.aspx#gauge does not work!

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
SimonH
NI Employee (retired)
on

Unfortunately Dundas Guage appears to "End of Life" due to acquisition from Microsoft .  I'll modify the post to reflect that.

Contributors