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

Save state information in a stream

Thread ID:

Created:

Updated:

Platform:

Replies:

8591 Nov 13,2003 08:08 AM UTC Dec 16,2003 04:11 PM UTC WinForms 14
loading
Tags: Tools
Ralf Huettl
Asked On November 13, 2003 08:08 AM UTC

Hi all, we want to save Toolbar state information in a MemoryStream as XML. This is no problem because you can create a MemoryStream and then get the MemoryStream into an XmlTextWriter. But how can we get the stream to the AppStateSerializer? There is no overloaded Method for doing this. Thank you for helping out Ralf

Administrator [Syncfusion]
Replied On November 13, 2003 07:18 PM UTC

Hi Ralf, First, create a MemoryStream and initialize the AppStateSerializer with it as shown below : System.IO.MemoryStream memStream = new System.IO.MemoryStream (); AppStateSerializer.InitializeSingleton(Syncfusion.Runtime.Serialization.SerializeMode.XMLFmtStream, memStream); You could save the current state information using : AppStateSerializer.GetSingleton().PersistNow(); Before closing the application make sure that the data in the MemoryStream is stored in a database. The next time the application is started, load the data back from the database into the MemoryStream and initialize the AppStateSerializer with this MemoryStream as shown above. This is equivalent to loading the previously saved state information. Please let me know if you need more information. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Ralf Huettl
Replied On November 14, 2003 04:57 AM UTC

Hi Guru, thank you for the source. But if we try this: guiSerializerStream = new MemoryStream(); AppStateSerializer.InitializeSingleton( Syncfusion.Runtime.Serialization.SerializeMode.XMLFmtStream, guiSerializerStream ); // Persist to Serializer AppStateSerializer.GetSingleton().PersistNow(); then the MemoryStream stays empty - why? Thank you :-) Ralf

Ralf Huettl
Replied On November 14, 2003 05:25 AM UTC

We found out that if we get the Serializer via AppStateSerializer.GetSingleton() that the Mode is not more XML (it is IsolatedStorage now). Can this be a setting problem or a version problem? Thank you again Ralf

Ralf Huettl
Replied On November 14, 2003 06:00 AM UTC

Here is another example of a explicit AppStateSerializer that also writes 0 bytes :-( Greetings Ralf

Administrator [Syncfusion]
Replied On November 14, 2003 08:11 PM UTC

Hi Ralf, Thanks for bringing this issue to our attention, and also for the code snippet. I have observed this error here, and have informed the Essential Suite Development Team about it. I will update you as soon as we resolve this issue. Thanks for your patience. Regards, Guru Patwal Syncfusion, Inc.

Ralf Huettl
Replied On December 11, 2003 04:22 AM UTC

Hi Guru, can you ask the development team when this bug will be fixed? We need it at january in our application because the state must be serialized into a DBS. You can contact me under my given Email too. Thank you Ralf

Ralf Huettl
Replied On December 11, 2003 04:25 AM UTC

Hi Guru, we have another problem with the MainFrameBarManager - maybe you can help me too in this situation: We want to fix/free all the toolbars in our application with one click (The user can choose if the toolbars will be draggeable or fixed). We have MDIs that have own ChildFrameBarManagers. But how can we fix (allow the user not to drag/drop bars) from the GUI? With the dockingManager this is no problem : dockingManager1.DisallowFloating = true; But the Toolbars are not working. They must be set all exclusive with BarStyle.DrawDragBorder? Why is there no generic access in the BarManagers? Any ideas, worarounds? Thank you... Ralf

Ralf Huettl
Replied On December 11, 2003 08:30 AM UTC

Hi Guru, we solved a part of this problem: We iterate through all ChildBarManagers and for every Manager we iterate through the bars and set the DrawDragBorder false. This works in the active MDI perfect BUT if we open another MDI the settings of the Managers are reset. The MDI1 Manager states are ok(fixed then) but new MDIs are not fixed. But we want ALL toolbars fixed ( all toolbars mean the toolbars of every MDI child) And ideas? Thank you Ralf private void fixBarItem_Click(object sender, System.EventArgs e) { dockingManager1.DisallowFloating = true; foreach( Syncfusion.Windows.Forms.Tools.XPMenus.BarManager c in mainFrameBarManager1.ChildManagers ) { foreach( Syncfusion.Windows.Forms.Tools.XPMenus.Bar b in c.Bars ) { b.BarStyle &= ~Syncfusion.Windows.Forms.Tools.XPMenus.BarStyle.DrawDragBorder; } } foreach( Syncfusion.Windows.Forms.Tools.XPMenus.Bar b in mainFrameBarManager1.Bars ) { b.BarStyle &= ~Syncfusion.Windows.Forms.Tools.XPMenus.BarStyle.DrawDragBorder; } }

Administrator [Syncfusion]
Replied On December 11, 2003 08:50 PM UTC

Hi Ralf, AppStateSerializer does write information into the memory stream correctly. But you need to reset the memory stream’s current position to the beginning or to the point from which the serialized bytes begin before passing it to the AppStateSerializer or calling a LoadState method. The AppStateSerializer will have no concept of where the stream begins or ends and it is up to the application to manage the stream. Assuming that this particular stream has just the persisted state information, then setting it’s current position to 0 before calling LoadBarState() will make it work correctly (as shown in the code snippet below) : private void LoadStateInfo(object sender, System.EventArgs e) { this.memStream.Position = 0; AppStateSerializer serializer = new AppStateSerializer(SerializeMode.BinaryFmtStream, this.memStream); this.mainFrameBarManager1.LoadBarState(serializer); } I have also attached a Sample_Application that illustrates the above. Here I have used as instance of the AppStateSerializer to save/load state information. Similarly it can done using the Singleton as well. But in this case, after reading the persisted state information from the database into the memory stream, once again you need to reset the memory stream’s current position to 0. Please try this and let me know if this helps. For the issue regarding the MainFrameBarManager, please refer to Arun''s reply in the following forum post : http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9205 Thanks for your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Ralf Huettl
Replied On December 16, 2003 05:26 AM UTC

Hi Guru, this helps :-) Great support.... Greetings Ralf

Ralf Huettl
Replied On December 16, 2003 07:17 AM UTC

Hi Guru, there is a last thing we have to solve: You solution works in the Main Form (MainFrameBarManger, Dockings etc.) but we have several different MDI Forms with ChildFrameBarManagers. How can we serialize them? Do we have to serialize every MDI in the Close method and deserialize it in the Load event or is there a generic solution for serializing/deserializing the MDI states? Thank you for helping out Ralf

Ralf Huettl
Replied On December 16, 2003 07:23 AM UTC

Hi again, a last note: we want to serialize the MainFrameBarManager and all the ChildFrameBarmanagers into one file then (later into DB) - if this will work. Cheers Ralf

Administrator [Syncfusion]
Replied On December 16, 2003 01:08 PM UTC

Hi Ralf, In a MDI parent-child scenario using docking, you will have to individually save and load state information for each MDI child. But in the same scenario, if the parent form uses MainFrameBarManager, it is not necessary to save and load toolbars/menu state information or each of the MDI child forms. Persisting state information of just the MainFrameBarManager will automatically save state information of its MDI child forms as well. Also, note that the ChildFrameBarManager cannot be used directly to save or load state information. Yes, you could serialize state information of MainFrameBarManager and all the ChildFrameBarmanagers into one single file and then save it into a database. Please refer to my earlier responses (above) for this purpose. Thanks for your continued interest in Syncfusion products, and please let me know if you need any other information. Regards, Guru Patwal Syncfusion, Inc.

Ralf Huettl
Replied On December 16, 2003 04:11 PM UTC

Guru, this works perfect :-) Ralf

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

;