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.