Make that nDockpanels come back to the original position in a nDockMananger.


https://www.nevron.com/Forum/Topic7088.aspx
Print Topic | Close Window

By Hector Medina - 12 Years Ago
Make that nDockpanels come back to the original position in a nDockMananger.

Hi everybody in the community, I'm doing an applicacion in windows forms in visual studio 2010 with the framework 4.0 and using the Nevron UI. the application that i'm creating has a nDockManager and into it, it has several dockpaneles the panels have totaly freedom to dock or undock in any part of the applicacition. and i want to do that all the panels come back to the original position when i want. I reviewed the samples but there are not something similar.

I don't know if the nDockManager has some property to do this, i haven't find something like that yet. or if someone has tried to do something similar with the dockpanels.
By Nevron Support - 12 Years Ago
Hello Hector,

Please, take a look at the following topic in our documentation:
http://helpdotnetvision.nevron.com/UsersGuide_DockingPanels_Layout_Presistency.html

Also, you can find an example called Layout Persistency in our example application which comes with the suite.
By Hector Medina - 12 Years Ago
It is exactly what i need. I will try it.

Thank you so much.
By Hector Medina - 12 Years Ago
hi again, i check the sample but I had some troubles,

I Create a sample application to testing, create the Dockmanager and the Dockpanels code in the contructor method of the form. and then a create an instance of the NDockingFrameworkState class to save the state, and later load it, the file is saved but when a load it the docks don't come back to the saved position.

this is my code:

public partial class Form1 : Form
{
NDockManager m_dockManager;
NDockingFrameworkState state;
string path;
public Form1()
{
InitializeComponent();
#region GeneracionPorCodigo
NDockManager manager = new NDockManager();
NDockingPanel dock12 = new NDockingPanel();
NDockingPanel dock1 = new NDockingPanel();
NDockingPanel dock3 = new NDockingPanel();

NDockingPanelHost nDockZone1 = new NDockingPanelHost();
NDockZone nDockZone2 = new NDockZone();
NDockingPanelHost nDockZone3 = new NDockingPanelHost();
NDockingPanelHost nDockZone4 = new NDockingPanelHost();

manager.Form = this;
manager.RootContainerZIndex = 0;
manager.UndockToleranceSize = 2;

manager.RootContainer.RootZone.AddChild(nDockZone1);
manager.RootContainer.RootZone.AddChild(nDockZone2);
manager.RootContainer.RootZone.Orientation = Orientation.Vertical;

nDockZone1.AddChild(dock3);
nDockZone1.Orientation = Orientation.Horizontal;
nDockZone1.Index = 0;

nDockZone2.AddChild(nDockZone3);
nDockZone2.AddChild(nDockZone4);
nDockZone2.AddChild(manager.DocumentManager.DocumentViewHost);
nDockZone2.Orientation = Orientation.Horizontal;
nDockZone2.Index = 1;

nDockZone3.AddChild(dock1);
nDockZone3.Orientation = Orientation.Horizontal;
nDockZone3.Index = 0;

nDockZone4.AddChild(dock12);
nDockZone4.Name = "nDockZone4";
nDockZone4.Orientation = Orientation.Horizontal;
nDockZone4.Index = 1;

dock12.Location = new Point(1, 24);
dock12.Size = new Size(134, 33);
dock12.SizeInfo.PreferredSize = new Size(200, 200);
dock12.TabIndex = 1;
dock12.Text = "C";

dock1.Location = new Point(1, 24);
dock1.Size = new Size(138, 33);
dock1.SizeInfo.PreferredSize = new Size(200, 200);
dock1.TabIndex = 1;
dock1.Text = "A";

dock3.Location = new Point(1, 24);
dock3.Size = new Size(282, 175);
dock3.SizeInfo.PreferredSize = new Size(200, 200);
dock3.TabIndex = 1;
dock3.Text = "B";

Button btn = new Button();
btn.Click += new EventHandler(btn_Click);
dock3.Controls.Add(btn);

btn.Location = new System.Drawing.Point(0, 0);
btn.Name = "button1";
btn.Size = new System.Drawing.Size(75, 23);
btn.TabIndex = 1;
btn.Text = "button1";
btn.UseVisualStyleBackColor = true;

#endregion
state = new NDockingFrameworkState(manager);
state.Format = PersistencyFormat.XML;
path = "DockStatus.xml";
state.Save(path);
}

void btn_Click(object sender, EventArgs e)
{
state.Load(path);
}

}

I don't know if i have to do something else. in the sample don't appear more interaction with the NDockingFrameworkState object that the save and load. or I have to do something else with the NDockManager?
By Nevron Support - 12 Years Ago
Hello Hector,

In the code snipped I see that Key property of the panels is not set. This could be the problem.
By Hector Medina - 12 Years Ago
Thank you so much it was that. It works great.
By Luis Miguel Perez Lopez - 11 Years Ago
I am doing something similar but, instead of save the layout in a Xml file, I want to save it in a database. Does anybody can help me ?
By Nevron Support - 11 Years Ago
Hello Luis,

What you can do is to save the state in a file and then add it to the database in appropriate database field.
By Luis Miguel Perez Lopez - 11 Years Ago
I've tried to do that:

Dim strim As System.IO.Stream = nothing

state.Save(strim)

but the information is not stored in the variable strim
By Nevron Support - 11 Years Ago
Hello Luis,

The Stream has to be initialized.
By Luis Miguel Perez Lopez - 11 Years Ago
Hi, I've got one solution:

Dim strim As New MemoryStream

state.Save(strim)

Thanks