NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Teststand OI in WPF?

Hi,

 

I'm wondering is there any chance to build the TSOI usinx WPF (XAML)?

 

When I referenced API dlls as they are referenced in the Windows form application I couldn't see the TS API controls in the Toolbox of VS2012.

 

(TS2013)

0 Kudos
Message 1 of 11
(6,587 Views)

Hi MimiKLM,

 

I'd like to help you out if possible but unfortunately I'm having a little trouble wading through the acronyms. Is there any chance you could clarify exactly what you're trying to do and where you are having a problem?

 

If you can break it down a little I can hopefully point you in the right direction.

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 2 of 11
(6,557 Views)

It's possible, but a little tricky. You might be better off starting with one of our Windows Forms UIs and using the WPF Host control to host any WPF controls you also want to use. That said, if you want to go the more complicated route you can do the following:

 

1 - Add references to your project for all of the TestStand interop assemblies and set them to NOT embed interop types in the properties pane.

 

2 - Add a WindowsFormsHost for each TestStand control you want to use on your panel (You'll at least need one for the application manager)

 

3 - Add a Loaded event handler for the main window of your WPF application.

 

4 - here is an example of creating the applicationmgr control in such a case. though this is really just the beginning of creating a UI. there is a lot more work required.

 

        private NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr mAppMgr;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mAppMgr = new NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr();
            this.windowsFormsHost1.Child = mAppMgr;

            mAppMgr.Start();
        }

Hope this helps,

-Doug

0 Kudos
Message 3 of 11
(6,552 Views)

Thanks a lot Doug

 

I've modified some of that code by adding the one line 

this.grid1.Children.Add(host);)

to your function:

 

private NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr mAppMgr;
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
            mAppMgr = new NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr();
            host.Child = mAppMgr;
            this.grid1.Children.Add(host);
            mAppMgr.Start();
        }

 

I had a successful build but I've seen a warning shown below:

 

A reference was created to embedded interop assembly 'c:\Program Files\National Instruments\TestStand 2013\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.API.dll' because of an indirect reference to that assembly created by assembly 'c:\Program Files\National Instruments\TestStand 2013\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.UI.AxControls.dll'. Consider changing the 'Embed Interop Types' property on either assembly.            

 

What’s that?

 

0 Kudos
Message 4 of 11
(6,501 Views)

I understand thet warnings are more informational, and are not 'dangerous'.

 

BTW: How manu hosts shall I have? One for whole application or one for each control?

0 Kudos
Message 5 of 11
(6,491 Views)

@MimiKLM wrote:

Thanks a lot Doug

 

I've modified some of that code by adding the one line 

this.grid1.Children.Add(host);)

to your function:

 

private NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr mAppMgr;
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
            mAppMgr = new NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr();
            host.Child = mAppMgr;
            this.grid1.Children.Add(host);
            mAppMgr.Start();
        }

 

I had a successful build but I've seen a warning shown below:

 

A reference was created to embedded interop assembly 'c:\Program Files\National Instruments\TestStand 2013\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.API.dll' because of an indirect reference to that assembly created by assembly 'c:\Program Files\National Instruments\TestStand 2013\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.UI.AxControls.dll'. Consider changing the 'Embed Interop Types' property on either assembly.            

 

What’s that?

 


I used the designer to add the Windows Forms Host control so I did not need the line you added. You should change the settings (properties page for assembly references) to not embed interops for any of the TestStand assemblies. They are all already in the GAC and the embed feature does not work with enums so could lead to problems in the future.

 

-Doug

0 Kudos
Message 6 of 11
(6,486 Views)

@MimiKLM wrote:

I understand thet warnings are more informational, and are not 'dangerous'.

 

BTW: How manu hosts shall I have? One for whole application or one for each control?


I think you are supposed to use one per control. You could theoretically add all of the activex controls on a Form control and then add the form to a single Windows Forms Host control, but I think you are generally supposed to use a separate host for each control instead. I'm not sure though. Feel free to look at Microsoft's documentation on MSDN to see what they recommend.

 

-Doug

0 Kudos
Message 7 of 11
(6,484 Views)

Dug,

 

I set the Embed Interop Types to false. It's fine now.

 

I did expect some objects to appear on the XAML application window (as on the windows form app) but they didn't. I did created SequenceFiele View Manager and ExecutionViewManager, but they didn't appear on the main window.

0 Kudos
Message 8 of 11
(6,477 Views)

@MimiKLM wrote:

Dug,

 

I set the Embed Interop Types to false. It's fine now.

 

I did expect some objects to appear on the XAML application window (as on the windows form app) but they didn't. I did created SequenceFiele View Manager and ExecutionViewManager, but they didn't appear on the main window.


Hmm, you might be better off creating the Windows Forms Host controls in the designer like I did, otherwise you probably have to set their size, location and visibility programmatically.

 

-Doug

0 Kudos
Message 9 of 11
(6,469 Views)

Hi Doug,

 

Any chance you could give me more indications how to do next step?

 

How to create them in designer?

 

K.

0 Kudos
Message 10 of 11
(5,566 Views)