DockablePanel Dock On a Side?

Hi,

I have been searching the forum, but can’t find anywhere how to automatically dock a panel.
When I open my panel it is always somewhere flying on the screen.

How to dock a panel on the left or right side with RhinoCommon?

1 Like

How do you make your panel?
For dockable panels (like the Layer panel) you need to register your panel during plug-in start-up:

protected override LoadReturnCode OnLoad(ref string errorMessage)
{
  Panels.RegisterPanel(this, typeof(MyPanel), "My Super Panel", MyPanelIcon);
  return base.OnLoad(ref errorMessage);
}

and your class MyPanel should inherit from System.Windows.Forms.UserControl

I register it like this:

Dim PanelType As System.Type = GetType(LutraCAD_Panel)
Rhino.UI.Panels.RegisterPanel(Me, PanelType, "LutraCAD", My.Resources.Logo)

Then i show it like this:

Dim bVisible As Boolean = Panels.IsPanelVisible(panelId)
If Not bVisible Then
     Panels.OpenPanel(panelId)
End If

Sow how do I automatically dock it on the side?

Ah, I see. I think you might be able to use Panels.OpenPanelAsSibling

I use this:

Guid[] open = Panels.GetOpenPanelIds();
Panels.OpenPanelAsSibling(myPanelId, open.FirstOrDefault());

I’m not sure what happens if there are no panels open

I now read that you can also use the Layers Panel Id like so, should be more robust:

OpenPanelAsSibling(myPanelId, PanelIds.Layers);
1 Like

Oke this seems to work, Thank you.

I first open the panel as sibling then I close rest of the panels.
So my panel stays docked :slight_smile:

I’ve got Layer panel out,like
Guid[] panelIds = { Rhino.UI.PanelIds.Layers, Rhino.UI.PanelIds.ObjectProperties };
foreach (var item in panelIds)
{
Panels.OpenPanel(item);
}

But I don’t know how to dock them on the right of the screen(the Layer panel and Properties panel flying on the screen now).Any replies would be appreciated.

Hi @310440338,

This is not possible in RhinoCommon. You can get the CRhinoUiDockBar associated with a panel in the C++ SDK then do whatever you want. But there is currently no direct access to it in RhinoCommon.

– Dale