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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cannot Serialize/Deserialize Docking Manager state using a Stream

Thread ID:

Created:

Updated:

Platform:

Replies:

71624 Feb 7,2008 05:40 PM UTC Feb 12,2008 11:15 AM UTC WinForms 5
loading
Tags: Tools
Simone Galleni
Asked On February 7, 2008 05:40 PM UTC

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!!!
---------------------------------------------------------------------


Administrator [Syncfusion]
Replied On 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


Simone Galleni
Replied On 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


Administrator [Syncfusion]
Replied On 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


Simone Galleni
Replied On 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.



Simone Galleni
Replied On 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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;