I am trying to save the MDI state when closing the application and load it when opening. Like FireFox, it opens all the web pages last time when you close the application. I've noticed that UltraTabbedMdiManager have methods like SaveAsXml and LoadFromXml.What is contained in the saved XML file?
What do I need to do if I want to open the last visited pages like FireFox? Thanks.Mike
vrn said:Mike, In the above code snippet I think you meant to do something with ToolbarConfig and DockConfig since write it out at Form closure.
My code snippet used an XmlTextReader, which just reads the nodes in order, so it did not need to specify the config file it was looking for. I could have put asserts before loading each stream to make sure the current node had the expected names before loading them.
vrn said:Second questoin, I want to let users to save as many settings as they like. That way they can have multiple looks and layouts pre-defined and they can change it to any of them very quickly. When they load such a setting file, I would like each control to process its own settings by firing an event. What should I be sending as part of the event to the individual control so that the control can pick it up from there? Should I make the control get the XML stream, the complete binary or something else?
I would send the stream loaded from the file in the event args. Then the control can just pass that to its appropriate LoadFrom... method.
Mike Dour"] private void Form1_Load( object sender, EventArgs e ){ if ( File.Exists( "config.xml" ) == false ) return; using ( XmlTextReader reader = new XmlTextReader( "config.xml" ) ) { reader.ReadStartElement( "Config" ); using ( MemoryStream stream = new MemoryStream( this.ReadBase64( reader ) ) ) this.ultraToolbarsManager1.LoadFromBinary( stream ); using ( MemoryStream stream = new MemoryStream( this.ReadBase64( reader ) ) ) this.ultraToolbarsManager1.LoadFromBinary( stream ); }}
private void Form1_Load( object sender, EventArgs e ){ if ( File.Exists( "config.xml" ) == false ) return;
using ( XmlTextReader reader = new XmlTextReader( "config.xml" ) ) { reader.ReadStartElement( "Config" );
using ( MemoryStream stream = new MemoryStream( this.ReadBase64( reader ) ) ) this.ultraToolbarsManager1.LoadFromBinary( stream );
using ( MemoryStream stream = new MemoryStream( this.ReadBase64( reader ) ) ) this.ultraToolbarsManager1.LoadFromBinary( stream ); }}
Mike, In the above code snippet I think you meant to do something with ToolbarConfig and DockConfig since write it out at Form closure.
Mike Dour"] writer.WriteStartElement( "DockConfig" );
writer.WriteStartElement( "DockConfig" );
If you do not mind, can you add that code to snippet to help me understand how you use the stream to read individual settings
Second questoin, I want to let users to save as many settings as they like. That way they can have multiple looks and layouts pre-defined and they can change it to any of them very quickly. When they load such a setting file, I would like each control to process its own settings by firing an event. What should I be sending as part of the event to the individual control so that the control can pick it up from there? Should I make the control get the XML stream, the complete binary or something else?
Thanks!
It all depends on how you want to store the data. If you want to convert the bytes of the saved binary layout file to some other format, you can use that. I just used Base64 because it is the standard way to store binary data.
So Base64 is necessary to implement as binary?
It all depends on whether you would like to use SaveAsBinary or SaveAsXml. The binary layout files are smaller in size but cannot be manually examined or edited. The XML layout files can be opened and edited by a developer in any xml editor.