komorra / NodeEditorWinforms

Node based user control / editor for Windows Forms
MIT License
507 stars 142 forks source link

Great job....but how to.... #6

Open nicolad76 opened 6 years ago

nicolad76 commented 6 years ago

Hi, really love what you did...but I need some guidance on how to develop nodes with complex logic. For instance I would like to make a node that takes an INT as input and it output TRUE/FALSE is the value is above a set number. The number must be entered in a text box on the node. How do I add the text box or other components to a node?

Thx!!!

komorra commented 3 years ago

The feature (referencing custom editors of nodes) was added by commit bffbe6d028745767b5e159de645db414f81d0d90 . If I understand you correctly this could be done via the following node code in your context class:

[Node("IsGreater",customEditor:typeof(NumericUpDown))]
public void IsGreater(int input, out bool output)
{
    var userThreshold = (int)(CurrentProcessingNode.CustomEditor as NumericUpDown).Value;
    output = input > userThreshold;
}

The final effect is shown in the image below: image