ThinkGeo.com    |     Documentation    |     Premium Support

Save the Control/Project

Hi ,


We are creating an application, based on  the ThinkGeo APIs.


In our application users can add/remove different type of layers (Shape, Tab,  Raster,...) and then edit them(changing the color,add/remove point,line , ...) and finally save it as project, therefore the user can load all of his activities and continue his work.


We decide to save different layers on Hard disk seperatly and create XML files which save address and type of layers.


I want to know do you have any Sample or best prctices for this issue?


Regards,


Ben



Ben, 
  
 Thanks for your post. 
  
 I am sorry to say that the XML serialization cannot be supported up to now because we encountered some problem which cannot be solved for some types of properties are not supported XML serialized by .net. 
  
 The binary serialization is still on our planning list, we have supported it for most classes in the Core, while we did not support it for the MapControl itself now. Sorry for the inconvenience now. 
  
 Thanks. 
  
 Yale 


Many thanks for your answer. 
  
 if we have structure like this: 
  
 – Layer1(ShapeFile/Tab/Raster/…) and user changed the default colors and other properties of layer 
 – Layer2(shapeFile/Tab/Raster/…) and user changed the default colors and other properties of layer 
 – Layer3(shapeFile/Tab/Raster/…) and user changed the default colors and other properties of layer 
 – … 
  
 now, we want to save the above structure when user want to close the application ,  
 therefore we can load it next time , when user open the application. 
  
 I want to know, what’s you suggestion to save the above structure? 
  
 Regards, 
 Ben 


Ben,


Thanks for your reply.


As I understand your problem, it is about a serialization of layers which should have been implemented in the latest public release. While, I am not sure this have been fully tested against.


Following code is some code snippet to do the serlize and deseialize.



private static MemoryStream SerializeBinaryViaBinaryFormatter(object request)
{
    BinaryFormatter serializer = new BinaryFormatter();
    MemoryStream memStream = new MemoryStream();
    serializer.Serialize(memStream, request);
    return memStream;
}

private static object DeSerializeBinaryViaBinaryFormatter(MemoryStream memStream)
{
    memStream.Position = 0;
    BinaryFormatter deserializer = new BinaryFormatter();
    object newobj = deserializer.Deserialize(memStream);
    memStream.Close();
    return newobj;
}

Any more questions just feel free to let us know.


Thanks.


Yale