1
我正在使用Zedgraph創建股票圖表應用程序。該圖表有多個指標面板。我想顯示一個十字光標,該光標延伸到包含所有圖形窗格的Zedgraph控件的範圍。我使用下面的代碼和MouseMove事件完成了一半的工作。但是,當鼠標停止移動時,十字準線消失。當鼠標靜止時,我如何讓它們顯示?我的Zedgraph控件在下面的代碼中被命名爲'chtOHLC'。如何在Zedgraph中繪製延長的十字光標,當鼠標未移動時該光標持續存在?
#region Extended Crosshairs
private Point _mousePoint;
private void chtOHLC_MouseMove(object sender, MouseEventArgs e)
{
_mousePoint = new Point(e.X, e.Y);
chtOHLC.Refresh();
}
private void chtOHLC_Paint(object sender, PaintEventArgs e)
{
if (_mousePoint != null)
{
Graphics g = chtOHLC.CreateGraphics();
g.DrawLine(Pens.Black, 0, _mousePoint.Y, chtOHLC.Width, _mousePoint.Y);
g.DrawLine(Pens.Black, _mousePoint.X, 0, _mousePoint.X, chtOHLC.Height);
g.Dispose();
}
}
#endregion