The DocPosition problems

Hello!

Today I have found one more bug in my application. I have overrided the DoRubberBand function in my custom GoToolRubberBanding to zoom the selection. Everything works excelent on the initially opened document. The tool zooms well. But if I create a new document or load some saved document, it starts working very strangely. The view's DocScale attribute is set nicely, but the DocPosition is set sometimes (the first few times) to the (0, 0), and then starts setting it to some strange values. I think the reason for the problem is that I assign the new document to the view every time I load or create a new document. I do this because my custom GoDocument has some extra structure, that has the easyest way to reset it by creating the new doc. This is my overided function:
if (View.LastInput.Control) {
float xScale = ((float)View.ClientSize.Height * View.DocScale) / (float)box.Height; float yScale = ((float)View.ClientSize.Width * View.DocScale) / (float)box.Width; float newScale = Math.Min(xScale, yScale); View.DocPosition = new PointF(box.Left, box.Top); View.DocScale = newScale;
} else base.DoRubberBand(box);
This is in my initialization form:
goView1.Tool = goView1.DefaultTool = new Manager(goView1);
In the debug mode I have noticed that the box has correct coordinates, but the assigninig the new PointF does not assign the value properly. Do you have any idea how to fix this behaviour?

Any reason why you aren’t just replacing the rubberband tool?

myView.ReplaceMouseTool(typeof(GoToolRubberBanding), new GoToolZooming(myView));

I must apologize, I have copied the wrong line. You are right, that’s exactly how I initialized it:

goView1.ReplaceMouseTool(typeof(GoToolRubberBanding), new RubberBanding(goView1));
The problem is still present. Have you got any idea how to solve it? Thank you.

Check your View.LimitDocPosition value then.