Adding RenderWindowControl to tool box

Deadly 提交于 2021-02-19 07:31:39

问题


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?


回答1:


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);
}



回答2:


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://docs.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);


来源:https://stackoverflow.com/questions/32629232/adding-renderwindowcontrol-to-tool-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!