我想用我的表单上的一个按钮来放大zedgraphcontrol,这与为mouseWheel提供的缩放相同......我不知道怎么做。我已经从 zedgraph 源代码中复制了一些代码,但只是缩小工作正常。
当我通过 Delta -1 时,它应该缩小......它工作正常。但是当我通过 Delta 1 时,它应该放大......但它没有。任何想法?
private void Zoom(int Delta, int ZoomStepFraction)
{
if ((zedGraphControl1.IsEnableVZoom || zedGraphControl1.IsEnableHZoom) && zedGraphControl1.MasterPane != null)
{
GraphPane pane = zedGraphControl1.GraphPane;
if (pane != null && Delta != 0)
{
PointF centerPoint = new PointF(zedGraphControl1.Size.Width / 2, zedGraphControl1.Size.Height / 2);
double zoomFraction = (1 + (Delta < 0 ? 1.0 : -1.0) * ZoomStepFraction);
zedGraphControl1.ZoomPane(pane, zoomFraction, centerPoint, false);
ApplyToAllPanes(pane);
using (Graphics g = this.CreateGraphics())
{
// always AxisChange() the dragPane
pane.AxisChange(g);
foreach (GraphPane tempPane in zedGraphControl1.MasterPane.PaneList)
{
if (tempPane != pane && (zedGraphControl1.IsSynchronizeXAxes || zedGraphControl1.IsSynchronizeYAxes))
tempPane.AxisChange(g);
}
}
zedGraphControl1.Refresh();
}
}
}
private void ApplyToAllPanes(GraphPane primaryPane)
{
foreach (GraphPane pane in zedGraphControl1.MasterPane.PaneList)
{
if (pane != primaryPane)
{
if (zedGraphControl1.IsSynchronizeXAxes)
Synchronize(primaryPane.XAxis, pane.XAxis);
if (zedGraphControl1.IsSynchronizeYAxes)
Synchronize(primaryPane.YAxis, pane.YAxis);
}
}
}
private void Synchronize(Axis source, Axis dest)
{
dest.Scale.Min = source.Scale.Min;
dest.Scale.Max = source.Scale.Max;
dest.Scale.MajorStep = source.Scale.MajorStep;
dest.Scale.MinorStep = source.Scale.MinorStep;
dest.Scale.MinAuto = source.Scale.MinAuto;
dest.Scale.MaxAuto = source.Scale.MaxAuto;
dest.Scale.MajorStepAuto = source.Scale.MajorStepAuto;
dest.Scale.MinorStepAuto = source.Scale.MinorStepAuto;
}