Error in persistance of docking

Topics related to the Krypton Docking.

Moderators: Phil Wright, Chris Porter

Error in persistance of docking

Postby salihovic » Thu Nov 17, 2011 11:52 pm

I have tryed to save docking layout in an array and save it in an xml file by serializing the array.
and reload information from save file to restore the config.
I have a problem because it is not working in all cases.
Code: Select all
private SerializedDock serializeElement=new SerializedDock();
 public void SerializeToXML(SerializedDock SerialDock)
        {
           XmlSerializer serializer = new XmlSerializer(typeof(SerializedDock));
           TextWriter textWriter = new StreamWriter(@"C:\SerialDock.xml");
           serializer.Serialize(textWriter, SerialDock);
           textWriter.Close();
        }

         public SerializedDock DeserializeFromXML()
         {
            XmlSerializer deserializer = new XmlSerializer(typeof(SerializedDock));
            TextReader textReader = new StreamReader(@"C:\SerialDock.xml");
            SerializedDock SerialDock;
            SerialDock = (SerializedDock)deserializer.Deserialize(textReader);
            textReader.Close();

            return SerialDock;
         }


and the object
Code: Select all
[Serializable]
    public class SerializedDock
   {
      private byte[] _dockingArray;
      [XmlArray("DockingPositions")]
      public byte[] DockingArray
      {
         get { return _dockingArray; }
         set { _dockingArray = value; }
      }

      public String NameOfDocking;

   }



when I try to save the array:
Code: Select all
        private void kryptonRibbonGroupButton4_Click(object sender, EventArgs e)
        {
         
           serializeElement.NameOfDocking = "First Docking to test";
         serializeElement.DockingArray = kryptonDockingManager.SaveConfigToArray(); ;
           SerializeToXML(serializeElement);
        }

and load
Code: Select all
private void kryptonRibbonGroupButton5_Click(object sender, EventArgs e)
        {
           serializeElement = DeserializeFromXML();
           kryptonDockingManager.LoadConfigFromArray(serializeElement.DockingArray);
        }


the error is produced when I save a modified layout and exit the application and then load the array.but in the same runtime it works.
maybe it is related to references to objects or somethingelse...
if some one knows how to do this thanks a lot .
salihovic
 
Posts: 8
Joined: Mon Jun 14, 2010 8:38 pm

Re: Error in persistance of docking

Postby salihovic » Fri Nov 18, 2011 2:56 am

my problem is similar to this post
viewtopic.php?f=17&t=2726&hilit=LoadConfigFromArray
salihovic
 
Posts: 8
Joined: Mon Jun 14, 2010 8:38 pm

Re: Error in persistance of docking

Postby salihovic » Fri Dec 30, 2011 5:35 pm

hi
the problem is related to the number of docking panels added at startup
what I have understood is that if in the saved config you have 3 docked panels and 2 panels in workspace.you have the total number of panels 5.
if in the load of your application you don't add 5 panels to your dockable workspace thepersistance will fail.
it is due to the saving of pages positions by saving the type and the location.
and if the kryptondockable workspace dont get the same panels it don't continue.
you can see kryptondockingmanager.cs the method LoadConfigFromXml in the line 3256

Code: Select all
 
// Did we have any starting pages?
                        if (currentPages.Count > 0)
                        {
                          //...
                        }

this is why if you don't initiate a number of pages you will have not this fonctionnality working.
and there is an other problem with the number and the type of loaded pages.
you have to readd the same number of pages or more and the same type else you will have a problem.
salihovic
 
Posts: 8
Joined: Mon Jun 14, 2010 8:38 pm

Re: Error in persistance of docking

Postby hayque » Thu May 24, 2012 1:35 pm

Hi,

I have a 3 Krypton Pages stacked together .. By default, the first page will appear on top. My question is, how do I programatically select a page, so that it appear on top of the other? (i.e. the same if we 'click' on the tab, but how do I do it in the code?)
Any help would be much appreciated.

Thank you.
VW.
hayque
 
Posts: 2
Joined: Thu May 24, 2012 1:33 pm


Return to Krypton Docking

Who is online

Users browsing this forum: No registered users and 1 guest