Eto.Forms Panel: subscribing to slider.valuechanged event

Hi,

playing around with Eto.Forms, I want to subscribe to the ValueChanged event of a slider placed inside a panel and read the value from my command. Probably missing something obvious, but my experience with Eto and Events is limited so here we go.

Bonus question: how to properly close a panel and end the command using a button on a panel?

EtoFormsSliderTestCommand.cs (4.5 KB)

Hi @rgr,

I can imagine several ways. An easy way is for your ValueChanged handler in your panel can set a property on your command class (e.g. EtoFormsSliderTestCommand.Instance.SliderValue = xxx;). You could event put the handler on the command class itself, depending on what you are trying to do.

Also, there is no easy to way to remotely cancel a running command. If the command is prompting the user for some token, sometimes posting a ! character to the command line will do it. But there are no guarantees.

Just curious, why is your command displaying a panel and not just a dialog box?

– Dale

1 Like

Hi Dale,

thank you for your answer. I`ll investigate ways to implent it and see how it goes.

To your question: I tried out the dialog box, but figured that a) Rhino is blocked during execution and b) i can only query the result once the dialog box is finished as per this line

var dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow);

taken from the “SampleCsEtoModalDialogCommand.cs” example.

What I am ultimatly trying to do is display a viewport in a seperate window with a slider controling the position of a brep on a set of points. For this, the slider value gets mapped to the number of points in a list and the brep transformed to the corresponding point and displayed in a conduit. I cropped that from the code to focus on the actual issue since the rest is more or less running.

I am open to other suggestions on how to handle this.

Marked this as solution since it worked, just like that.

Added the code for anyone curious:
EtoFormsSliderTestCommand.cs (4.9 KB)

Hi @Dale,

one short additional question: is there a way to manually force a ViewportControl to redraw? It is embedded in a panel, if this makes any difference.

I tried redrawing the ParentView but it`s always null, also I can not find any of it in the RhnioCommon API documentation.

Hi @rgr,

The ViewportControl in Rhino.UI in Rhino 6 is very experimental. I doubt has any method on it to force a redraw. I do know, however, that it is getting some attention in the Rhino WIP.

– Dale

1 Like

Hi @Dale,

thank you for your answer.