R
Rune Jacobsen
Hi all,
I have a few questions on deriving from ScrollableControl that I hope
will be relatively easy to answer. I am using Visual Studio 2003, C# and
..Net 1.1.
I have this custom control I am making called ResourceView. It is
supposed to show a visual overview of resource usage over time. Time is
represented by the X axis, and the different resources (people,
equipment, rooms etc.) are in the Y axis. Usually one will view a
limited amount of resources (a logical group/unit for instance) and time
(a 24 hour period) at once, but it will be possible to display all
resources for an entire time period - this will naturally lead to a
large amount of items.
Currently I have one control which is made up of three ScrollableControl
objects (extended slightly to allow me to manually control scroll
positions and also set scroll positions) - on the top is the time ruler,
on the left is the vertical resource list, and the rest (except for the
empty top left corner) is occupied by the actual view. The view is
currently a large canvas where I paint the resource "events" as square
boxes that visually give you an idea how long they last and when they
start in relation to other resource events. Each of these boxes is
actually inside another control (one per resource) that spans the length
of the view and contains all the events of a single resource - I call
these ResourceStrips for now.
When you scroll the view horizontally, the time ruler is also made to
scroll the same amount of pixels, so that the events and their place in
time lines ut properly. Likewise, when the view is scrolled vertically,
the resource list on the left is manually scrolled to keep up.
So far, all is good. I put my ResourceView into a form and dock it to
fill the entire thing. In the controls' OnResize I manually resize the
time (top) and resource (left) controls to keep up - the built in
docking functionality does not work the way I need it to. So the control
resizes beautifully and it all seems relative light on resources.
However, there are a few issues (and finally he gets to the point..?);
1) When I resize the window, the scrollbars on the top and left controls
flash on and off; This seems to happen in the ScrollableControl OnLayout
method, but I am not sure. Can I get rid of this? If I override OnLayout
and don't let it call base.OnLayout(), it stops flashing but it also
stops doing much of anything else, including scrolling.
2) If I click in the main view, it will reset to horizontal position
zero, and scroll vertically so the entire "resource row" (i.e.
ResourceStrip control) is in view. I am guessing this is due to some
sort of EnsureVisible() thing on the ResourceStrip? I think it is worth
nothing that the scroll reset occurs on mousedown - it doesn't wait for
me to release the mouse button. Is this a focus thing? And more
importantly, can I get rid of it?
3) Currently, each resource event (i.e. the square boxes that make up
the contents of the ResourceStrips) is simply painted on - they are not
controls. These controls could get quite heavy, in theory 500-1000
events in one view. I will need these to react to clicks and mouseovers.
Is it better to create these as individual lightweight controls? Or
should I keep painting them as graphics on the ResourceStrips.
I hope some friendly soul can shed some light on this as my head is
almost out of hair..
Thank you very much in advance for the help!
Rune
I have a few questions on deriving from ScrollableControl that I hope
will be relatively easy to answer. I am using Visual Studio 2003, C# and
..Net 1.1.
I have this custom control I am making called ResourceView. It is
supposed to show a visual overview of resource usage over time. Time is
represented by the X axis, and the different resources (people,
equipment, rooms etc.) are in the Y axis. Usually one will view a
limited amount of resources (a logical group/unit for instance) and time
(a 24 hour period) at once, but it will be possible to display all
resources for an entire time period - this will naturally lead to a
large amount of items.
Currently I have one control which is made up of three ScrollableControl
objects (extended slightly to allow me to manually control scroll
positions and also set scroll positions) - on the top is the time ruler,
on the left is the vertical resource list, and the rest (except for the
empty top left corner) is occupied by the actual view. The view is
currently a large canvas where I paint the resource "events" as square
boxes that visually give you an idea how long they last and when they
start in relation to other resource events. Each of these boxes is
actually inside another control (one per resource) that spans the length
of the view and contains all the events of a single resource - I call
these ResourceStrips for now.
When you scroll the view horizontally, the time ruler is also made to
scroll the same amount of pixels, so that the events and their place in
time lines ut properly. Likewise, when the view is scrolled vertically,
the resource list on the left is manually scrolled to keep up.
So far, all is good. I put my ResourceView into a form and dock it to
fill the entire thing. In the controls' OnResize I manually resize the
time (top) and resource (left) controls to keep up - the built in
docking functionality does not work the way I need it to. So the control
resizes beautifully and it all seems relative light on resources.
However, there are a few issues (and finally he gets to the point..?);
1) When I resize the window, the scrollbars on the top and left controls
flash on and off; This seems to happen in the ScrollableControl OnLayout
method, but I am not sure. Can I get rid of this? If I override OnLayout
and don't let it call base.OnLayout(), it stops flashing but it also
stops doing much of anything else, including scrolling.
2) If I click in the main view, it will reset to horizontal position
zero, and scroll vertically so the entire "resource row" (i.e.
ResourceStrip control) is in view. I am guessing this is due to some
sort of EnsureVisible() thing on the ResourceStrip? I think it is worth
nothing that the scroll reset occurs on mousedown - it doesn't wait for
me to release the mouse button. Is this a focus thing? And more
importantly, can I get rid of it?
3) Currently, each resource event (i.e. the square boxes that make up
the contents of the ResourceStrips) is simply painted on - they are not
controls. These controls could get quite heavy, in theory 500-1000
events in one view. I will need these to react to clicks and mouseovers.
Is it better to create these as individual lightweight controls? Or
should I keep painting them as graphics on the ResourceStrips.
I hope some friendly soul can shed some light on this as my head is
almost out of hair..
Thank you very much in advance for the help!
Rune