You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Overview

This page provides a comprehensive guide on managing and interacting with objects in a Solution 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

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:

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.

  1. Click on the desired object in the Draw (in this case, the Ellipse), in Dynamics / Action.
  2. Select the Action / RunScript option.
  3. In CodeBehind, you can use the following syntax as a reference to identify the Uid of the selected object when the Solution is running:

MyEllipse
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:


Syntax
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);
}


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("SymbolUID") 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.


  • No labels