algorithmic modeling for Rhino
I would like to have a "Settings" component for one of my C# components. I would like to have a win forms pop up when I right-click this component.
Are there any tutorials that would allow you the display a windows form on a Grasshopper canvas?
Thanks!
Tags:
Do not display winform controls directly on the canvas, that's almost always a bad idea. The Panel and Slider currently do display TextBoxes, but it's so much code and so many things can go wrong that I wouldn't recommend it. You can display a menu or a form which contains controls, that is the best solution in my opinion.
When you say "C# component", do you mean the C# script component or are you writing components in Visual Studio C#? It is not possible override mouse clicks for C# Script components.
--
David Rutten
david@mcneel.com
The problem with winforms controls on the canvas is that winforms controls don't 'like' to be zoomed. However your image shows you want a Form, so that's fine.
You'll have to make sure that System.Windows.Forms is referenced in your GHA project. Then create a new Form and place your buttons, sliders, checkboxes etc. on it. If you make all these controls public you might not even have to add any code to the form itself.
Instantiate the form from within your component, set the control states based on your local data, show the form as a modal dialog, wait for the OK return code and read all control states back in. From the component it should look a bit like this:
SettingsForm form = new SettingsForm();
form.StartDate.Value = startDate;
form.EndDate.Value = endDate;
form.DateFrequency.SelectedText = "Daily";
etc.
if (form.ShowDialog(Grasshopper.Instances.DocumentEditor) ==
DialogResult.OK)
{
startDate = form.StartDate.Value;
endDate = form.EndDate.Value;
etc.
}
--
David Rutten
david@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by