C# visual control for editing statements / equatio

2019-07-25 17:13发布

问题:

Basically what i need is an editor for a logical statement or equation or condition. I am looking to do something like what is shown in http://www.youtube.com/watch?v=xFUWtztPibs at 1min 20sec and on, and i thought maybe I'll be re-inventing the wheel and its already there as a control you can just use.

Example: there is a class that has the following properties:

  • variable_name (string)
  • comparator (enum)
  • value (object)

This class represents a condition of a kind:

If <variable_name> <comparator> <value>

which can hold conditions like:

If x != 0
If temp <= 100
If currentChapter > 3

etc.

It can be more complex - like, If 3dpoint(x,y,z) is outside a sphere(x,y,z,r) or even something like if (a>b) and ((3d point is inside a rectangle) or (not(b<c))) etc.

User should be able to edit theese conditions (specifically, the class's properties) in a manner that shown in the video - the condition is displayed in a form of simple text (like Label control), with changeable "parts" highlited and clickable (Label that is a hyperlink), clicking them shows a modal window that allows you to change them.

Like, when you select a new condition from my example, it shows:

If <variable_name> <comparator> <value>

If you click the <comparator>, you are allowed to chose from =, !=, >, <etc and if you click the <variable_name>, you are allowed to chose from list of already used variables or type a new one. After you specify it, labels change to:

If variable_1 != <value>

Of course i can make this kind of interface myself by dynamically adding and removing labels inside some TabLayout control, hooking OnClick events to those of the labels that represent changeable parts, but maybe, just maybe, something like that is already done and available?

Thanks in advance!