You can certainly use the AutoScroll capabilities of the Panel control to do
what you want, and it sounds like you're already set up to handle it. The
thing you have to realize is that, as far as drawing graphic objects is
concerned, you still have to write code for the AutoScroll to do anything
for you, unless you have a panel contained within your scrolling panel that
you actually draw on (and size to fit your entire canvas.) Given your
retained-mode object model, I wouldn't recommend that method, since
enclosing a panel object within another kinda defeats the purpose of your
object model, and makes solving this problem REALLY hard.
Any .NET controls contained within the panel will be scrolled for you, but
anything you draw will have to be managed by the Paint event of your Panel,
using the translate methods of each object's Matrix in order to get the
right position. In case you haven't yet, check out the "AutoScrollMinSize",
"AutoScrollMargin", and "AutoScrollPosition" properties to see how to get
everything working. It's not hard to do, but like I said, in order to
actually get your graphics to scroll with the scrollbar, you'll have to
write some translation code within your Paint event. However, given that
each object already has its own Matrix property, it should be relatively
simple to add the scrolling translation to each selected object's Matrix
before drawing them. Doing that should ensure that your non-selected
objects don't go anywhere.
If you need a "push" to get you started, Bob Powell's GDI+ FAQ is about the
best out there right now. In fact, he's got an article that explains the
basics of AutoScroll and graphics operations:
http://www.bobpowell.net/understanding_autoscroll.htm He also has an article discussing retained-mode graphics systems, and there
is some MSDN information on that available as well.
You're also going to want to investigate the Begin/EndContainer methods, if
you haven't already. Given that each object has its own Matrix, each object
can be transformed/translated independently within the canvas. That almost
requires Begin/EndContainer use, so that you can isolate the translations
appropriately. Each object needs to start from a consistent translation
state, and the easiest one is the identity matrix (no translation), since
that's how your Graphics object will be when you enter your Paint event.
Using the Begin/EndContainer methods will let you to isolate your
transformation to the specific object you're drawing, and reset the Graphics
object before you draw your next one. If you don't do it that way, then you
will probably never get it to work right.
Of course, depending on where your retained-mode graphics system came from,
this might all be handled for you, so it's certainly something to
investigate before you go writing a bunch of code. If you developed it from
scratch, then you'll have to deal with all of this. If you got it from
somewhere else, it may already manage some or all of this for you.
HTH
- Scott
[quoted text, click to view] "Steve Magoon" <owkmann@nojunk.yahoo.com> wrote in message
news:O7FiHFxVFHA.2196@TK2MSFTNGP09.phx.gbl...
>> If I understand what you're wanting to do, you want to be able to
>> selectively scroll objects within your panel, taking advantage of the
>> AutoScroll capabilities. For example:
>>
>> You have three objects in the panel - A, B, and C. If you select A and
>> scroll the panel, you *only* want A to scroll - B and C should retain
>> their positions.
>
>
> Yah, you're right. I didn't explain myself very clearly; thanks for the
> 'translation'. I have three objects drawn into a panel. I want to scroll
> one of them without affecting the others. Each object has its own Matrix
> and Properties that I can change. I'm wondering if it's possible to do
> this on a panel using its autoscroll properties, or should I try scrolling
> individual objects with a scroll bar from the tool box?
>
> I hope this makes more sense.
>
> Thanks for helping this novice!
>
> Steve
>
>
>
> "Scott McChesney" <scott.NO.SPAM.mcchesney@us.army.mil> wrote in message
> news:ebgOEBwVFHA.548@tk2msftngp13.phx.gbl...
>> Steve -
>>
>> If I understand what you're wanting to do, you want to be able to
>> selectively scroll objects within your panel, taking advantage of the
>> AutoScroll capabilities. For example:
>>
>> You have three objects in the panel - A, B, and C. If you select A and
>> scroll the panel, you *only* want A to scroll - B and C should retain
>> their positions.
>>
>> If I have it right, I believe it is possible. From my way of thinking,
>> you'll have to store which objects are selected, and then in your Paint
>> event, you'll have to "undo" the scroll translation on all unselected
>> objects. That way, they should remain in their current position, while
>> all others scroll as appropriate.
>>
>> If you're using a retained-mode system, probably the best thing to do (if
>> you aren't already) is to store the transformation to apply within each
>> object. That way, you could apply the appropriate translations
>> (scrolling or otherwise) to each object - in this case, you would only
>> apply the scrolling translation to the selected objects. That would
>> provide the best control over object placement. I don't think the Panel
>> control provides a Scroll event, but you could apply the scrolling
>> translation in your Paint event before you actually draw each object.
>>
>> I'm not nearly the GDI+ expert that Bob is, so he may have a better
>> solution. But this is how I'd tackle the problem.
>>
>> HTH
>>
>> - Scott
>>
>> "Steve Magoon" <owkmann@nojunk.yahoo.com> wrote in message
>> news:OCNkxAnVFHA.3864@TK2MSFTNGP10.phx.gbl...
>>>I would like to autoscroll objects as I select them (via hit testing),
>>>separately, on a panel. In other words, if I select drawing (A) with the
>>>mouse, then the autoscroll function would apply only to that object. Is
>>>this possible with autoscroll, or is there a better way? I have several
>>>objects that I'm drawing to a panel using a retained mode graphics
>>>method.
>>>
>>> Thanks for your help,
>>>
>>> Steve
>>>
>>
>>
>
>