I have a Rhinoceros 5 plugin that handles two panels as System.Windows.Forms.UserControl. These panels are registered with the RhinoCommon method Rhino.UI.Panels.RegisterPanel. I don’t create these usercontrols in my plugin, the instances are created by Rhinoceros at startup.
In Rhinoceros 5 the usercontrols were created only at Rhinoceros startup. When the user opened a different project, the usercontrols linked to the new viewport3D internals.
Now with Rhinoceros 7 the usercontrols are created at each project change (New Project or Open Project). I had a static event that had to be redirected to prevent memory leak.
Is this behavior known or it is a bug on my code? If there is a guideline on the matter, I’d like to know.
In Rhinoceros 5 the panel is created only at the first project opened.
In Rhinoceros 7 the panel is created at each project change (New Project or Open Project).
If you review the help for Panels.RegisterPanel, you’ll notice that there was an override added to Rhino 6 that takes a PanelType parameter. This was added in support of Rhino for Mac, which is a multi-document application. If you call the overide without the PanelType paraemter, a panel type of PanelType.PerDoc is used. This is why your panel’s constructor is being called multiple times.