当加载到matlab中时,Ilnumerics Ilpanel在winform中编译成dll时不会激活

我想在visual-studio 2012中将用c#编写的winform编译成一个dll然后加载到matlab 2013a中。 使用matlab .net接口,然后我想与winform交互,听取它的事件并通过一组预定义的公共方法传递数据。 我正在使用Windows 7 Ultimate SP2。

这非常好用,我可以与所有本机winform工具,按钮,树,面板甚至图表进行交互。 但是我想使用ILnumerics,特别是用于显示包含所有奇迹的“场景”的ILpanel。 这是因为当它被编译为dll并调用到matlab时,我在IPanel中没有渲染任何东西。 它只显示默认的椭圆形。

我可以将matlab作为一个过程添加到visual studio中并运行代码。 一切都很好。 看起来第32行的场景未正确连接到iLPanel1。

任何帮助,将不胜感激。

没有form1.Designer.cs的Form1.cs主要c#代码

using System; using System.Windows.Forms; using ILNumerics; using ILNumerics.Drawing.Plotting; using ILNumerics.Drawing; using MarkerStyle = ILNumerics.Drawing.MarkerStyle; namespace WindowsFormsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void PlotData(double[,] myX) { var myDoubleVec = new double[myX.Length]; for (int i = 0; i < myX.Length; i++) { myDoubleVec[i] = myX[i, 0]; } var scene = new ILScene(); ILArray myNumX = myDoubleVec; scene.Add(new ILPlotCube { new ILLinePlot(ILMath.tosingle(myNumX.T), markerStyle: MarkerStyle.Dot) }); ilPanel1.Scene = scene; } private void ilPanel1_Load_1(object sender, EventArgs e) { var myDouble = new double[,] { { 2 }, { 4 }, {9 }, { 16 } }; ; PlotData(myDouble); } public void PlotRandom() { double yValue = 50.0; double yValue2 = 200.0; if (chart1.Series["Series1"].Points.Count > 0) { yValue = chart1.Series["Series1"].Points[chart1.Series["Series1"].Points.Count - 1].YValues[0]; yValue2 = chart1.Series["Series2"].Points[chart1.Series["Series1"].Points.Count - 1].YValues[0]; } Random random = new Random(); for (int pointIndex = 0; pointIndex < 50; pointIndex++) { yValue = yValue + (float)(random.NextDouble() * 10.0 - 5.0); chart1.Series["Series1"].Points.AddY(yValue); yValue2 = yValue2 + (float)(random.NextDouble() * 10.0 - 5.0); chart1.Series["Series2"].Points.AddY(yValue2); } } private void button1_Click(object sender, EventArgs e) { PlotRandom(); } private void button2_Click(object sender, EventArgs e) { var myDouble = new double[,] { { 2 }, { 4 }, { 6 }, { 8 } }; ; PlotData(myDouble); } } } 

得到的winform如下所示。 包含Windows图表的Winform

用于加载程序集和操作表单的Matlab代码。

  NET.addAssembly('C:\Users\philliproso\Documents\Visual Studio 2012\Projects\WindowsFormsApplication3\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.dll') myForm=WindowsFormsApplication3.Form1; myForm.Show; myForm.plotRandom; %this call works fine myForm.PlotData(rand(50,1)); %this call has no effect 

在matlab中获得winform