Z
Zach Nelson
I'm working on a control that simulates a timeline and it supports "zooming"
so you can drill down and get finer detail along the timeline. I accomplish
this by always drawing the same tick marks starting at 0 on the x axis, but
I use Graphics.ScaleTransform(zoomfactorX, 1F) to scale the entire drawing
along the x axis (the y axis remains at 1x magnification).
The problem I'm running into is when you apply a zoom factor of let's say
2X. If there were 100 tick marks at 1X zoom then there should be 50 tick
marks visible at 2X zoom and you should have to scroll to the right to see
the other 50 tick marks.
sidenote: I was using the Autoscroll properties of the Panel object but they
didn't give me enough control and they wouldn't invalidate the panel during
or after the scroll (no scrollstart or scrolling or scrollend events). Also,
the zooming functionality works great, I'm just trying to simulate a scroll
effect.
So on the windows form I have this timeline control and a horizontal scroll
control. My thinking was that each time you zoomed into the timeline, I
could scale the scrollbar's smallchange property according to the zoom
factor, and also shift the entire timeline panel to the left. I'm looking
for a way to offset the X axis to give me this effect.
I tried a rough approach where I scaled the width of the panel by the zoom
factor and also shifted the left property as well. But as the width
increased the entire algorithm slowed down to a crawl because of all the
extra pixels involved.
So I really only want to deal with a drawable area that is say 800 pixels
wide, and then inside that area, draw the timeline, but start drawing
according to the offset on the X axis. I guess what is throwing me off is
the ScaleTransformation. It is behaving as expected but when it scales at 2X
or higher, I need to be able to scroll and see the same range of tick marks
as if it was scaling at 1X.
Does that make sense?
TIA!
Zach
so you can drill down and get finer detail along the timeline. I accomplish
this by always drawing the same tick marks starting at 0 on the x axis, but
I use Graphics.ScaleTransform(zoomfactorX, 1F) to scale the entire drawing
along the x axis (the y axis remains at 1x magnification).
The problem I'm running into is when you apply a zoom factor of let's say
2X. If there were 100 tick marks at 1X zoom then there should be 50 tick
marks visible at 2X zoom and you should have to scroll to the right to see
the other 50 tick marks.
sidenote: I was using the Autoscroll properties of the Panel object but they
didn't give me enough control and they wouldn't invalidate the panel during
or after the scroll (no scrollstart or scrolling or scrollend events). Also,
the zooming functionality works great, I'm just trying to simulate a scroll
effect.
So on the windows form I have this timeline control and a horizontal scroll
control. My thinking was that each time you zoomed into the timeline, I
could scale the scrollbar's smallchange property according to the zoom
factor, and also shift the entire timeline panel to the left. I'm looking
for a way to offset the X axis to give me this effect.
I tried a rough approach where I scaled the width of the panel by the zoom
factor and also shifted the left property as well. But as the width
increased the entire algorithm slowed down to a crawl because of all the
extra pixels involved.
So I really only want to deal with a drawable area that is say 800 pixels
wide, and then inside that area, draw the timeline, but start drawing
according to the offset on the X axis. I guess what is throwing me off is
the ScaleTransformation. It is behaving as expected but when it scales at 2X
or higher, I need to be able to scroll and see the same range of tick marks
as if it was scaling at 1X.
Does that make sense?
TIA!
Zach