Nevron Forum

Docking NUIDocuments? (code)

https://www.nevron.com/Forum/Topic4328.aspx

By Fábio Mello - Friday, October 15, 2010

How can I make an initial display of NUIDocuments docked in a similar way to the sample attached?
By Nevron Support - Friday, October 15, 2010

Hello Fábio,

To dock the panels as they are in the attached image, you need to use one of the DocumentManager.AddDocument overloads.

When you first add a NUIDocument to the DocumentManager.Documents collection it initialize an ActiveGroup property which will holds the panels that are added to the Documents collection without specifying the group explicitly.

When you add the rest of the panels you should specify the group they will reside and how they should be docked.

Please, check the code snipped below which shows how you can achieve the desired state of the panels:

NUIDocument doc1 = new NUIDocument("Doc1");
NUIDocument doc2 = new NUIDocument("Doc2");
NUIDocument doc3 = new NUIDocument("Doc3");
NUIDocument doc4 = new NUIDocument("Doc4");

NDocumentManager documentManager = nDockManager1.DocumentManager;
//This will create documentManager.ActiveGroup which we will use below.
documentManager.AddDocument(doc1);

NDocumentHost activeGroup = documentManager.ActiveGroup;
nDockManager1.DocumentManager.AddDocument(doc2, activeGroup,
DockStyle.Fill);
nDockManager1.DocumentManager.AddDocument(doc3, activeGroup,
DockStyle.Right);
nDockManager1.DocumentManager.AddDocument(doc4, activeGroup.RootZone,
DockStyle.Bottom);

By Fábio Mello - Wednesday, October 20, 2010

Thank you very much.

My problem is solved.
By Fábio Mello - Thursday, October 21, 2010

One more thing, is there a RightClick event in the NUIDocuments header? (I'd like to expand a dropdown list of general commands by rightclicking the NUIDocument's header like the tab groups in Visual Studio's editor)

Thanks in advance
By Nevron Support - Thursday, October 21, 2010

Hello Fábio,

I guess you want to display context menu on the NUIDocument when the DocumentViewStyle is MdiTabbed.

There is no event exposed directly, but you can use the following workaround:

NDocumentPanel host = nDockManager1.DocumentManager.ActiveDocument.Host as NDocumentPanel;
if (host != null)
{
    NTabStrip tabStrip = host.Parent.Controls[0] as NTabStrip;
    if (tabStrip != null)
    {
        tabStrip.MouseClick +=
new MouseEventHandler(tabStrip_MouseClick);
    }
}

...

void tabStrip_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        NDocumentPanel host = nDockManager1.DocumentManager.ActiveDocument.Host as NDocumentPanel;
        if (host != null)
        {
            NTabStrip tabStrip = host.Parent.Controls[0] as NTabStrip;
            if (tabStrip != null)
            {
                NContextMenu menu = new NContextMenu();
                //Add some commands.
                menu.Show(MousePosition);
                //To determine on which tab you have clicked you can use:
                NTab clickedTab = tabStrip.Tabs.TabFromPoint(e.Location);

            }
        }
    }
}

By Fábio Mello - Friday, October 22, 2010

Thank you for the response.

In which assembly is the class NDocumentPanel?
I couldn't find it.

I use Nevron .NET Vision for VS2008.
By Nevron Support - Monday, October 25, 2010

Hi Fabio,

NDocumentPanel is in Nevron.UI.WinForm.Docking assembly.

By Fábio Mello - Tuesday, October 26, 2010

Hi,

This is very strange.
NDocumentPanel is not in my Nevron.UI.WinForm.Docking assembly.
By Nevron Support - Wednesday, October 27, 2010

Hi Fabio,

You might not see it because it has EditorBrowsableAttribute set to Never.