Hi Max,
Thanks a lot for looking into this.
I’m using the latest automatic update of Rhino (6.9.18271.20591, 09/28/2018). The plug-in is using RhinoCommon 6.8.18240.20051 via Nuget. The same problem occurs on a different computer, with - I think - a previous build of Rhino 6.
The Windows crash dialog (“This program is not responding…”) mentions a stack overflow exception so it sounds like there’s a nasty loop somewhere in there. I couldn’t find a .dmp file from the crash, unfortunately, unless it’s hiding in some other place?
I have also tried declaring and instantiating the new section within the RenderSettingsCustomSections
instead of making it a member of the plugin class, and have tried leaving out the base class call, to no effect:
public CustomPlugIn()
{
if (Instance == null) Instance = this;
}
public override void RenderSettingsCustomSections(List<ICollapsibleSection> sections)
{
var m_render_section = new CustomRenderSettingsSection();
sections.Add(m_render_section);
base.RenderSettingsCustomSections(sections);
}
Otherwise, I’m not sure how else to narrow down the problem…
The custom render section class looks like this. CustomSection
is the right from the SampleCs examples.
public class CustomRenderSettingsSection: CustomSection
{
private Button m_button;
private CheckBox m_checkbox;
private Label m_button_lb;
private Label m_checkbox_lb;
private Label m_button_clicks_lb;
private Label m_checkbox_value_lb;
private int m_clicks;
private LocalizeStringPair m_caption;
public CustomRenderSettingsSection()
{
m_caption = new LocalizeStringPair("CustomRender", "CustomRender");
InitializeComponents();
InitializeLayout();
RegisterControlEvents();
}
public override LocalizeStringPair Caption
{
get
{
return m_caption;
}
}
public override int SectionHeight
{
get
{
return 80;
}
}
private void InitializeComponents()
{
m_clicks = 0;
m_button = new Button()
{
Text = "Button"
};
m_checkbox = new CheckBox();
m_button_lb = new Label()
{
Text = "",
VerticalAlignment = VerticalAlignment.Center,
Width = 20
};
m_checkbox_lb = new Label()
{
Text = "",
VerticalAlignment = VerticalAlignment.Center,
Width = 20
};
m_button_clicks_lb = new Label()
{
Text = "Number of clicks: ",
VerticalAlignment = VerticalAlignment.Center,
};
m_checkbox_value_lb = new Label()
{
Text = "Custom User Data",
VerticalAlignment = VerticalAlignment.Center,
};
m_checkbox_lb.Text = m_checkbox.Checked.ToString();
m_button_lb.Text = m_clicks.ToString();
}
private void InitializeLayout()
{
TableLayout layout = new TableLayout()
{
// Padding around the table
Padding = 10,
// Spacing between table cells
Spacing = new Eto.Drawing.Size(15, 15),
Rows =
{
new TableRow(m_button_clicks_lb, m_button_lb, m_button),
new TableRow(m_checkbox_value_lb, m_checkbox, m_checkbox_lb)
}
};
Content = layout;
}
private void RegisterControlEvents()
{
m_checkbox.CheckedChanged += OnCheckedChanged;
m_button.Click += OnButtonClick;
}
private void UnRegisterControlEvents()
{
m_checkbox.CheckedChanged -= OnCheckedChanged;
m_button.Click -= OnButtonClick;
}
private void OnLoadComplete(object sender, EventArgs e)
{
}
private void OnCheckedChanged(object sender, EventArgs e)
{
m_checkbox_lb.Text = m_checkbox.Checked.ToString();
if (m_checkbox.Checked != null)
{
bool checked_state = (bool)m_checkbox.Checked;
}
}
private void OnButtonClick(object sender, EventArgs e)
{
m_clicks++;
m_button_lb.Text = m_clicks.ToString();
}
}