2

I am trying to use Kitware ActiViz.NET. I have installed it using nuget. But I can't seem to find RenderWindowControl on the toolbox. I have been trying to add it manually this way:

  • invoke "Choose Items..."

  • and in the following dialog click on button "Browse...",

  • navigate to your ActiViz.NET installation folder, browse to /bin folder, select "Kitware.VTK.dll".

  • Click OK.

Now you should see in your ToolBox a new control named RenderWindowControl. But I get "The file "C:\programfiles\activiz.net 5.8.0 Opensource Eddition\bin\kitware.vtk.DLL" is not valid".

I have tried to add the control in the code rether than the designer,and got this exception: Could not load file or assembly 'Kitware.VTK, Version=5.8.0.607, Culture=neutral, PublicKeyToken=995c7fb9db2c1b44' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Has anyone had this problem before? Any ideas?

tal
  • 525
  • 2
  • 8
  • 26

3 Answers3

4

For the design mode you would need to use the 32Bit version, because VS is running on 32Bit and can only load 32Bit controls. So you could use for design time the 32Bit version and for build/release switch to the 64bit version.

But you can also add the RenderWindowControl manually. Of course the designer will be unable to display this, so it would be necessary to comment it out, before switching to the designer

Open your designer file e.g. Form1.Designer.cs and add the control like

private RenderWindowControl myRenderWindowControl;

private void InitalizeComponent()
{
    //all other controls added by the designer

    myRenderWindowControl = new RenderWindowControl();
    myRenderWindowControl.SetBounds(0,0,640,480);
    this.Controls.Add(this.myRenderWindowControl);
}
JohnnyQ
  • 1,591
  • 1
  • 16
  • 25
  • the 32 bit vesrion downlad ` https://www.nuget.org/packages/Activiz.NET.x86` , than use `Invoke "Choose Items..." and in the following dialog click on button "Browse...", navigate to your ActiViz.NET installation folder, browse to /bin folder, select "Kitware.VTK.dll". Click OK.` – 張正軒 Jul 06 '22 at 07:46
1

Adding VTK's RenderWindowControl to WPF is a little more complicated. Assuming you installed a 64 bit VTK package, the following steps worked for me.

https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf

  • Add Project References to WindowsFormsIntegration and System.Windows.Forms
  • Draw a Grid on the Designer Form.
  • In Properties Dialog, Give it a name, then
  • Double Click the Loaded event.
  • In the loaded event handler add the code.
  // Create the interop host control.
  System.Windows.Forms.Integration.WindowsFormsHost host =
  new System.Windows.Forms.Integration.WindowsFormsHost();
  myRenderWindowControl = new RenderWindowControl();
  myRenderWindowControl.SetBounds(0, 0, 30, 30); // not too big in case it disappears.
  // Assign the control as the host control's child.
  host.Child = myRenderWindowControl;
  this.VTKGrid.Children.Add(host);
intotecho
  • 4,925
  • 3
  • 39
  • 54
0

The instructions on the VTK website are outdated. If you are using Visual Studio 2022 or similar, then most of the work will be automatically done for you behind the scenes. Install it as follows:

-Open Tools > Nuget Package Manager > Manage Nuget packages for solution.

-Select the install tab, and search for Activiz.net. Install Activiz.net.x64 or Activiz.net.x86. All the tools will automatically be added to the toolbox.

If you are using the 64 bit library, you also need to change the configuration or it will throw an exception at InitializeComponent(); To fix it:

-In the solution explorer window, right click on the solution and select Configuration Manager.

-Under "Active solution platform" choose "<New...>" and then set it x64 and copy Any CPU settings.

-Back in the configuration manager, change Platform from "Any CPU" to your new "x64" configuration.

Everything should now be working perfectly.

Blake
  • 1
  • 2