Zedgraph:如何从 ZoomEvent 取消缩放?

Zedgraph: How can I cancel a Zoom from ZoomEvent?

我想让用户能够在图表上单击并拖动到 select 该区域中的点。

我认为一个好的方法是使用 ZoomEvent,因为 newState 参数给出了缩放区域,我可以简单地 select 中的点那个区域。有没有办法可以访问 newState 中的值,然后取消缩放?我可以强制它返回 oldState 吗?

private void trendGraphControl_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
{
    if (newState.Type == ZoomState.StateType.Zoom) {
        selectPointsInArea(newState);

        // How can I disable this zoom??
    }
}

实际上,我在 newState 中需要的缩放区域信息是私有的。解决方案是在按下鼠标时保存之前的缩放值,然后在缩放事件中检查新的缩放值,然后再将它们重置为之前的值。

double last_x_max, last_x_min, last_y_max, last_y_min;

private bool trendGraphControl_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
{
    // Save the zoom values
    last_x_max = sender.GraphPane.XAxis.Scale.Max;
    last_x_min = sender.GraphPane.XAxis.Scale.Min;
    last_y_max = sender.GraphPane.YAxis.Scale.Max;
    last_y_min = sender.GraphPane.YAxis.Scale.Min;
    return false;
}

private void trendGraphControl_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
{
    if (newState.Type == ZoomState.StateType.Zoom) {
        double new_x_max = sender.GraphPane.XAxis.Scale.Max;
        double new_x_min = sender.GraphPane.XAxis.Scale.Min;
        double new_y_max = sender.GraphPane.YAxis.Scale.Max;
        double new_y_min = sender.GraphPane.YAxis.Scale.Min;
        selectPointsInArea(new_x_max, new_x_min, new_y_max, new_y_min);
        sender.GraphPane.XAxis.Scale.Max = last_x_max;
        sender.GraphPane.XAxis.Scale.Min = last_x_min;
        sender.GraphPane.YAxis.Scale.Max = last_y_max;
        sender.GraphPane.YAxis.Scale.Min = last_y_min;
    }
}

感谢 Ramankingdom 的评论让我指明了正确的方向。