WPF の WindowsFormsHost コントロールで ILPanel をホストしようとしています。これが私のコードです:
XAML:
<Window x:Class="ILNumericsCharacteristicViewer.ILView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:forms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Title="ILView"
Width="300"
Height="300"
Loaded="ILView_OnLoaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<forms:WindowsFormsHost x:Name="WindowsFormsHost" Margin="5" />
<Button x:Name="ButtonClose"
Grid.Row="1"
HorizontalAlignment="Right"
Click="ButtonClose_OnClick"
Content="Close" />
</Grid>
コードビハインド:
public partial class ILView : Window
{
private ILPanel ilPanel;
public ILView()
{
InitializeComponent();
}
private void IlPanelOnLoad(object sender, EventArgs eventArgs)
{
ILArray<float> A = ILMath.tosingle(ILMath.rand(3, 10000));
var scene = new ILScene {
new ILPlotCube(twoDMode: false) {
new ILPoints {
Positions = A,
Color = null,
Colors = A,
Size = 2,
}
}
};
var pcsm = scene.First<ILPlotCube>().ScaleModes;
pcsm.XAxisScale = AxisScale.Logarithmic;
pcsm.YAxisScale = AxisScale.Logarithmic;
pcsm.ZAxisScale = AxisScale.Logarithmic;
ilPanel.Scene = scene;
}
private void ButtonClose_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void ILView_OnLoaded(object sender, RoutedEventArgs e)
{
ilPanel = new ILPanel();
ilPanel.Load += IlPanelOnLoad;
WindowsFormsHost.Child = ilPanel;
}
}
この行WindowsFormsHost.Child = ilPanel;
は、「パラメーターが無効です」という引数例外をスローします。スタックトレース:
System.Drawing.Bitmap..ctor(Int32幅、Int32高さ、PixelFormat形式)でILNumerics.Drawing.ILBackBuffer.set_Rectangle(長方形値)でILNumerics.Drawing.ILGDIDriver.set_Size(サイズ値)でILNumerics.Drawing.ILOGLControlで。 OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System .Windows.Forms.Control.UpdateBounds() で System.Windows.Forms.Control.WmWindowPosChanged(Message& m) で System.Windows.Forms.Control.WndProc(Message& m) で System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr) hWnd、Int32 msg、IntPtr wparam、IntPtr lparam)