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

XPMenus-How can I influence where the MainFrameBarManager saves its data

Hi, I want to save the current layout and configuration of the toolbars and menus on a central server. The MainFrameBarManager object seems to store all this information using a memory stream in its BarPositionInfo property. However, the documentation warns on using this property. What would be the bet way to store and read this information from/to a custom location? Thanks in advance, Andy

5 Replies

AD Administrator Syncfusion Team August 5, 2004 05:36 PM UTC

Hi Andy, By default, the persisted menus and toolbars state information is saved in the Isolated Storage folder (in isolated storage medium). The Isolated Storage is present in the directory C:\Documents and Settings\{user name}\Local Settings\Application Data\IsolatedStorage To disable this, set the MainFrameBarManager''s AutoLoadToolBarPositions property to false. this.mainFrameBarManager1.AutoLoadToolBarPositions = false; You could use the AppStateSerializer to save/restore the toolbar state information from a custom location. The AppStateSerializer will allow you to store state information in the following storage media : - IsolatedStorage - XMLFile - XMLFmtStream - BinaryFile - BinaryFmtStream - WindowsRegistry You could also specify the desired location at which you wish to store this information. // Load persisted toolbar state information AppStateSerializer aser = new AppStateSerializer(SerializeMode.XMLFile, "C:\\SyncfusionToolsStateInfo"); this.mainFrameBarManager1.LoadBarState(aser); // Save toolbar state information AppStateSerializer aser = new AppStateSerializer(SerializeMode.XMLFile, "C:\\SyncfusionToolsStateInfo"); this.mainFrameBarManager1.SaveBarState(aser); aser.PersistNow(); Please refer to the sample attached that illustrates this and let me know if this meets your requirements. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


AM Andreas Mueller August 9, 2004 12:55 PM UTC

Thanks, I will try that. Cheers, Andy >Hi Andy, > >By default, the persisted menus and toolbars state information is saved in the Isolated Storage folder (in isolated storage medium). The Isolated Storage is present in the directory C:\Documents and Settings\{user name}\Local Settings\Application Data\IsolatedStorage > >To disable this, set the MainFrameBarManager''s AutoLoadToolBarPositions property to false. > >this.mainFrameBarManager1.AutoLoadToolBarPositions = false; > >You could use the AppStateSerializer to save/restore the toolbar state information from a custom location. > >The AppStateSerializer will allow you to store state information in the following storage media : > >- IsolatedStorage > >- XMLFile > >- XMLFmtStream > >- BinaryFile > >- BinaryFmtStream > >- WindowsRegistry > >You could also specify the desired location at which you wish to store this information. > >// Load persisted toolbar state information > >AppStateSerializer aser = new AppStateSerializer(SerializeMode.XMLFile, "C:\\SyncfusionToolsStateInfo"); >this.mainFrameBarManager1.LoadBarState(aser); > > >// Save toolbar state information > >AppStateSerializer aser = new AppStateSerializer(SerializeMode.XMLFile, "C:\\SyncfusionToolsStateInfo"); >this.mainFrameBarManager1.SaveBarState(aser); >aser.PersistNow(); > >Please refer to the sample attached that illustrates this and let me know if this meets your requirements. Thanks for choosing Syncfusion products. > > >Regards, >Guru Patwal >Syncfusion, Inc.


AD Administrator Syncfusion Team August 9, 2004 05:19 PM UTC

Hi Andy, Thanks for the update. Please let us know if you need further assistance. Regards, Guru Patwal Syncfusion, Inc.


AM Andreas Mueller August 18, 2004 05:47 AM UTC

Hi Guru, I checked this out and it is working great for the location and size of the toolbars. Before I ask a follow up questions, here is some info why I''m doing all this. The application I''m designing must be able to store all information about its Gui layout on a server profile. A customer must be able to log in at differnt client PCs and always have his specific Gui configuration active. For the Gui components I''m currently evaluating Syncfusion, especially the docking package and the XPMenu package. Now I was trying to solve this for the customization info. After digging into the documentation, I found out that this information can only be saved and loaded at specific times. So here is what I came up with: I derive my own bar manager and override the methods to save the customization info to a place of my choice: using Syncfusion.Windows.Forms.Tools.XPMenus; using Syncfusion.Runtime.Serialization; internal sealed class MyBarManager : MainFrameBarManager { private static AppStateSerializer Serializer() { return new AppStateSerializer(SerializeMode.XMLFile, Application.StartupPath + "\\mystate"); } protected override void SaveCustomizationInfo(AppStateSerializer serializer) { AppStateSerializer pipe = Serializer(); base.SaveCustomizationInfo (pipe); pipe.PersistNow(); } protected override void LoadCustomizationInfo(AppStateSerializer serializer) { base.LoadCustomizationInfo (Serializer()); } } It seems to work fine and would be sufficient for us. However, I''m not sure if this is correct and moreover safe and compatible with future releases of syncfusion. Concrete questions that are bugging me are: + Does the serializer that is passed into the method depend on the data that is normally written into it in this method? + Am I breaking the Framwork here? Is this a "dirty" workaround? + Do I really save all relevant information into my (server) location + When are the Save and Load methods called? On application startup/shutdown or on the forms startup/shutdown Thanks in advance for answering the questions, Andy >Hi Andy, > >Thanks for the update. Please let us know if you need further assistance. > >Regards, >Guru Patwal >Syncfusion, Inc.


AD Administrator Syncfusion Team August 18, 2004 09:10 PM UTC

Hi Andreas, As you rightly pointed out SaveBarState/LoadBarState only save/restore positional and size related information of the toolbars and not their customization information. You could use the MainFrameBarManager''s SaveCustomizationInfo/LoadCustomizationInfo to serialize customizaton information, but they are protected methods and cannot be accessed directly. So you would have to derive from the MainFrameBarManager to create a CustomMainFrameBarManager and then access these methods as shown in the code below : public class CustomMainFrameBarManager : MainFrameBarManager { public CustomMainFrameBarManager () : base() {} public CustomMainFrameBarManager(Form f): base(f) {} public CustomMainFrameBarManager(IContainer c,Form f): base(c, f) {} public void LoadBarCustomization(AppStateSerializer serializer) { this.LoadCustomizationInfo(serializer); } public void SaveBarCustomization(AppStateSerializer serializer) { this.SaveCustomizationInfo(serializer); } } Apart from the SaveBarState/LoadBarState, SaveBarCustomization/LoadBarCustomization methods too need to be called to correctly save/restore the positional, size and customization information. Here is how the new SaveToolbarState/LoadToolbarState blocks will look like : public void SaveToolbarState(CustomMainFrameBarManager toolbar, String filename) { AppStateSerializer serialize = new AppStateSerializer(SerializeMode.BinaryFile, filename); toolbar.SaveBarCustomization(serialize); toolbar.SaveBarState(serialize); serialize.PersistNow(); } public void LoadToolbarState(CustomMainFrameBarManager toolbar, String filename) { AppStateSerializer serialize = new AppStateSerializer(SerializeMode.BinaryFile,filename); toolbar.LoadBarCustomization(serialize); toolbar.LoadBarState(serialize); } A test sample that illustrates the same is attached here. Please refer to it and let me know if this meets your requirements. Thanks for your continued interest in Syncfusion produtcs. Regards, Guru Patwal Syncfusion, Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon