GetControl Method
Access to created symbol properties via script
To differentiate the objects being used in a Solution, 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:
Expand |
---|
|

|
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.
Expand |
---|
|

|
- 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 Solution is running:
Expand |
---|
|
Image Added
|
Expand |
---|
|
Code Block |
---|
| private Ellipse MyEllipse;
//Note that for each object, it is necessary to use this public void again
public void MouseLeftButtonDown1 (object sender, System.Windows.Input.InputEventArgs e)
{
string Uid = "22";
fc(Uid) ;
}
public void MouseLeftButtonDown2 (object sender, System.Windows.Input.InputEventArgs e)
{
string Uid = "44";
fc(Uid);
}
public void fe (string ReceivedUid)
{
this.MyEllipse = this.CurrentDisplay.GetControl (ReceivedUid) as Ellipse;
MyEllipse.Margin = new Thickness (@Tag.Left, @Tag.Top, 0, 0);
@Info.Trace(MyEllipse.Uid);
} |
|
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:
Expand |
---|
|
Code Block |
---|
| public void MouseLeftButtonDownl (object sender, System.Windows.Input.InputEventArgs e)
{
var obj = sender as Ellipse;
fc(obj);
}
public void MouseLeftButtonDown2 (object sender, System.Windows.Input.InputEventArgs e)
{
var obj = sender as Ellipse;
fc(obj);
}
public void MouseLeftButtonDown3 (object sender, System.Windows.Input.InputEventArgs e)
{
var obj = sender as Ellipse;
fc(obj);
}
public void fc(Ellipse obj)
{
obj.Margin = new Thickness(@Tag.Left, @Tag.Top, 0, 0);
@Info.Trace (obj.Uid);
}
|
|