DocExtentSize override

I am overriding DocExtentSize in GoView to prevent the view from showing anything outside the (fixed size) document:

return new SizeF(
Math.Min(base.DocExtentSize.Width, Document.Size.Width),
Math.Min(base.DocExtentSize.Height,Document.Size.Height));

This works, except that when zoomed out far enough, a border of in my case 96 width and height (document coordinates) gets added to right and bottom of the actual document boundary.
If I use:
return new SizeF(
Math.Min(base.DocExtentSize.Width, Document.Size.Width - 96.0f),
Math.Min(base.DocExtentSize.Height, Document.Size.Height - 96.0f));
the document is bounded perfectly in the view, with just white space outside of the document boundaries.
The SheetStyle is None, all the sheet margins etc. are 0 and the document position is also 0.
Why do I have to subtract an offset, and how can I compute or obtain the required value in a proper way, or avoid it altogether ?

I don’t understand why you are overriding any GoView properties or methods for this. If you just set GoView.ShowsNegativeCoordinates to false, set GoView.Document.FixedSize to true, and set the GoView.Document.Size to the desired value, everything should work as I think you want it.

Note that if the document size is small enough, combined with a GoView.DocScale that is small enough, the user could see outside of the document's bounds. If you want to avoid this, you'll need to override GoView.LimitDocScale to make sure the new GoView.DocScale value will prevent that, according to whatever guidelines you wish.

I already have that part working.

I am overriding DocExtentSize to prevent the grid to get drawn outside of the document bounds.
I don't want to suggest to the user that this region is valid in any way.
If the entire document is visible in the view, but the aspect ratio of the view is not the same as that of the document, there will be a region in the view that is empty; i.e. where the document does not extend to.
In this case , the DocExtentSize is larger than the document size in at least one direction.
The view does display the grid in that region, however, whichis what I want to prevent.
By limiting the DocExtentSize to the document size, no grid gets drawn in the region outside the document, but I have to include an offset of 96 in document coordinates to prevent a thin border to the right and/or bottom of the document to show.
My question is: why the offset, can I get rid of it, or if not do I need to calculate it in a less ad hoc way ?

Ah, so you just want to limit the size of the GoView.Grid.

Well, that's easy enough -- just do:
[code] goView1.Grid.UnboundedSpots = 0;
goView1.Grid.Bounds = goView1.Document.Bounds;[/code]
Again, I don't think you need to override any GoView properties or methods.

Thanks, that works really well.

Another reason for the DocExtentSize override is to avoid GoOverview to resize for irrelevant space (i.e. space outside the document).
Do you have any recommendations on that ?

I just tried this, and it works the way I would expect.

Could you describe in more detail what you would expect?

Everything works as expected indeed, except for the apparent offset (of 96) between the drawing in the view and the document size.

Now that the DocExtentSize override is only used for avoiding unwanted resizing of the GoOverview, the offset is not that important anymore, although I'm still curious about its origins.

Perhaps that depends on when you look at the original (base) value of GoView.DocExtentSize. If you look at it at a time that there are scrollbars, and if the GoView.DocScale is 0.25 (?? or something like that), then I could imagine that the discrepancy of 96 is caused by the size of the scrollbars that later disappeared.

Just guessing....