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

Configure trigger actions. More...

Inheritance diagram for Trigger:
PropertyContainer MessageTrigger

Public Member Functions

Action CreateAction (ActionProperty actionProperty)
 Creates a trigger action. More...
 
MessageAction CreateAction (MessageProperty actionProperty, string routingTargetRelativePath)
 Creates a message action and specifies a relative path to the target item to which the message will be dispatched. More...
 
MessageAction CreateAction (MessageProperty actionProperty, ProjectItem routingTarget)
 Creates a message action and specifies the target item to which the message will be dispatched. More...
 
MessageAction CreateAction (MessageProperty actionProperty, ProjectItemReference< ExportedPropertyContainerItem > routingTargetReference)
 Creates a message action and specifies a reference to the target item to which the message will be dispatched. More...
 
MessageAction CreateAction (MessageProperty actionProperty, ProjectItemReference< ExportedPropertyContainerItem > routingTargetReference, uint delay)
 Creates a message action. More...
 
Action CreateAction (Action sourceAction)
 Creates a trigger action by copying an existing action. More...
 
MessageAction CreateAction (MessageAction sourceAction)
 Creates a message action by copying an existing action. More...
 
TriggerCondition CreateCondition ()
 Adds a condition under which Kanzi sets off a trigger. More...
 
TriggerCondition CreateCondition (TriggerCondition sourceCondition)
 Adds a trigger condition by copying an existing condition. More...
 
bool DeleteAction (Action action)
 Deletes an action. More...
 
bool DeleteCondition (TriggerCondition condition)
 Deletes a trigger condition. More...
 
- Public Member Functions inherited from PropertyContainer
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< Action > Actions [get]
 Gets the actions in a trigger. More...
 
IEnumerable< TriggerConditionConditions [get]
 Gets the conditions in a trigger. More...
 
TriggerProperty TriggerProperty [get]
 Gets the type of the trigger. More...
 
- Properties inherited from PropertyContainer
IEnumerable< PropertyProperties [get]
 Gets the properties in a project item or node component. More...
 

Detailed Description

Configure trigger actions.

An action is an outcome of a trigger. There are general actions like Set Property, Write Log, and message actions you can use to control a specific type of item, such as Go to State, or Navigate to Page.

See also
NodeComponentHost, TriggerCondition, MessageTrigger

Member Function Documentation

Action CreateAction ( ActionProperty  actionProperty)

Creates a trigger action.

Parameters
actionPropertyThe name of the action you want to create.
Returns
The trigger action.

Examples

To create a Write Log action:

public void Execute(PluginCommandParameter parameter)
{
// Create a Button 2D node named Click in the RootPage node.
var buttonClick = studio.ActiveProject.CreateProjectItem<Button2D>(
"Click",
studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage"));
// Get the first Button: Click trigger in the Click button.
var clickTrigger =
buttonClick.Triggers.First(
trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Write Log action in the Button: Click trigger.
var writeLogAction = clickTrigger.CreateAction(Properties.MessageWriteLog);
// Set the Log Message in the Write Log action to "Button clicked".
writeLogAction.Set(Properties.MessageArgumentWriteLogMessage, "Button clicked");
}

To create a Set Property action:

// This example creates a button with a Set Property action in the Button: Click trigger.
// When you click the button, the Set Property action sets the value of the Layout Width
// property in the parent node of the button.
public void Execute(PluginCommandParameter parameter)
{
// Create a Button 2D node named Resize in the RootPage node.
var buttonSetWidth = studio.ActiveProject.CreateProjectItem<Button2D>(
"Resize",
studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage"));
// Get the first Button: Click trigger in the Resize button.
var clickTrigger =
buttonSetWidth.Triggers.First(
trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Set Property action in the Button: Click trigger.
var setPropertyAction = clickTrigger.CreateAction(Properties.KanziSetPropertyAction);
// Create a reference to the parent node of the Button 2D node.
ProjectItemReference<ExportedPropertyContainerItem> routingTarget = new NodeReference<Button2D>("..");
// Set the Target Item in the Set Property action to the parent node of the Resize button.
// Target Item is the node to which the action is applied.
setPropertyAction.Set(Properties.MessageArgumentSetPropertyActionTargetObjectPath, routingTarget);
// Set Target Property in the Set Property action to Layout Width.
// Target Property is the property to which to apply the new value.
setPropertyAction.Set(Properties.MessageArgumentSetPropertyPropertyType, Properties.NodeWidth);
// Set Target Property Attribute in the Set Property action to Whole property.
setPropertyAction.Set(
Properties.MessageArgumentSetPropertyPropertyAttribute,
AnimationTargetPropertyAttributeEnum.WHOLE_PROPERTY);
// Set Fixed Value to 500.
setPropertyAction.Set(Properties.MessageArgumentSetPropertyPropertyValue.Name, 500.0f);
}
MessageAction CreateAction ( MessageProperty  actionProperty,
string  routingTargetRelativePath 
)

Creates a message action and specifies a relative path to the target item to which the message will be dispatched.

Parameters
actionPropertyThe name of the action you want to create.
routingTargetRelativePathRelative path to the target item to which you want to dispatch the message.
Returns
The message action.

Examples

To create a message action and specify a relative path the to target item:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Page node named Page1 in the RootPage node.
var page1 = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Page1"), rootPage);
// Set the Default Subpage property of the RootPage node to the Page1 node.
rootPage.Set(Properties.PageHostDefaultSubPage.Name, "Page1");
// Create a Page node named Page2 in the RootPage node.
studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Page2"), rootPage);
// Create a Button 2D node named "Next" in the RootPage node.
var nextButton = studio.ActiveProject.CreateProjectItem<Button2D>("Next", rootPage);
// Create a Text Block 2D node named "Next page" in the Next button.
var buttonLabel = studio.ActiveProject.CreateProjectItem<TextBlock2D>("Next page", nextButton);
// Set the Text property of the Text Block 2D node to Next page.
buttonLabel.Set(Properties.TextBlockConceptText, "Next page");
// Get the first Button: Click trigger in the Next button.
var clickTrigger =
nextButton.Triggers.First(
trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Navigate To Page action, use a relative path to set Target Item to the Page2 node.
clickTrigger.CreateAction(Properties.MessagePageNavigate, "../Page2");
}
MessageAction CreateAction ( MessageProperty  actionProperty,
ProjectItem  routingTarget 
)

Creates a message action and specifies the target item to which the message will be dispatched.

Parameters
actionPropertyThe name of the action you want to create.
routingTargetThe target item to which you want to dispatch the message.
Returns
The message action.

Examples

To create a message action and specify a target item:

// This example creates a state manager with a state that sets the background color of the RootPage node,
// and a button with a Go To State action in the first Button: Click trigger.
// When you click the button, the background color of the RootPage node changes.
public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores the state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named My State Manager in the State Managers library.
var myStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("My State Manager"),
stateManagerLibrary);
// Create a state group named My State Group in the My State Manager state manager.
var myStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("My State Group"),
myStateManager);
// Create a state named My State in the My State Group state group.
var myState = studio.ActiveProject.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("My State"),
myStateGroup);
// Create a state object named RootPage in the My State state.
var myStateObject = studio.ActiveProject.CreateProjectItem<StateObject>(
myState.GenerateUniqueChildName("RootPage"),
myState);
// Get the Brushes library in the Library > Materials and Textures which stores all the Brushes
// in a Kanzi Studio project.
var brushLibrary = studio.ActiveProject.BrushLibrary;
// Create a Color Brush named Blue Brush in the Brushes Library.
var blueBrush =
studio.ActiveProject.CreateBrush(
brushLibrary.GenerateUniqueChildName("Blue Brush"),
brushLibrary,
BrushTypeEnum.COLOR);
// Create a blue color.
var blueColor = System.Windows.Media.Color.FromArgb(255, 0, 0, 255);
// Set the color of the Blue Brush brush to the blue color.
blueBrush.Set(blueBrush.PropertyTypes.ColorBrushColor, blueColor);
// Add and set the Background Brush in the RootPage state object to Blue Brush.
myStateObject.AddProperty(Properties.Node2DBackgroundBrush);
myStateObject.Set(Properties.Node2DBackgroundBrush.Name, blueBrush);
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Set the State Manager property of the RootPage node to MyStateManager.
rootPage.Set(Properties.NodeStateManager.Name, myStateManager);
// Create a Button 2D node named "Go Blue" in the RootPage node.
var goButton = studio.ActiveProject.CreateProjectItem<Button2D>(
"Go Blue",
rootPage);
// Create a Text Block 2D node in the Go Blue button.
var buttonLabel = studio.ActiveProject.CreateProjectItem<TextBlock2D>("Label", goButton);
// Set the Text property of the Text Block 2D node to Go Blue.
buttonLabel.Set(Properties.TextBlockConceptText, "Go Blue");
// Get the first Button: Click trigger in the Go Blue button.
var clickTrigger =
goButton.Triggers.First(
trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Go To State action and set Target Item to the RootPage node.
var goToStateAction = clickTrigger.CreateAction(Properties.MessageStateManagerGoToState, rootPage);
// Set State to My State.
goToStateAction.Set(Properties.MessageArgumentStateManagerState.Name, "My State");
}
MessageAction CreateAction ( MessageProperty  actionProperty,
ProjectItemReference< ExportedPropertyContainerItem >  routingTargetReference 
)

Creates a message action and specifies a reference to the target item to which the message will be dispatched.

Parameters
actionPropertyThe name of the action you want to create.
routingTargetReferenceReference to the target item to which you want to dispatch the message.
Returns
The message action.
MessageAction CreateAction ( MessageProperty  actionProperty,
ProjectItemReference< ExportedPropertyContainerItem >  routingTargetReference,
uint  delay 
)

Creates a message action.

Parameters
actionPropertyThe name of the action you want to create.
routingTargetReferenceReference to the target item to which you want to dispatch the message.
delayThe delay in milliseconds after which the trigger sets off the action.
Returns
The message action.

Examples

To create an action:

// This example creates two Page nodes, Intro and Main, in the RootPage node, and sets the Default Subpage
// property of the RootPage node to Intro. It then adds a Navigate to Page action to the Page Activated trigger
// in the Intro Page node. The action is set off after a delay of two seconds and navigates to the Main Page node.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Page node named Intro in the RootPage node.
var introPage = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Intro"), rootPage);
// Set the Default Subpage property of the RootPage node to the Intro node.
rootPage.Set(Properties.PageHostDefaultSubPage.Name, "Intro");
// Create a Page node named Main in the RootPage node.
studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Main"), rootPage);
// Get the first Page Activated trigger in the Intro Page node.
var pageActivatedTrigger =
introPage.Triggers.First(trigger => trigger.TriggerProperty == Properties.MessagePageActivated);
// Create a routing target reference from the Intro Page node to the Main Page node.
ProjectItemReference<ExportedPropertyContainerItem> routingTarget = new NodeReference<Page>("../Main");
// Create a Navigate To Page action, set Target Item to the Main Page node, and set the action delay to 2000 ms.
pageActivatedTrigger.CreateAction(Properties.MessagePageNavigate, routingTarget, 2000);
}
Action CreateAction ( Action  sourceAction)

Creates a trigger action by copying an existing action.

Parameters
sourceActionThe action you want to copy to create a new action.
Returns
The trigger action.

Examples

To create an action from another action:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Button 2D node in the RootPage node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// Get the first Button: Click trigger in the Button 2D node.
var clickTrigger =
button.Triggers.First(trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Write Log action in the Button: Click trigger.
var writeLogAction1 = clickTrigger.CreateAction(Properties.MessageWriteLog);
writeLogAction1.Set(Properties.MessageArgumentWriteLogMessage, "Source action");
// Create another Write Log action by copying the one you already creatd.
clickTrigger.CreateAction(writeLogAction1);
}
MessageAction CreateAction ( MessageAction  sourceAction)

Creates a message action by copying an existing action.

Parameters
sourceActionThe action you want to copy to create a new action.
Returns
The message action.
TriggerCondition CreateCondition ( )

Adds a condition under which Kanzi sets off a trigger.

Returns
The trigger condition.
See also
TriggerCondition

Examples

To create an empty trigger condition:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Button 2D node in the RootPage node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// Get the first Button: Click trigger in the Button 2D node.
var clickTrigger =
button.Triggers.First(trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create an empty trigger condition for the first Button: Click trigger in the Button 2D node.
var triggerCondition = clickTrigger.CreateCondition();
}
TriggerCondition CreateCondition ( TriggerCondition  sourceCondition)

Adds a trigger condition by copying an existing condition.

Parameters
sourceConditionThe trigger condition you want to copy to create a new trigger condition.
Returns
The trigger condition.
bool DeleteAction ( Action  action)

Deletes an action.

Parameters
actionThe action you want to delete.
Returns
True when it deletes the action successfully, otherwise false.

Examples

To delete an action:

// To delete a trigger action you first have to get the trigger and the action, and then use the DeleteAction
// function to delete the action.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Button 2D node in the RootPage node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// Get the first Button: Click trigger in the Button 2D node.
var clickTrigger =
button.Triggers.First(trigger => trigger.TriggerProperty == Properties.MessageButtonClick);
// Create a Write Log action in the Button: Click trigger.
var writeLogAction = clickTrigger.CreateAction(Properties.MessageWriteLog);
// Use the DeleteAction function to delete the Write Log action.
clickTrigger.DeleteAction(writeLogAction);
}
bool DeleteCondition ( TriggerCondition  condition)

Deletes a trigger condition.

Parameters
conditionThe trigger condition you want to delete.
Returns
True when it deletes the condition successfully, otherwise false.

Property Documentation

IEnumerable<Action> Actions
get

Gets the actions in a trigger.

IEnumerable<TriggerCondition> Conditions
get

Gets the conditions in a trigger.

Gets the type of the trigger.