We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot Serialize/Deserialize Docking Manager state using a Stream

Hi all,

In the application main window of my application the controls are docked using the DockingManager;

I'd like to store the DockingManager state in a XML file that hosts other stuff. To do this I'm trying to use the AppStateSerializer.

I can serialize/deserialize the Docking Manager state using a file:

---------------------------------------------------------------------
Serialization:

string fileName = "C:\temp\test"
AppStateSerializer apss = new AppStateSerializer(SerializeMode.XMLFile, fileName);
_syncfusionDockingManager.SaveDockState(apss);
apss.PersistNow();

Deserialization:

string fileName = "C:\temp\test"
AppStateSerializer apss = new AppStateSerializer(SerializeMode.XMLFile, filename);
_syncfusionDockingManager.LoadDockState(apss);
---------------------------------------------------------------------


but if I try to serialize/deserialize using a MemoryStream (so that I can store the serialized state in my XML) I cannot get the deserialization working, while the serialization seems to be working perfectly since the MemoryStream contains valid stuff:

---------------------------------------------------------------------
Serialization:

MemoryStream ms = new MemoryStream();
AppStateSerializer apss = new AppStateSerializer(SerializeMode.XMLFmtStream, ms);
_syncfusionDockingManager.SaveDockState(apss);
apss.PersistNow();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string xmlString = encoding.GetString(ms.GetBuffer()); // --> this string goes to my serializer
// and is correctly received here (*)

Deserialization:

// (*) here I correctly receive the XML-stream in a string called "xmlStream"
MemoryStream ms = new MemoryStream();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] buffer = new byte[xmlStream.Length];
encoding.GetBytes(value, 0, xmlStream.Length, buffer, 0);
ms.Write(buffer, 0, buffer.Length);
AppStateSerializer apss = new AppStateSerializer(SerializeMode.XMLFmtStream, ms);
_syncfusionDockingManager.LoadDockState(apss); // -> DOESN'T LOAD THE STATE!!!
---------------------------------------------------------------------


5 Replies

AD Administrator Syncfusion Team February 9, 2008 09:37 AM UTC

Hi Ampelio,

Thank you for your interest in Syncfusion products.

Load dock state from XMLFmtStream.

Please load the dock state from XMLFmtStream using the following code snippet.

[C#]

AppStateSerializer aser = new AppStateSerializer(SerializeMode.XMLFmtStream, ms);
ms.Seek(0, SeekOrigin.Begin);
this.dockingManager1.LoadDockState(aser);

Sample

Please refer the sample that demonstartes the same and let us know if you have any other queries.

http://websamples.syncfusion.com/samples/Tools.Windows/F71624/main.htm

Regards,
Jaya



SG Simone Galleni February 11, 2008 09:27 AM UTC

Thanx Jaya,

it worked!
Seems it was something about the stream seek(0, ...).

Just a suggestion: since the user actually relay directly on the AppStateSerializer you could suggest the Syncfusion Devs to add the seek() on the stream in the constructor of the AppStateSerializer itself...

Anyway, thanks again, bye!

Ampelio



AD Administrator Syncfusion Team February 11, 2008 09:33 AM UTC

Hi Ampelio,

Thanks for your suggestion.

We will inform this to development team. Please let us know if you have any other questions.

Regards,
Jaya



SG Simone Galleni February 12, 2008 09:27 AM UTC

>Hi Ampelio,

Thanks for your suggestion.

We will inform this to development team. Please let us know if you have any other questions.

Regards,
Jaya



Hi Jaya,

actually I have a question about the docking windows. I'd like to show a confirmation dialog when a docking window (ALL the dockable windows, docked or floating...) is going to be closed: seems there is not an event in the DockingManager object. Using the CaptionButtons collection (using the Click event of thebutton) I'm able to detect the "Closing" of the docked window only, the floating one do not fire the Click event.
Any ideas? Thanks in advance.




SG Simone Galleni February 12, 2008 11:15 AM UTC



>>Hi Ampelio,

Thanks for your suggestion.

We will inform this to development team. Please let us know if you have any other questions.

Regards,
Jaya



Hi Jaya,

actually I have a question about the docking windows. I'd like to show a confirmation dialog when a docking window (ALL the dockable windows, docked or floating...) is going to be closed: seems there is not an event in the DockingManager object.




Ok, I found the "DockVisibilityChanging" event... the name was not so _descriptive_ but it seems it does what I need.


Loader.
Live Chat Icon For mobile
Up arrow icon