Overview
This page provides a comprehensive guide on managing and interacting with objects in a project using Draw, Dynamics, and CodeBehind. The main focus is on manipulating these objects using their unique identification number (Uid), moving them within the display, and accessing their properties via script. An important aspect discussed here is the GetControl method that allows control over symbols created on the screen. The guide also notes the limitation of the #Source property, which currently cannot be accessed through the code.
On this page:
GetControl Method
Acess to created symbol properties via script
To differentiate the objects being used in a project, it's important to identify the information presented in the Draw, such as the Type, which refers to the object type, and the Uid, representing the unique identification number of the object.
In the Layout box, you can move the object to the desired location on the display according to the desired width and height, as shown in the image below:
In the Dynamics > Config > MoveDrag tab, you can use a reference tag to move the object. In this way, when the tag value is changed, either through the use of a bargraph or a script, the object will move on the display as desired.
- Click on the desired object in the Draw (in this case, the Ellipse), in Dynamics > Action.
- Select the Action > RunScript option.
- In CodeBehind, you can use the following syntax as a reference to identify the Uid of the selected object when the project is running:
To identify the Uid of the object with a mouse click through the code, for example: int UidObject= me.Uid;
You can use the sender parameter to obtain an object from whom the function was called. In this way, there will be no need to manually write each Uid.
Consider the syntax below:
Handling Unavailable #Source in Code
To create a symbol and access its properties via a script, place a created symbol on the screen with a specific Uid and access its properties via the code.
You can control the symbol created on the screen through its Uid using the GetControl method. Here's an example of how to do this using Code Behind:
TSymbol s = this.CurrentDisplay.GetControl("simboloUID") as TSymbol;
In the code above, we are locating the symbol created on the screen through its Uid and defining it as an object for the variable s. Thus, when you type "s.", it will be possible to access all the properties of the symbol.
Please note that the #Source property is not currently accessible via the code.
In this section...