[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

patrick

1/4/2005 5:21:00 PM

Dear Ng,

i have a panel. I would like to enable the user to draw his own graphics on
the panel, which is looking like a paper. How can I handle the graphics
elements (e.g. a rectangle) like objects which have to be resized like a
control. Each time I refresh the panel, the elemnts will disappear. Do I have
to remember all attributes of all graphic elements and do i have to recall
them in the OnPaint method?

Thanks in advance and best regards,
Patrick Braunschweig
2 Answers

Morten Wennevik [C# MVP]

1/4/2005 6:52:00 PM

0

Hi Patrick,

There are two approaches to a drawing panel like this.

1. You can store each element and each size etc and redraw them all when
refreshing (or optimizing and redrawing only those necessary).

2. Draw to an internal Bitmap and use DrawImage in the paint procedure to
paste this image onto the panel. You won't have to remember the elements
already drawn, but undoing drawn figures will be more complex.

(3. Use a combination. Store elements and size, but once an element is
"finished", paint it to a bitmap that will be used in refresh procedures.)

--
Happy Coding!
Morten Wennevik [C# MVP]

Bob Powell

1/4/2005 10:37:00 PM

0

The GDI+ FAQ will tell you why your objects are disappearing and how to
create systems that don't do that.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Patrick" <Patrick@discussions.microsoft.com> wrote in message
news:FA16B5E4-E107-49D2-928B-ECE4254D10DE@microsoft.com...
> Dear Ng,
>
> i have a panel. I would like to enable the user to draw his own graphics
> on
> the panel, which is looking like a paper. How can I handle the graphics
> elements (e.g. a rectangle) like objects which have to be resized like a
> control. Each time I refresh the panel, the elemnts will disappear. Do I
> have
> to remember all attributes of all graphic elements and do i have to recall
> them in the OnPaint method?
>
> Thanks in advance and best regards,
> Patrick Braunschweig