Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys. I am trying to save 2D graphics shapes that were drawn on a UserControl. I mean, it is like Microsoft's paint application where the user can create different shapes like rectangles, lines and then save it to a file in their PC. They can later come to that file and open it.

I am currently drawing these shapes in a UserControl and wanted to save it as I explained above. I thought one way would be to serialize the UserControl. But some googling showed me that UserControls and WindowsForms are not suitable for serialization.
Is there a way around this thing? I appreciate any ideas you might suggest if you have an experience on this thing.

Thanks in advance
Posted
Comments
fjdiewornncalwe 9-Nov-10 9:26am    
Do you want to save each drawn shape as a separate object, or just save everything drawn as an image?
Bezawit 10-Nov-10 9:30am    
I want to save what I have already drawn on to the UserControl as one object. But I want to do all the operations that I was able to do on the object before I saved it. i.e like changing the size of rectangle for example, changing its position and so on.

I would take a screenshot of the the window which hosts your user control. A sample code to do this you can find here :

Screenshot C# Example

The page is in german, but the code is quite self-explainatory.

Good luck !
 
Share this answer
 
Comments
Henry Minute 9-Nov-10 11:23am    
that is a dreadful solution to the OPs problem.
Thorsten_Loos 9-Nov-10 11:24am    
It's exactly what MSPaint which he mentioned does....
This article might give you some ideas. Draw Tools[^]
 
Share this answer
 
Comments
Thorsten_Loos 9-Nov-10 14:34pm    
Now that is quite a lousy solution to his problem, because he won't be able to open his images in any other tool but his own...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900