I’m trying to use Panel.RegisterPanel and Panel.OpenPanel to register my custom UserControl that I want to be docked on left but it doesn’t work. It’s opened next to my mouse and not docked. I’m trying to call OpenPanel and then GetPanel to set the docking and the anchor:
Dim myToolbar as UserControl = getMyToolbar()
Dim myPanel As System.Type = GetType(MyToolbarLeft)
Panels.RegisterPanel(myPlugin, myPanel , "My toolbars", My.Resources.rhino48p256c)
Panels.OpenPanel(myPanel .GUID, True)
myMain = Panels.GetPanel(myPanel .GUID, RhinoDoc.ActiveDoc())
myMain.Dock = DockStyle.Left
myMain.Anchor = AnchorStyles.Left
Please, could you pointing out what I’m doing wrong or maybe provide a simple example how to dock a simple panel?
As far as I know the methods
don’t work in Rhino 8, you can use this one which worked fine for me:
Dim dockBarId as Guid = Rhino.UI.Panels.PanelDockBar(PanelCgWpf.Id);
Rhino.UI.Panels.OpenPanel(dockBarId, YourPanel.Id, True);
I’m trying to migrate from .NET Framework to .NET 7 and I was using System.Windows.Forms and now I see that I have to use WPF.
I’m looking a way to have a WPF DockPanel and my UserControl from System.Windows.Forms inside the dock panel.
You can still use WinForms in Rhino 8.
Here is a sample that you might find helpful.
TestWinFormsPlugin.zip (31.7 KB)
Let me know if you have any questions.
This is not related to the issue of opening the panels, anyway keep in mind that you don’t have to migrate to wpf if you don’t want to (but I would… ^^) as Dale said you can make your panel inheriting from System.Windows.Forms.Control or you can use a WindowsFormsHost (wpf control) to host your WinForms control.
This is very personal, but if you want my point of view that I am also old school… since I changed to WPF, in spite of the headaches that the transition gave me, I am more than happy, if you have to low level draw , I recommend you to do it in GDI, or openGL if it is 3D, but for custom controls WPF it is much better, the only thing that you can miss is the inheritance of controls since it does not exist, but for the rest you will not regret it.
A greeting and if I can help you in something else just let me know.
Thanks Dale and William. It is helpful.
Also, I would like to ask you about an example code of a panel that it is docked to left on load?