Changing zooming center

I want to zoom the selected area in such a way that the center of the selected area should become the zooming center instead of using center of the entire document.



Can anybody tell me how to do it?

PointF oldpos = goView1.DocPosition; PointF focus = ...; goView1.DocScale *= ...; goView1.DocPosition = new PointF(oldpos.X + evt.DocPoint.X - focus.X, oldpos.Y + evt.DocPoint.Y - focus.Y);

Thanks a lot.

but could you explain the solution? What is focus, evt etc?

Sorry about that – I was just trying to show you what GoView.DoWheel does for control-wheel-rotation:

PointF oldpos = this.DocPosition; this.DocScale *= (1 + ((float)evt.Delta)/2400); PointF focus = ConvertViewToDoc(evt.ViewPoint); this.DocPosition = new PointF(oldpos.X + evt.DocPoint.X - focus.X, oldpos.Y + evt.DocPoint.Y - focus.Y);
So evt is the GoInputEventArgs describing where the mouse is at the time of the wheel turn. evt.DocPoint is the document point before changing the scale; focus is the document point for the same mouse view point after changing the scale. That’s what shifts the GoView.DocPosition appropriately so that the mouse point is a “fixed point” for the operation.

oh ok…but sorry I am confused.

how this will help in calculating the center point for the selected area and zooming around that calculated center point.

Presumably you know how to calculate the center of your area, a RectangleF in document coordinates.

GoView.DoWheel does the same thing you want, but is given the mouse point via the GoInputEventArgs. I assumed if I gave you that code, you would figure out what it does and how, and you then could adapt it for your own purposes.