int MarkerY = Convert.ToInt32(data.FirstOrDefault(m => m.x == markerX).y);
Point curPos = chart.PointToScreen(chart.DataToPoint(new Point(markerX, MarkerY)));
SetCursorPos(Convert.ToInt32(curPos.X), Convert.ToInt32(curPos.Y));
//模拟鼠标左键按下
const int MOUSEEVENTF_LEFTDOWN = 0x0002;
//模拟鼠标左键抬起
const int MOUSEEVENTF_LEFTUP = 0x0004;
//标示是否采用绝对坐标
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(curPos.X), Convert.ToInt32(curPos.Y), 0, 0);
我保存lineMarker的x值,获取chart中对应的(x,y),通过chart.DataPoint获取变化后坐标,再通过chart.pointToScreen获取变化后在屏幕中的坐标,最后模拟鼠标点击事件!这样哪里不对吗?还是无法实现 |