1
WindowsFormsHost를 사용하여 WPF 앱에서 라이브 데이터를 플롯하기 위해 ILLinePlot을 사용하려고합니다. 나는이 두 가지 질문에 기초하여 시작했다 : ILScene in WindowsFormsHost & ILNumeric continuous rendering plots.ILScene이 WindowsFormsHost에서 업데이트되지 않습니다.
내 코드는 다음과 같습니다
XAML :
<Window x:Class="Pulse_Generator.MainWindow"
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="MainWindow" Height="350" Width="525"
Loaded="ILView_OnLoaded">
<Grid Name="grid1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<forms:WindowsFormsHost x:Name="WindowsFormsHost" Margin="5" />
</Grid>
</Window>
C 번호 :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private ILPanel ilPanel;
private void IlPanelOnLoad(object sender, EventArgs eventArgs)
{
using (ILScope.Enter())
{
// generate some dummy data
int N = 50000;
ILArray<float> x = ILMath.vec<float>(0, N-1);
ILArray<float> y = ILMath.tosingle(ILMath.rand(N));
ILArray<float> A = ILMath.zeros<float>(2, N);
A["0;:"] = x;
A["1;:"] = y;
ilPanel.Scene.Add(new ILPlotCube(){
new ILLinePlot(A)
});
ilPanel.BeginRenderFrame += (o, args) =>
{
using (ILScope.Enter())
{
var linePlot = ilPanel.Scene.First<ILLinePlot>();
var posBuffer = linePlot.Line.Positions;
ILArray<float> data = posBuffer.Storage;
// update the plot with some new dummy data
data["1;:"] = ILMath.tosingle(ILMath.randn(1, posBuffer.DataCount));
linePlot.Line.Positions.Update(data);
ilPanel.Scene.First<ILPlotCube>().Reset();
linePlot.Configure();
}
};
// start running
ilPanel.Clock.TimeMilliseconds = 15;
ilPanel.Clock.Running = true;
}
}
private void ILView_OnLoaded(object sender, RoutedEventArgs e)
{
ilPanel = new ILPanel();
ilPanel.Load += IlPanelOnLoad;
WindowsFormsHost.Child = ilPanel;
}
}
문제는 그 줄거리는 업데이트 (그리고 BeginRenderFrame에만 트리거 될 나타납니다)가있는 경우 플롯에서 마우스 상호 작용 (클릭/끌기/스크롤) 또는 창 크기가 조정됩니다.
아마 이것은 WindowsFormsHost에서 시계가 제대로 실행되지 않기 때문입니까?