Click here to Skip to main content
13,089,246 members (65,757 online)
Rate this:
Please Sign up or sign in to 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 9-Nov-10 1:52am
PogoboyKramer 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 !
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....
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This article might give you some ideas. Draw Tools[^]
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 9 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100