关于缩放,我想我设法解决了这个问题。
在MouseNavigation.cs添加新属性
// 2014-02-22 - MPEKALSKI - added property to make possible
limiting on zoom on only one axis
private bool? _zoomX;
/// <summary>
/// Property for allowing/disallowing for zoom along X axis. By default allowed (true).
/// </summary>
public bool zoomX
{
get { return _zoomX ?? true; }
set { _zoomX = value; }
}
private bool? _zoomY;
/// <summary>
/// Property for allowing/disallowing for zoom along Y axis. By default allowed (true).
/// </summary>
public bool zoomY
{
get { return _zoomY ?? true; }
set { _zoomY = value; }
}
在同一个类中修改方法
private void MouseWheelZoom(Point mousePos, int wheelRotationDelta)
通过替换
Viewport.Visible = Viewport.Visible.Zoom(zoomTo, zoomSpeed);
和
// 2014-02-23 - MPEKALSKI - if we do not allow for change in Y
// then keep the old value, by analogy for X
Rect zoomedRect = Viewport.Visible.Zoom(zoomTo, zoomSpeed);
if (zoomY == false) { zoomedRect.Y = Viewport.Visible.Y;
zoomedRect.Height = Viewport.Visible.Height; }
if (zoomX == false) { zoomedRect.X = Viewport.Visible.X;
zoomedRect.Width = Viewport.Visible.Width; }
Viewport.Visible = zoomedRect;
现在使用非常简单,因为 chartPlotter 对象只需将属性 zoomY 或 zoomX 设置为 false 以防止沿此轴缩放。
chartPlotter2.MouseNavigation.zoomY = false;
我不知道它是否是最佳解决方案,但它对我有用。