Panel Visibility


#1

Hi,

I developing currently a plugin. This plugin use a panel that I’m open and close with the Rhino.UI.Panels.OpenPanel/ ClosePanel method. This works very well. But how can I determine that the panel is switch off in Rhino? Is there a way how can I detect when the form will closing?

Thanks
Holger


How to add a "Tab" to Properties
(Dale Fugier) #2

Hi Holger,

The panel sample here:

https://github.com/dalefugier/SampleCsPanel

shows you how to detect when the form is closing.


#3

Thanks dale,

I know this sample but it doesn’t work. And this is my problem.
To make it sure I downloaded again and I made it runable with Rhino5, but no chance to catch the Disposed event :frowning:

Any other ideas?

Thanks
Holger


(Menno Deij - van Rijswijk) #4

As far as I know there is no need to catch the Disposed. You can use this code to see if it is visible or not:

System.Guid panelId = SampleCsPanelUserControl.PanelId;
bool bVisible = Rhino.UI.Panels.IsPanelVisible(panelId);


(Dale Fugier) #5

Yes this is true. The confusion might be in that the form is not destroyed when the user closes the panel - it is just hidden.


#6

Ok, but I´m looking for a possibility to react in the moment when the user closing/hiding the panel. Is there no other way? Should I look secondly if the panel is still visible? I tested all events in the window forms controls but not one of them is usable for my purpose.


#7

just for the record:
the best result is delivering by the VisibleChanged event. But this event didn’t happens when do you closing a panel with the “redcross” of a free panel. Only when closing with ClosePanel function or in Rhino by unticking the hook in the list of the available panles.

best
Holger


(Dale Fugier) #8

Hi Holger,

The UserControl you register as a Panel is nested inside of a windows, which is nested inside of a tabbed window, which is nested inside of a docking frame window.

When you click the “X” to close the docking frame, you are only effecting the docking frame itself, which is why your UserControl’s VisibleChanged event is not triggered.

A docking dialog, created in C++, receives these types of events because the class you must inherit from provides virtual functions for these events. The RhinoCommon implementation is much simpler - all you have to do is create a UserControl and register it as a panel.

One solution would be for us to provide some events on Rhino.UI.Panels that you could subscribe to if you wanted to be notified if your tab was shown or hidden, or if the owning dockbar was shown or hidden. I’ve add a request for such events to the RhinoCommon wish list.

– Dale


#9

Thank you Dale,

even if this not the answer that I’m waiting for :frowning:

And before im starting witht it, I would like to ask what do you think: could it be a solution to develope a “partiell” c++ plug-in to catch this event and forward this to the RhinoCommon plug-in?

Holger


(Dale Fugier) #10

Why do you need to know when tab is closed?


#11

My plug-in is connected to digital cutting device like this http://www.zund.com/ via a serial port. I constantly make querries to the device, write the responds to the display conduit and depending on the answers of the cutter I manipulating the geometry. To close down all this things in a proper way when the panel disappear would be really helpful. A “shutdown” button doesn’t work. Every second user ignore this and is surprised about all the “mystery” things that still happens in the background.

And I don’t want to wait until a wish comes true and this capability will implemented in the api. The point is not my weak c++ knowledge, but I haven’t any experience with the rhino c++ sdk the figured out if its possible to make such a hack.

Holger


(Menno Deij - van Rijswijk) #12

Rather than using the Rhino panel to embed your form, why not use a “normal” win forms window or WPF window? You won’t be able to dock it, but if you set the parent window to the rhino main window, it will float on the Rhino window. Then you can “really” close it and catch the event Closed.

We use this strategy all the time & it works very well.

Let me know if you need some example code how to do this.


#13

Hi,

I’m having exactly the same problem.

We used to enable/disable our timers with the visibility_changed of the main form. We control different things in the timer so it’s not a good idea to have them running all the time. The visibility_changed event no longer ensures us this will be happening, so it would be useful to have a new event in the panels we could use.


#14

Hi Dale,

You said you would be adding the event to the wishlist, but since that was 4 months ago and thread opener said he didnt need it, I was wondering if it still is.


(Dale Fugier) #15

Hi José,

I just confirmed the wishes (for tabbed dockbar events) is on the wish list. You will need these events if you wan to know when your tab has been hidden or has been displayed, when your dockbar has been moved, etc.


#16

Yes, that’s the point. An event where where we can centralize all the logic regarding plug-ins showing/hiding regardless of how they were showed/hided.

Thanks!!!