Skip to content

Save shape(polygon, ellipse) into file

karhong karhong

Asked Jul 15, 2008, 10:34 PM EDT3 answers
Share
LinkedInX

Hi,

I'm wondering, whether is there any other methods to save the shape into a file?
Meaning that I've already drag few shape and I wanted to save all the shapes, their position, their colour.

What I'm thinking now is, getting all the shape's coordinate, colours, size and save it into a text file.
Then when loading the file, I need to recreate all the shape based on the information of the text file.

Is there any other method in C# which make my saving shape easier?? Such as save with other format, then enable me to load the file easier??

Regards,
Kar Hong

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0

    Hmmm.. this is the way if you want to keep track of your objects, their position and properties. If there are no changes to the shapes and you just want to display, you can use them as an Image using the Bitmap and Image classes.

    Alternatively, you can create a GraphicsPath and add all shapes to it and save the path and within the path, you save shapes but still you will have to load your text file and recreate the shapes.

    0
  • 0
    You could also serialize the objects to a stream and then write the stream to a file. Then when you want to use them again, you can read the file into a stream and then deserialize it back into the object.
    0
  • 0

    Em, I'll try on the Serialise and then get back to you...

    Thank you all for the fast reply!

    0