Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# GDI
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 2:52am
PogoboyKramer at 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 at 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 at 9-Nov-10 11:23am
that is a dreadful solution to the OPs problem.
Thorsten_Loos at 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 at 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
0 Sergey Alexandrovich Kryukov 485
1 Maciej Los 285
2 OriginalGriff 285
3 Peter Leow 260
4 John C Rayan 162
0 Sergey Alexandrovich Kryukov 7,203
1 OriginalGriff 5,587
2 Peter Leow 4,097
3 Mika Wendelius 2,850
4 CHill60 2,818

Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 9 Nov 2010
Copyright © CodeProject, 1999-2015
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