ShapeCollectionSave
Introduction
The ShapeCollectionSave class is a "save" class. Save classes are classes which allow you to load XML files to runtime objects as well as to save data contained in runtime objects to XML files. For more information on Save files, check this article.
You do not need to use the ShapeCollectionSave class in most cases since the FlatRedBallServices' Load method can load ShapeCollections. If you are simply looking to load a ShapeCollection, see this page.
You can use ShapeCollectionSave if you are making a tool that works with the .shcx file format.
Loading a .shcx file
You can load load a ShapeCollectionSave as follows:
Saving a .shcx file
Sha'eCollectionSaves can be saved through the Save method. Therefore, the process of saving an existing ShapeCollectionSave is very simple:
The more complicated process is to construct the ShapeCollectionSave. You can construct a ShapeCollectionSave by creating a ShapeCollectionSave from an existing ShapeCollection or manually (by instantiating and adding instances to it).
Creating a ShapeCollectionSave from a ShapeCollection
The following code saves a .shcxfile named MyShapeCollection.shcx. It assumes that shapeCollection is a valid .
Add the following using statements:
Assumes shapeCollection is a valid ShapeCollection:
Creating a ShapeCollectionSave manually
The steps for creating a ShapeCollectionSave manually are:
Instantiate a ShapeCollectionSave
Add "save" instances to the ShapeCollectionSave (such as PolygonSave and CircleSave)
Save using the Save method.
Creating a ShapeCollection from a ShapeCollectionSave
You can convert ShapeCollectionSaves into runtime ShapeCollections: Add the following using statements:
Assumes "save" is a valid ShapeCollectionSave:
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
Last updated