将 RenderWindowControl 添加到工具箱
Adding RenderWindowControl to tool box
我正在尝试使用 Kitware ActiViz.NET。我已经使用 nuget 安装了它。
但我似乎无法在工具箱上找到 RenderWindowControl。我一直在尝试以这种方式手动添加它:
调用"Choose Items..."
并在以下对话框中单击按钮 "Browse..."、
导航到您的 ActiViz.NET 安装文件夹,浏览到 /bin
文件夹,select"Kitware.VTK.dll".
单击确定。
现在您应该在您的工具箱中看到一个名为 RenderWindowControl 的新控件。
但是我得到 "The file "C:\programfiles\activiz.net 5.8.0 Opensource Eddition\bin\kitware.vtk.DLL" is not valid".
我试过在代码中添加控件而不是设计器,但得到了这个异常:
无法加载文件或程序集 'Kitware.VTK, Version=5.8.0.607, Culture=neutral, PublicKeyToken=995c7fb9db2c1b44' 或其依赖项之一。试图加载格式不正确的程序。
以前有人遇到过这个问题吗?
有什么想法吗?
设计模式需要使用32位版本,因为VS是运行32位的,只能加载32位控件。
因此,您可以在设计时使用 32 位版本,并且 build/release 切换到 64 位版本。
但您也可以手动添加 RenderWindowControl
。
当然设计者将无法显示这个,所以它会是
有必要在切换到设计器之前将其注释掉
打开您的设计器文件,例如Form1.Designer.cs 并添加控件
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);
}
将 VTK 的 RenderWindowControl 添加到 WPF 中稍微复杂一些。
假设您安装了 64 位 VTK 包,以下步骤对我有用。
- 将项目引用添加到 WindowsFormsIntegration 和 System.Windows.Forms
- 在设计器窗体上绘制网格。
- 在“属性”对话框中,为其命名,然后
- 双击 Loaded 事件。
- 在加载的事件处理程序中添加代码。
// 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);
我正在尝试使用 Kitware ActiViz.NET。我已经使用 nuget 安装了它。 但我似乎无法在工具箱上找到 RenderWindowControl。我一直在尝试以这种方式手动添加它:
调用"Choose Items..."
并在以下对话框中单击按钮 "Browse..."、
导航到您的 ActiViz.NET 安装文件夹,浏览到 /bin 文件夹,select"Kitware.VTK.dll".
单击确定。
现在您应该在您的工具箱中看到一个名为 RenderWindowControl 的新控件。 但是我得到 "The file "C:\programfiles\activiz.net 5.8.0 Opensource Eddition\bin\kitware.vtk.DLL" is not valid".
我试过在代码中添加控件而不是设计器,但得到了这个异常: 无法加载文件或程序集 'Kitware.VTK, Version=5.8.0.607, Culture=neutral, PublicKeyToken=995c7fb9db2c1b44' 或其依赖项之一。试图加载格式不正确的程序。
以前有人遇到过这个问题吗? 有什么想法吗?
设计模式需要使用32位版本,因为VS是运行32位的,只能加载32位控件。 因此,您可以在设计时使用 32 位版本,并且 build/release 切换到 64 位版本。
但您也可以手动添加 RenderWindowControl
。
当然设计者将无法显示这个,所以它会是
有必要在切换到设计器之前将其注释掉
打开您的设计器文件,例如Form1.Designer.cs 并添加控件
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);
}
将 VTK 的 RenderWindowControl 添加到 WPF 中稍微复杂一些。 假设您安装了 64 位 VTK 包,以下步骤对我有用。
- 将项目引用添加到 WindowsFormsIntegration 和 System.Windows.Forms
- 在设计器窗体上绘制网格。
- 在“属性”对话框中,为其命名,然后
- 双击 Loaded 事件。
- 在加载的事件处理程序中添加代码。
// 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);