There is a big bug which breaks Rhino panels UI drawing in SR1.
Opening a panel raises two times the event “VisibleChanged” event.
Closing a panel raises two times the event “VisibleChanged” event but Visibility property is True, in SR0 it was False which is the right one.
Closing the panel makes that all the other panels of the container have the closed panel inside but without any background. (see the following video)
Here the code:
Plugin:
public class PanelBugRh6Sr1PlugIn : PlugIn
{
public PanelBugRh6Sr1PlugIn()
{
Instance = this;
}
public static PanelBugRh6Sr1PlugIn Instance { get; private set; }
protected override LoadReturnCode OnLoad(ref string errorMessage)
{
Panels.RegisterPanel(this, typeof(PanelTestCtrl), "TestPanel", System.Drawing.SystemIcons.Application);
return base.OnLoad(ref errorMessage);
}
}
Open panel command:
public class PanelBugRh6Sr1CommandOpen : Command
{
public PanelBugRh6Sr1CommandOpen()
{
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static PanelBugRh6Sr1CommandOpen Instance { get; private set; }
public override string EnglishName => "PanelBugRh6Sr1CommandOpen";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
return Panels.OpenPanelAsSibling(PanelTestCtrl.Id, PanelIds.Layers) ? Result.Success : Result.Failure;
}
}
Close Panel Command:
public class PanelBugRh6Sr1CommandClose : Command
{
public PanelBugRh6Sr1CommandClose()
{
Instance = this;
}
public static PanelBugRh6Sr1CommandClose Instance { get; private set; }
public override string EnglishName => "PanelBugRh6Sr1CommandClose";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Panels.ClosePanel(typeof(PanelTestCtrl));
return Result.Success;
}
}
Here the example plugin source code with the rhp file: PanelBug_Rh6_Sr1.7z (206.9 KB)
I hope you can fix it soon, so it’s breaking all the workflow of our plugin.
Not looking at the code yet, but you may want to at least want to fix your .csproj to point to the correct RhinoCommon location. It currently has a relative path something like ..\..\..\Program Files\Rhinoceros 6\System\RhinoCommon.dll, but you have it probably installed under C:\Program Files\Rhino 6\System\RhinoCommon.dll
I forgot to replace Rhinocommon path, I updated all references to point to default Rhino installation C:\Program Files\Rhino 6\
now the sample project should work with a default Rhino installation.
I reported this as RH-44287 and am in the process of committing a fix for this issue. The fix should be available in todays Rhino service release preview.
Opening a panel raises VisibleChanged event 3 times (true, false and true)
Opening another panel raises last panel Show event set to Visible=TRUE, next raises last panel Show event 4 times Visible=FALSE
Switching between Rhino or other panels keeps raising hidden panels Show event set to FALSE.
Hidding a panel by code (opening Rhino Properties panel) raises Show event set to TRUE for the current panel 4 times, VisibleChanged event set to False, and finally Show event set to False, (also Show event is raised 2 times per any of the other panels, in this case Panel2)
Closing the panel by code raisesShow event for this panel 7 times set to TRUE but never Show event set to FALSE, also raises VisibleChanged event 2 times (one False and another True, furthermore the Close event 2 times.
Here a video showing the issues:
I would like to remark that every panel Show or Close event has a check like this:
private static void Panels_Show(object sender, ShowPanelEventArgs e)
{
if (e.PanelId != Id) return;
RhinoApp.WriteLine($"Panel 1 Show raised = {e.Show}");
}
So even the event is raised for another panel there is a check which returns if the args Id doesn’t match.
You are correct, the underlying code that activates a panel in a dock bar calls hide on all but the newly active panel tab to ensure the panels visibility state is correct which you can see by the events being raised. The states are correct even if the notifications are redundant. I will take a look in a bit and see if I can filter out redundant events.