Custom format for serialization
I am using docking manager to lay out my sub controls in parent user control. I wanted to have my own serialization format for child controls visual state. Can you comment on what should be the proper approach to do this and is there enough API support available to re-genrate
visual state from custom format?
visual state from custom format?
SIGN IN To post a reply.
9 Replies
GR
Golda Rebecal
Syncfusion Team
March 15, 2007 12:04 PM UTC
Hi Sam,
The dock state of the controls can be stored in binary or XML format.
//Save Dock State
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
this.dockingManager1.SaveDockState(ser);
ser.PersistNow();
//Load Dock State
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
this.dockingManager1.LoadDockState(ser);
I have created a sample that illustrates the same. Please have a look at it and let me know if I have understood your requirement correctly.
Thanks for your interest in Syncfusion products.
Docking_Serialization
Best Regards,
Golda
The dock state of the controls can be stored in binary or XML format.
//Save Dock State
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
this.dockingManager1.SaveDockState(ser);
ser.PersistNow();
//Load Dock State
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
this.dockingManager1.LoadDockState(ser);
I have created a sample that illustrates the same. Please have a look at it and let me know if I have understood your requirement correctly.
Thanks for your interest in Syncfusion products.
Docking_Serialization
Best Regards,
Golda
AD
Administrator
Syncfusion Team
March 15, 2007 02:10 PM UTC
No...I got that....but I don't want to use suncfusion internal serialization. I want to
store the layout information in my custom format.
Regarding the same I wanted to know if anyone has done it before or is there enough API support
available to do this.
store the layout information in my custom format.
Regarding the same I wanted to know if anyone has done it before or is there enough API support
available to do this.
GR
Golda Rebecal
Syncfusion Team
March 16, 2007 08:25 AM UTC
Hi Sam,
Could you please give me more information on what you mean by custom format?
We can use the SerializeObject method of the AppStateSerializer to store the layout information. Here is the code snippet that illustrates the same.
//To store the width and height of the docked control
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
ser.SerializeObject("width", this.panel1.Width);
ser.SerializeObject("height", this.panel1.Height);
ser.PersistNow();
//To restore the state
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
Object width = (int)ser.DeserializeObject("width");
Object height = (int) ser.DeserializeObject("height");
int h = (int)height;
int w = (int)width;
if (width is int)
this.dockingManager1.SetControlSize(this.panel1, new Size(w, h));
Please have a look at the attached sample and let me know if this meets your requirement.
Thanks for your interest in Syncfusion products.
Docking_Serialization
Best Regards,
Golda
Could you please give me more information on what you mean by custom format?
We can use the SerializeObject method of the AppStateSerializer to store the layout information. Here is the code snippet that illustrates the same.
//To store the width and height of the docked control
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
ser.SerializeObject("width", this.panel1.Width);
ser.SerializeObject("height", this.panel1.Height);
ser.PersistNow();
//To restore the state
AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState");
Object width = (int)ser.DeserializeObject("width");
Object height = (int) ser.DeserializeObject("height");
int h = (int)height;
int w = (int)width;
if (width is int)
this.dockingManager1.SetControlSize(this.panel1, new Size(w, h));
Please have a look at the attached sample and let me know if this meets your requirement.
Thanks for your interest in Syncfusion products.
Docking_Serialization
Best Regards,
Golda
AD
Administrator
Syncfusion Team
March 16, 2007 12:48 PM UTC
Ok...I will rephrase the question a bit.
Can I bypass AppStateSerializer and have my own
CustomStateSerializer. It has two steps.
1) I need to get all the properties associated
with the docking manager and all controls.
( Then I will store them in a name value pair
format in txt file )
2) Once I read back the txt file I will need
API support like in ur example .SetControlSize
to recreate the whole layout...
so it leads to two questions
1) On the way down to custom serialization do
u expose all the properties used by docking manager, individual control and linking/ glueing information between them.
2) On the way back I have all the properties available but do I have enough API support to
recreate the layout from those properties. or in other words DockControl/ FloatControl/ SetControlSize/ SetEnableDocking methods are sufficient to recreate any layout programmatically. Or there are any other methods available on individual dockhosts that interplay
to give final dock state.
Can I bypass AppStateSerializer and have my own
CustomStateSerializer. It has two steps.
1) I need to get all the properties associated
with the docking manager and all controls.
( Then I will store them in a name value pair
format in txt file )
2) Once I read back the txt file I will need
API support like in ur example .SetControlSize
to recreate the whole layout...
so it leads to two questions
1) On the way down to custom serialization do
u expose all the properties used by docking manager, individual control and linking/ glueing information between them.
2) On the way back I have all the properties available but do I have enough API support to
recreate the layout from those properties. or in other words DockControl/ FloatControl/ SetControlSize/ SetEnableDocking methods are sufficient to recreate any layout programmatically. Or there are any other methods available on individual dockhosts that interplay
to give final dock state.
GR
Golda Rebecal
Syncfusion Team
March 20, 2007 01:47 PM UTC
Hi Sam,
I am working on a sample to find out whether it is possible to serialize/deserialize dock state information using custom format and will get back to you on Friday.
Thanks for being patient.
Best Regards,
Golda
I am working on a sample to find out whether it is possible to serialize/deserialize dock state information using custom format and will get back to you on Friday.
Thanks for being patient.
Best Regards,
Golda
AD
Administrator
Syncfusion Team
March 20, 2007 01:59 PM UTC
awesome...waiting for the outcome :)
thanks a lot.
thanks a lot.
AD
Administrator
Syncfusion Team
March 23, 2007 06:17 PM UTC
any luck?
ST
Sameer Tupe
March 29, 2007 02:28 PM UTC
Any updates?
VM
Venugopal M
Syncfusion Team
April 2, 2007 10:17 AM UTC
Hi Sam,
We could customize the object serialization. Classes can take control of the data they want to serialize by implementing the ISerializable interface. This option requires writing actual code to handle serialization and deserialization instead of changing the behavior simply by attaching attributes to a class.
If the object implements this interface, the formatter calls the interface’s only method: GetObjectData() to pass a SerializationInfo container that the object can fill with the data it wants to serialize. For deserialization need to implement a constructor with the same signature as GetObejectData.
A SerializationInfo object stores name-value pairs, similar to a dictionary as per requirement. We can store any object in the SerializationInfo container by calling one of the many overloaded versions of the AddValue() method.
Code snippet for serialization : CustomState stateobject = new CustomState(); stateobject.Width = this.panel1.Width; stateobject.Height = this.panel1.Height; AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState"); ser.SerializeObject("stateobject",stateobject); ser.PersistNow(); Code snippet for deserialization AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState"); stateobject = ser.DeserializeObject("stateobject") as CustomState; int h = stateobject.Height; int w = stateobject.Width; this.dockingManager1.SetControlSize(this.panel1, new Size(w, h));
You could get more idea from attached sample. http://websamples.syncfusion.com/samples/Tools.Windows/57959/main.htm
Answer for your questions.
1.Yes ,We could expose all the properties used by docking manager with the help of creating proper properties for storing and retrieving in custom state class. 2.Yes, Docking Manager API will support to recreate any layout programmatically with those properties. Please have a look at the attached sample and let me know if this meets your requirement. Thanks for your interest in Syncfusion products.
Thanks, Venugopal M.
Code snippet for serialization : CustomState stateobject = new CustomState(); stateobject.Width = this.panel1.Width; stateobject.Height = this.panel1.Height; AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState"); ser.SerializeObject("stateobject",stateobject); ser.PersistNow(); Code snippet for deserialization AppStateSerializer ser = new AppStateSerializer(SerializeMode.XMLFile, "DockState"); stateobject = ser.DeserializeObject("stateobject") as CustomState; int h = stateobject.Height; int w = stateobject.Width; this.dockingManager1.SetControlSize(this.panel1, new Size(w, h));
You could get more idea from attached sample. http://websamples.syncfusion.com/samples/Tools.Windows/57959/main.htm
Answer for your questions.
1.Yes ,We could expose all the properties used by docking manager with the help of creating proper properties for storing and retrieving in custom state class. 2.Yes, Docking Manager API will support to recreate any layout programmatically with those properties. Please have a look at the attached sample and let me know if this meets your requirement. Thanks for your interest in Syncfusion products.
Thanks, Venugopal M.
SIGN IN To post a reply.
- 9 Replies
- 4 Participants
-
AD Administrator
- Mar 14, 2007 05:41 PM UTC
- Apr 2, 2007 10:17 AM UTC