In my application, I have a constraint, that zooming should be done only horizontally not vertically.Because I have a fixed hight of Y axis, which is always current visible area of the screen. But X axis grows, as per data according to y axis.
In our application, the requirement is to only zoom the x coordinates (distance b/w objects), not the size of the objects.
So I am redrawing the whole x axis with changed zoom factor, which is taken from an input box in my application.But problem is with horizontal scroll bar position.
As per the requirement, when changing the zoom factor the current time position (X axis) should be kept.
You can refer the screen shots:
1. When zoom is 150%, then horizontal scrolbar is b/w 9:30 - 11:00
2. When zoom is changed to 200%, then horizontal scrolbar is b/w 8:30 - 09:30, which should be kept b/w 9:30 - 11:00
Please provide me some hint to resolve this issue. It's very urgent.
Say your Document width goes from 1500 to 2000 when you go from scale from 150% to 200%. so, if you were scrolled 10% in before, the left edge of the view was 150. After the zoom, to maintain the same left edge, you want it to be 200.
So, you need to scroll to maintain the same “visual” position.
(now, my numbers were all made up, but you should be able to figure out the math.)
GoView.DocPosition will give you the TopLeft of the GoView in Document coordinates. You need to read that Position, scale it and then set it.
Do you re-compute & set the Bounds of the Document in the missing code? By default, Documents will get larger to fit new objects, but they don’t shrink unless you force them.
Hi,
Yes, whenever there is any zoom event, I clear all existing view’s data & set its size to 0 as:
View.Document.Clear();
View.Document.Size = new SizeF(0.0F, 0.0F);
Then I reload all data again.
Note:
When I zoom from lower to higher value, then View.DocumentSize.Width value increases accordingly.
When I zoom from higher to lower value, then View.DocumentSize.Width value decreases accordingly.
If you look at the blue line, where it intersects with the y axis just under HAFR(2), it looks identical, because we don't zoom the y axis.
But problem is with x axis, horizontal axis.
You can easily see the difference b/w both images.
Anyhow if there is any chance to improvement in this regard, then please let me know, otherwise we would keep this solution as it is in our application.
Yes, you are right.This is due to zoom from 600% to 800%.
But my query is different that after zoom, scollbar should be shifted accordingly.Means my x location (before zoom & after zoom) should be shifted according to zoom, which is quite better than earlier after implementing your approach. But not perfect.
I think it’s right. The scrollbar size changes… you are seeing a smaller % of the entire document, so that makes sense. But the leftmost position of the view into the document stays the same… so the % of how far you are scrolled stays the same.
In other words… the point where the blue line intersects the vertical by HAFR(2) is about 40% across the document. Changing the zoom level doesn’t change that … it is still 40% to that point. and the left side of the scroll bar is reflecting that.