The 3D styles that you see in Measurement Studio 6.0, LabWindows/CVI, and LabVIEW is unmanaged code that would take a good amount of engineering effort to integrate with or migrate to an all-managed code base like the new Measurement Studio UI controls, and unfortunately this wasn't in the Measurement Studio 7.0 release. However, the Measurement Studio .NET switch styles are extensible, so this does not mean that you're limited to the styles that shipped with Measurement Studio 7.0. One way you can emulate the 3D styles with the .NET switch is to:
- Create images (preferably metafiles) of the off and on states of the 3D switch in Measurement Studio 6.0.
- Create a class that derives from NationalInstruments.UI.SwitchStyle and create a custom style that uses the 3D images to display the style.
The SaveCWMetafile.zip attachment below is a project that demonstrates how to generate the images in the first step. The CustomSwitchStyle.zip attachment below is a project that demonstrates how to create the custom style in the second step. Below is a little more technical detail about each step.
The easiest way to create the images from the Measurement Studio 6.0 controls is to create a separate project that use interop assemblies for the Measurement Studio 6.0 ActiveX controls, add an ActiveX switch to a Windows Form, then use the ActiveX control's ControlImage method to get an image for the control. The image that's returned by ControlImage is a metafile, so if you call this once for each state, you can easily get metafiles for when the value is false and for when it is true. Once you have the metafiles you can save them and then copy the saved metafiles to the project where you will create the custom switch style. See the attached SaveCWMetafile project for more information.
Add the saved metafiles to your project and specify that they are embedded resources in the properties window. Create a class that derives from NationalInstruments.UI.SwitchStyle and in the class you can create the two metafiles at runtime from the resources in the assembly manifest. Override the Draw method and then draw the appropriate bitmap according to the state of the switch control. Once you have the custom style created, instantiate it and assign it to the switch's SwitchStyle property, and your .NET switch should then be drawing like the 3D switch in Measurement Studio 6.0. This is much easier than it sounds - see the attached CustomSwitchStyle project for more information.
Note that this approach does have a couple of drawbacks. For example, the background and foreground colors of the control are hard coded into the image, so you would have to create additional images if you wanted other colors. The background color can especially be a problem if you're running the application on a machine that uses non-standard system colors.
Hope this helps.
- Elton