4,816
社区成员
发帖
与我相关
我的任务
分享
/*画图委托*/
public delegate void DrawingChart(List<int> point);
//模拟数据接收 类RevDetectionSoket
public event Global.DrawingChart drawingChart; //画图委托事件
public void testDrawing() //模拟接收数据触发事件
{
Random r = new Random();
while (true)
{
lock (loker)
{
int point = r.Next(90, 100);
drawingChart (new List<int>{ i++, point }); //触发画图事件(绘制一个点i为x,point为y)
Thread.Sleep(20);
}
}
}
//显示数据类型
public ChartSimple(RevDetectionSoket revDetectionSoket)
{
InitializeComponent();
this.revDetectionSoket = revDetectionSoket;
revDetectionSoket.drawingChart += DrawingChart; //关联事件
}
private void DrawingChart(List<int> point)
{
chart1.Series[0].Points.AddXY(point[0],point[1]); //添加一个点
}