0

I want to do the zoom in zedgraphcontrol with a button on my form the same zoom that is provided for mouseWheel... I don't know how. I have copied some code from the zedgraph source code but just the zoom out works properly.

when I pass Delta -1 , it shoud zoom out... it works right. but when I pass Delta 1, it shoud zoom in ... but it doesn't. any idea?

    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;
    }

1 Answers1

0

In-order to disable the MouseWheel Zoom Event:

zedGraphControl1.IsEnableWheelZoom = false;

&

Zedgraph comes up with zooming as a default functionality, eg: pan, zoom in, zoom Out, it can be customized according to the requirement.

enter image description here

SanVEE
  • 2,009
  • 5
  • 34
  • 55
  • If you check the type of zoombuttons you can find that it is a mousebutton,but the thing I want is a button on my form. but still tanx for your answer any way. – Seyed Keyvan Kabirnia Jul 25 '13 at 06:36
  • The above shown picture is just a sample, that I was trying to convey that it has all the zoom functionality in default, I dont understand why you want to do with a button?? – SanVEE Jul 25 '13 at 08:41