I want to create an Eto.Forms.Panel whose component are multiple EtoCollapsibleSection.
The problem is, the values displayed in these EtoCollapsibleSection are calculated at run time (after several RhinoCommands have been ran).
Is there anyway to do this ? As according to the documentation, the whole panel must have zero-parameters. Does this meant it is not possible to pass information into Rhino.UI.Panel ?
MVVM pattern is a solution to bind your View - in this case panel - controls to VieModel properties. ViewModel should communicate with logic in Model to get those values.
With this solution you are separating UI code from your plugin logic.
Thank for your input, but itās not really what iām looking for.
Iām aware of the Model-View-ViewModel design pattern, I can create a View using the Eto.Form.Panel class, and pass data from my model (multiple Rhino Commands) into it just fine.
Iām asking about the specific API call needed to pass initialized value into Rhino.UI.Panel, as the API call only pass the GUID - not specific value.
The panel registering you should actually do in the plug-in OnLoad implementation instead of in the command RunCommand implementation, but otherwise this example should be fine.
Yeah, this was my original example that I followed.
For my case, specifically, at line 49 of CollapsibleSectionUIPanel.cs
SectionOne section1 = new SectionOne();
I need to pass some information obtained from some algorithm (my plugin have multiple commands).
Ideally, It would look something like this
SectionOne section1 = new SectionOne(Dictionary <double, Color> colorDict);
The colorDict variable is not available OnLoad.
Ofc I can register the Panel (as shown in line 37 of CollapsibleSectionUICommand.cs).
However, Iām pretty sure i cannot pass colorDict into this API call.
As such, Iām asking is there any work around ?
You should abstract the need for color dictionary out such that you donāt need to know that at startup. But once you everything is running and you do get a (valid) dictionary with colors youād gave it to you data handling part of your code.
If youāre not doing that youāll end up with conundrums like this.
You should follow the advice of @mlukasz87 . You should be able to set up your GUI without the need for direct access to your data.
Not directly sections in a separate panel, but still here are the collapsible sections as implemented by RhinoCycles, the Cycles integration plug-in for Rhino:
Happy new year!
Iāve looked through SessionSection.cs. Afaik, the code initialized m_throttlems_lb, which are updated in the UI when value changes through an event.
Are you saying I should initialized an empty colorDict, then set up an event that update the UI when colorDict is changed ?
If so, how do I set up a connection from the modelās colorDict (which I calculated) and the UIās colorDict ?
Also, the folder is while big, so iām not even sure that was what you meant.
I set up an event handler. The event is in the core and triggered where it needs to be triggered so that the UI can react to changes in the data. Small, but important difference where the event is published.
I suggest you clone the repository and open up the code in Visual Studio or Visual Studio Code. You should be able to navigate the code a bit better and utilize intellisense capabilities to gain better understanding.
Okay, iāve spent sometime looking through the repo you shown me, and I still have no idea what this has to do with my problem.
Let just say, I have a Rhino.UI.Panel - which contain a EtoCollapsibleSection.
This EtoCollapsibleSection need data from the model.
Then, how do I bind this data to the EtoCollapsibleSection ? Especially the case where EtoCollapsibleSection āliveā inside Rhino.UI.Panel - and has zero ideas that the model existed.
The model you do give to your collapsible section. Just make sure you have a way to update the model and trigger refreshing of your collapsible section implementation via events and handlers.
Thanks, It worked now, although it is kinda āhackyā. Can you give me any suggestion on my current approach:
algorithm calculate colorDict
colorDict is passed into a Singleton(basically a list of calculated number) called session
create a custom Eto.Forms.Panel class, whose contain a private variable pointing to session.
In the init function, pass session into an EtoCollapsibleSection class, as shown below.
public ColorScalePanel()
{
EtoCollapsibleSectionHolder holder = new EtoCollapsibleSectionHolder();
ColorScaleSection section1 = new ColorScaleSection(session.depthColorDict);
holder.Add(section1);
TableLayout tableLayout = new TableLayout()
{
Rows =
{
holder
}
};
Content = tableLayout;
}
Afaik, this is basically pointing straight from the āviewā Eto.Forms.Panel to the āmodelā session, meaning, there isnāt any āviewModelāā as all.
Further down the line, If I wanna include the āviewModelā, are the event logics be coded in here ?
Also, I have another problem regarding Eto.Forms.Label, as shown here.