Click here to Skip to main content
Rate this: bad
good
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
Bezawit460
Comments
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
good
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 !
  Permalink  
Comments
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
good
Please Sign up or sign in to vote.

Solution 2

This article might give you some ideas. Draw Tools[^]
  Permalink  
Comments
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 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Afzaal Ahmad Zeeshan 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


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