Eto Panel, multiple trigger of public static controls

Dear Rhino developers,

I have followed example of eto panel from here, and but I have shifted my checkboxes and numericsteppers definition outside “SampleCsEtoPanel” method. User action events are defined inside “SampleCsEtoPanel”, as in example.

It works fine when my controls are not public and not static. To reference some specific logic, I needed to make some of them public and static (which may be already bad design by me…). Those specific controls works fine until I will close panel and open it again - it results in multiple triggering of public static controls. Each opening of my panel results in additional trigger of control when user makes some action with it.

1.) Besides making those controls not public and not static, is there some other solution that could make it work correctly without multitple triggering?

2.) Is it allowed to make eto panel controls public and static?


Hey @mlukasz87,

While I do not recommend to make UI controls static (yes, it is poor design), you will have to unsubscribe all events after the dialog/form is closed. This will be problematic and I do not recommend it.

Another way would be to keep your state static, such as a boolean for a check box, string for a TextBox, etc. If your state includes logic and to keep it all in one manageable place you can put it into a class. This is sometimes called a “view model”.

Hope this helps. If you need more details on how to approach this, a sample of what you have done would help us steer you in the right direction.

Thank you @curtisw, I think I need to revise my code and its concept. I will come back when I will find another too high wall.