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
I can't think of any reason why it wouldn't work but I wouldn't be surprised if there was some timing issue occuring because Visible is changing in the OnLoad. If you must load the layout in the OnLoad because that is the earliest point at which you can access the mdi children, report the issue to the support group. They may find a workaround or a bug with the tabbed mdi manager which can be fixed. Otherwise, I would recommend trying to load the layout in the constructor so you don't need to worry about setting Visible to False.
I managed to find out the cause of the problem, but i do not understand why.
In my OnLoad method in the MainForm, if i do LoadTabbedMdiLayout("TabbedMdi.xml"), everything was fine, including the tab group or mdi child position.
But if i add the following line, the tab group and mdi child position would fail to work. All tabs will be added into one group. this.Visible = false;
Can you think of any reason why? The reason I added this line is because it takes some time to LoadTabbedMdiLayout, and I do not want to show some blank screen while it is loading.
Thanks!
It could be a bug. I would recommend submitting a sample which reproduces the issue to the support group: http://ko.infragistics.com/gethelp.
I tried to add StoreTab and RestoreTab event handler, and they were called when SaveAsXml and LoadFromXml.
All the MDI child forms were loaded successfully, but the MDI layout does not.
For example, if i create a new horizontal Tab group, the group dissapears when loading next time. If i am not use tab, the sizes and positions of child forms were not loaded propertly next time.The only difference it can tell is whether the layout is tabbed or not, and this was loaded properly.
Any idea what's going wrong?
Its possible, but it would need to be done manually. You could create an XML file where you store each configuration stream as a base 64 value in the file. Here is one way you could accomplish this for a toolbars manager and dock manager:
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_FormClosed( object sender, FormClosedEventArgs e ){ using ( XmlTextWriter writer = new XmlTextWriter( "config.xml", Encoding.Default ) ) { writer.WriteStartElement( "Config" ); writer.WriteStartElement( "ToolbarsConfig" );
using ( MemoryStream stream = new MemoryStream() ) { this.ultraToolbarsManager1.SaveAsBinary( stream, true );
byte[ buffer = stream.GetBuffer(); writer.WriteBase64( buffer, 0, buffer.Length ); }
writer.WriteEndElement();
writer.WriteStartElement( "DockConfig" );
using ( MemoryStream stream = new MemoryStream() ) { this.ultraDockManager1.SaveAsBinary( stream );
writer.WriteEndElement(); writer.WriteEndElement(); }}
private byte[ ReadBase64( XmlTextReader reader ){ List<byte> finalBuffer = new List<byte>(); byte[ buffer = new byte[ 1000 ];
while ( true ) { int bytesRead = reader.ReadBase64( buffer, 0, buffer.Length );
if ( bytesRead < buffer.Length ) { byte[ retValue = new byte[ finalBuffer.Count + bytesRead ];
Buffer.BlockCopy( finalBuffer.ToArray(), 0, retValue, 0, finalBuffer.Count ); Buffer.BlockCopy( buffer, 0, retValue, finalBuffer.Count, bytesRead );
return retValue; } else { finalBuffer.AddRange( buffer ); } }}