Public Member Functions | Properties | List of all members
PropertyContainer Interface Reference

Access and configure property values. More...

Inheritance diagram for PropertyContainer:
ProjectItem Trigger ProjectItemLibrary< out out T > MessageTrigger

Public Member Functions

object Get (string propertyName)
 Gets the value of a property. More...
 
object Get (Property property)
 Gets the value of a property. More...
 
Get< T > (TypedProperty< T > property)
 Gets the value of a property. More...
 
void Set (string propertyName, object value)
 Sets the value of a property. More...
 
void Set< T > (TypedProperty< T > property, T value)
 Sets the value of a property. More...
 

Properties

IEnumerable< PropertyProperties [get]
 Gets the properties in a project item or node component. More...
 

Detailed Description

Access and configure property values.

Member Function Documentation

object Get ( string  propertyName)

Gets the value of a property.

Parameters
propertyNameThe name of the property whose value you want to get.
Returns
The value of the property.
See also
Get(Property), Get<T>(TypedProperty<T>), Set(string, object), Set<T>(TypedProperty<T>, T), Project.GetProjectItem(string), Project.CreateProjectItem<T>(string, ProjectItem)

Examples

To get the value of a property in a node using the name of the property:

public void Execute(PluginCommandParameter parameter)
{
// Get the node to which you want to add a node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Get the background brush of the RootPage node you got in the previous line.
var bgBrush = rootPage.Get("Node2D.BackgroundBrush");
// Create a Page node named Home in the RootPage node.
var homePage = studio.ActiveProject.CreateProjectItem<Page>(
rootPage.GenerateUniqueChildName("Home"), rootPage);
// Set the Background Brush property of the Home node to the brush that you got.
homePage.Set("Node2D.BackgroundBrush", bgBrush);
object Get ( Property  property)

Gets the value of a property.

Parameters
propertyThe property whose value you want to get.
Returns
The value of the property.
See also
Get(string), Get<T>(TypedProperty<T>), Set(string, object), Set<T>(TypedProperty<T>, T), Project.GetProjectItem(string)

Examples

To get the values of all properties in a node:

public void Execute(PluginCommandParameter parameter)
{
// Get the node whose property values you want to get.
var screenNode = studio.ActiveProject.GetProjectItem("Screens/Screen");
// Iterate through the properties of the node and for each property print to the Kanzi Studio Log window:
// - Property name as it is shown in Kanzi Studio
// - Property value
foreach (var property in screenNode.Properties)
{
studio.Log(property.DisplayName + ": " + screenNode.Get(property));
}
}
T Get< T > ( TypedProperty< T >  property)

Gets the value of a property.

Template Parameters
TThe type of the property whose value you want to get.
Parameters
propertyThe property whose value you want to get.
Returns
The value of the property.
See also
Get(string), Get(Property), Set(string, object), Set<T>(TypedProperty<T>, T), ProjectItemLibrary<T>.GetItemByName(string)

Examples

To get the value of a property in a resource:

public void Execute(PluginCommandParameter parameter)
{
// Get the DefaultBackground texture in the Textures library.
var defaultBackgroundTexture = studio.ActiveProject.TextureLibrary.GetItemByName("DefaultBackground");
// Get the image that the DefaultBackground texture shows.
var defaultBackground = defaultBackgroundTexture.Get(Properties.TextureImage);
// Print the path to the image file to the Kanzi Studio Log window.
studio.Log(defaultBackground.FileSystemPath);
}
void Set ( string  propertyName,
object  value 
)

Sets the value of a property.

Parameters
propertyNameThe name of the property whose value you want to set.
valueThe value to which you want to set the property.
See also
Get(string), Project.GetProjectItem(string), Project.CreateProjectItem<T>(string, ProjectItem)

Examples

To set the values of properties in triggers and actions using the names of the properties:

public void Execute(PluginCommandParameter parameter)
{
// In the RootPage node create a Button 2D node named My Button.
var myButton = studio.ActiveProject.CreateProjectItem<Button2D>(
"My Button",
studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage"));
// In the My Button button get the first Button: Click trigger.
var clickTrigger = myButton.Triggers.First(
trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// In the Button: Click trigger create a Write Log action.
var writeLogAction = clickTrigger.CreateAction(Properties.MessageWriteLog);
// In the Write Log action set the Log Message to "Button clicked!".
writeLogAction.Set("MessageArgument.WriteLog.Message", "Button clicked!");
// In the trigger settings disable the Set Message Handled property.
clickTrigger.Set("MessageTrigger.SetHandled", false);
}
void Set< T > ( TypedProperty< T >  property,
value 
)

Sets the value of a property.

Template Parameters
TThe type of the property whose value you want to set.
Parameters
propertyThe property whose value you want to set.
valueThe value to which you want to set the property.
See also
Get<T>(TypedProperty<T>), Project.GetProjectItem(string), Project.CreateProjectItem<T>(string, ProjectItem)

Examples

To set the value of a property in a node to a resource:

public void Execute(PluginCommandParameter parameter)
{
// Get the node to which you want to add a node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Get the resource reference to the background brush of the RootPage node
// you got in the previous line.
var bgBrush = rootPage.Get(Properties.Node2DBackgroundBrush);
// Create a Page node named Home in the RootPage node.
var homePage = studio.ActiveProject.CreateProjectItem<Page>(
rootPage.GenerateUniqueChildName("Home"), rootPage);
// Set the Background Brush property of the Home node to the brush that you got.
homePage.Set(homePage.PropertyTypes.Node2DBackgroundBrush, bgBrush);
}

Property Documentation

IEnumerable<Property> Properties
get

Gets the properties in a project item or node component.

See also
ProjectItem, NodeComponentHost