Kanzi 4.1.0
NodeComponentHost Interface Reference

Configure node components. More...

Inheritance diagram for NodeComponentHost:
[legend]
Collaboration diagram for NodeComponentHost:
[legend]

Public Member Functions

NodeComponent CreateNodeComponent (NodeComponent sourceNodeComponent)
 Creates a node component by copying an existing node component.
 
NodeComponent CreateNodeComponent (string name, NodeComponentType nodeComponentType)
 Creates a node component (Animation, Input Manipulator, or Custom node component).
 
TriggerNodeComponent CreateTrigger (NodeComponentType triggerType)
 Creates a trigger.
 
TriggerNodeComponent CreateTrigger (TriggerNodeComponent sourceTrigger)
 Creates a trigger by copying an existing trigger.
 
bool DeleteNodeComponent (NodeComponent nodeComponent)
 Deletes a node component.
 
bool DeleteTrigger (TriggerNodeComponent trigger)
 Deletes a trigger.
 
- Public Member Functions inherited from ProjectItem
void AddProperty (Property property)
 Adds a property to an item.
 
void AddProperty (string propertyName)
 Adds a property to an item.
 
void BeginBatchModification (string batchName)
 Begins a batch modification operation.
 
bool CanAddProperty (Property property)
 Checks whether Kanzi Studio allows you to add a specific property to an item.
 
bool CanAddProperty (string propertyName)
 Checks whether Kanzi Studio allows you to add a specific property to an item.
 
void CommitBatchModification ()
 Commits the current batch modification operation.
 
bool Delete ()
 Deletes a project item.
 
void DeregisterThumbnailUser (object user)
 Deregisters a registerd thumbnail user.
 
IEnumerable< PropertyGetAddableProperties ()
 Gets a list of properties which you can add to an item.
 
T GetAncestor< T > ()
 Gets the nearest item of given type in the parent tree.
 
ProjectItem GetChild (string childName)
 Gets the child item of the current item with the given name.
 
T GetChild< T > (string childName)
 Gets the child item of the current item with the given name and type.
 
int GetChildIndex (ProjectItem child)
 Gets the index of a child project item within this item's children collection.
 
IEnumerable< PropertyGetContextProperties ()
 Gets the context properties for this project item.
 
IEnumerable< PropertyGetFixedProperties ()
 Gets the fixed properties for this project item that cannot be removed.
 
IEnumerable< PropertyGetFrequentlyAddedProperties ()
 Gets the properties that are frequently added to this type of project item.
 
ProjectItem GetProjectItemByPath (string path)
 Gets a project item by its path relative to this project item.
 
string GetRelativeProjectPathTo (ProjectItem anotherItem)
 Gets the relative path from this project item to another project item.
 
IEnumerable< PropertyGetRemovableProperties ()
 Gets a list of properties which you can remove from an item.
 
BitmapSource GetThumbnail (int width, int height, bool showChildren, bool showFullScreen, Node contextNode)
 Gets the thumbnail image for a project item.
 
BitmapSource GetThumbnail (int width, int height, bool showChildren, bool showFullScreen, Node contextNode, float[] letterboxColorRGBA)
 Gets the thumbnail image for a project item.
 
IEnumerable< ProjectItemGetTreeItemsAsList ()
 Enumerates the items under this ProjectItem including this item itself, children, and grand children.
 
bool HasProperty (Property property)
 Checks whether an item has a specific property.
 
bool HasProperty (string propertyName)
 Checks whether an item has a specific property.
 
bool IsPropertyReadOnly (Property property)
 Checks whether the specified property is read-only on this project item.
 
void RegisterThumbnailUser (object user, uint width, uint height, bool showChildren, bool showFullScreen, Node contextNode)
 Registers a user for the thumbnail images for a project item.
 
void RemoveProperty (Property property)
 Removes a property from an item.
 
void RemoveProperty (string propertyName)
 Removes a property from an item.
 
void SetChildIndex (ProjectItem child, int index)
 Sets the index of a child project item within this item's children collection.
 
void SetPropertyReadOnlyStatus (Property property, bool? value)
 Sets the read-only status of the specified property on this project item.
 
void UpdateValidity ()
 Recalculates the validity the item.
 
- Public Member Functions inherited from PropertyContainer
object Get (Property property)
 Gets the value of a property.
 
object Get (string propertyName)
 Gets the value of a property.
 
T Get< T > (TypedProperty< T > property)
 Gets the value of a property.
 
void Set (string propertyName, object value)
 Sets the value of a property.
 
void Set< T > (TypedProperty< T > property, T value)
 Sets the value of a property.
 
- Public Member Functions inherited from ChildContainer
string GenerateUniqueChildName (string defaultName)
 Generates a unique name.
 
string GetInvalidityReasonOfNewName (string newName)
 Returns the reason why the passed name is not valid.
 

Properties

IEnumerable< NodeComponentNodeComponents [get]
 Gets the node components in a NodeComponentHost.
 
IEnumerable< TriggerNodeComponentTriggers [get]
 Gets the triggers in a NodeComponentHost.
 
- Properties inherited from ProjectItem
IEnumerable< ProjectItemChildren [get]
 Gets all child items of a project item.
 
string IconLocation [get]
 Gets the location of the icon for this project item in Kanzi Studio.
 
object IconModifier [get, set]
 Gets or sets the icon modifier for this project item.
 
string InvalidityReason [get]
 Gets the reason why this project item is in an invalid state, or null if the item is valid.
 
bool IsDeleted [get]
 Gets whether this project item has been deleted.
 
bool IsDisposed [get]
 Gets whether this project item has been disposed.
 
bool IsHidden [get, set]
 Gets or sets whether this project item is hidden in Kanzi Studio.
 
bool IsReadOnly [get, set]
 Gets or sets whether this project item is read-only.
 
bool IsValidState [get]
 Gets whether this project item is in a valid state.
 
string KzbUrl [get]
 Gets the kzb URL of a project item.
 
string Name [get, set]
 Gets or sets the name of a project item.
 
ProjectItem Parent [get, set]
 Gets or sets the parent of this project item.
 
string Path [get]
 Gets the path to this project item within the project.
 
Project Project [get]
 Gets the project in which this item is located.
 
Type ProjectItemType [get]
 Gets the type of this project item.
 
PropertyTypeLibrary PropertyTypeLibrary [get]
 Gets the Property Types library of the project of this item which stores all property types you create in a Kanzi Studio project.
 
ProjectItemProperties PropertyTypes [get]
 
object this[Property property] [get, set]
 Gets or sets the value of the specified property on this project item.
 
object this[string propertyName] [get, set]
 Gets or sets the value of the property with the specified name on this project item.
 
string ToolTip [get]
 Gets the tooltip text for this project item in Kanzi Studio.
 
string TypeDisplayName [get]
 Gets the type of a project item.
 
- Properties inherited from PropertyContainer
IEnumerable< PropertyProperties [get]
 Gets the properties in a project item or node component.
 

Additional Inherited Members

- Events inherited from ProjectItem
EventHandler< CollectionChangedEventArgs< ProjectItem > > ChildCollectionChanged
 Occurs when the children collection of this project item changes.
 
EventHandler< DeletedEventArgsDeleted
 Occurs after this project item has been deleted.
 
EventHandler< DeletedEventArgsDeleting
 Occurs when this project item is about to be deleted.
 
EventHandler< CollectionChangedEventArgs< ProjectItem > > DescendantChildCollectionChanged
 Occurs when the children collection of this project item or any of its descendants changes.
 
EventHandler< DeletedEventArgsDescendantDeleted
 Occurs after a descendant of this project item has been deleted.
 
EventHandler< DynamicPropertyChangedEventArgsDescendantDynamicPropertyChanged
 Occurs when a dynamic property value changes on this project item or any of its descendants.
 
EventHandler< ParentChangedEventArgsDescendantParentChanged
 Occurs when the parent of this project item or any of its descendants changes.
 
EventHandler< CollectionChangedEventArgs< string > > DescendantPropertyCollectionChanged
 Occurs when a property is added to or removed from this project item or any of its descendants.
 
EventHandler< ProjectItemEventArgsDisposing
 Occurs when this project item is being disposed.
 
EventHandler< DynamicPropertyChangedEventArgsDynamicPropertyChanged
 Occurs when a dynamic property value changes on this project item.
 
EventHandler< ParentChangedEventArgsParentChanged
 Occurs when the parent of this project item changes.
 
EventHandler< PathChangedEventArgsPathChanged
 Occurs when the path of this project item changes.
 
EventHandler< DynamicPropertyChangedEventArgsPreviewDescendantDynamicPropertyChanged
 Occurs before a dynamic property value changes on this project item or any of its descendants.
 
EventHandler< DynamicPropertyChangedEventArgsPreviewDynamicPropertyChanged
 Occurs before a dynamic property value changes on this project item.
 
EventHandler< CollectionChangedEventArgs< string > > PropertyCollectionChanged
 Occurs when a property is added to or removed from this project item.
 
EventHandler< ReplaceEventArgsReplacing
 Occurs when this project item is being replaced.
 
EventHandler ThumbnailChanged
 Occurs when the thumbnail of this project item changes.
 
EventHandler ValidityChanged
 Occurs when the validity state of this project item changes.
 

Detailed Description

Configure node components.

This interface represents a node component host that can have node components. To add functionality to a node, attach node components to that node.

You can create these node components:

  • Triggers react to messages or events and apply logic.
  • Animation node components (Animation Player, Property Driven Animation Player, and Property Target Interpolator) animate specific properties of the node and its child nodes.
  • Input Manipulator node components (Click Manipulator, Multi-Click Manipulator, Key Manipulator, Long-Press Manipulator, and Pan Manipulator) enable and configure gesture and keyboard input recognition for the node.
  • Custom node components implement custom functionality that you define in a Kanzi Engine plugin.
See also
TriggerNodeComponent

Member Function Documentation

◆ CreateNodeComponent() [1/2]

NodeComponent CreateNodeComponent ( NodeComponent sourceNodeComponent)

Creates a node component by copying an existing node component.

Parameters
sourceNodeComponentThe node component you want to copy to create a new node component.
Returns
The node component you create with this function.
See also
Project.NodeComponentTypeLibrary, CreateNodeComponent(string, NodeComponentType)

Examples

To create a node component from an existing node component:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// In the RootNode node create an Animation Player named Root Animation Player.
NodeComponent animationPlayer = rootNode.CreateNodeComponent(
rootNode.GenerateUniqueChildName("Root Animation Player"), studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.AnimationPlayer));
// Create a copy of Root Animation Player in the RootNode node.
rootNode.CreateNodeComponent(animationPlayer);
}

◆ CreateNodeComponent() [2/2]

NodeComponent CreateNodeComponent ( string name,
NodeComponentType nodeComponentType )

Creates a node component (Animation, Input Manipulator, or Custom node component).

This function is the equivalent of calling Project.CreateNodeComponent.

You can find the available node component types in Project.NodeComponentTypeLibrary.

Parameters
nameThe name of the node component.
nodeComponentTypeThe type of the node component.
Returns
The node component you create with this function.
See also
Project.NodeComponentTypeLibrary, Project.CreateNodeComponent, CreateNodeComponent(NodeComponent)

Examples

To create an Animation Player:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// Get the Animation Player node component type.
var animationPlayerType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.AnimationPlayer);
// In the RootNode node create an Animation Player named Root Animation Player.
rootNode.CreateNodeComponent(rootNode.GenerateUniqueChildName("Root Animation Player"), animationPlayerType);
}

To create and configure a Property Target Interpolator:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// Get the Property Target Interpolator node component type.
var propertyTargetInterpolatorType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.PropertyTargetInterpolator);
// In the RootNode node create a Property Target Interpolator named Root Property Target Interpolator.
var propertyTargetInterpolator = rootNode.CreateNodeComponent(
rootNode.GenerateUniqueChildName("Root Property Target Interpolator"), propertyTargetInterpolatorType);
// Set the Interpolated Property Type property to Node2D.RenderTransformation
propertyTargetInterpolator.Set(
propertyTargetInterpolator.PropertyTypes.PropertyTargetInterpolatorInterpolatedPropertyType,
rootNode.PropertyTypes.Node2DRenderTransformation);
// Set the Interpolated Field property to Rotation Z.
propertyTargetInterpolator.Set(
propertyTargetInterpolator.PropertyTypes.PropertyTargetInterpolatorInterpolatedPropertyField,
// Set the value of the Acceleration property to 7.
propertyTargetInterpolator.Set(propertyTargetInterpolator.PropertyTypes.PropertyTargetInterpolatorAcceleration, 7);
// Set the value of the Drag property to 10.
propertyTargetInterpolator.Set(propertyTargetInterpolator.PropertyTypes.PropertyTargetInterpolatorDrag, 10);
}

To create and configure a Multi-Click Manipulator:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// In the RootNode node create an Image node.
var image = studio.ActiveProject.CreateProjectItem<Image2D>(rootNode.GenerateUniqueChildName("Image"), rootNode);
// In the Image node add and enable the Hit Testable property.
// Kanzi uses hit testing to determine the nodes that receive input.
image.Set(Properties.NodeHitTestable, true);
// Get the Multi-Click Manipulator node component type.
var multiClickManipulatorType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.MultiClickManipulatorComponent);
// In the Image node create a Multi-Click Manipulator.
var multiClickManipulator = image.CreateNodeComponent(image.GenerateUniqueChildName("Multi-Click Manipulator"), multiClickManipulatorType);
// In the Multi-Click Manipulator set the value of the Multi-Click Timeout property to 300 ms.
multiClickManipulator.Set(multiClickManipulator.PropertyTypes.MultiClickManipulatorComponentTimeout, 300);
// To create a Multi-Click trigger in the Image node, create a Message Trigger and set the value of the Message Trigger Message Type property to Multi-Click.
var multiClickTrigger = image.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.MessageTrigger));
multiClickTrigger.Set(Properties.TriggerMessageType, studio.ActiveProject.MessageTypeLibrary.GetItemByName(MessageTypeNames.MessageMultiClick));
// In the Multi-Click trigger create a Write Log action.
var writeLogAction = multiClickTrigger.CreateAction(studio.ActiveProject.TriggerActionTypeLibrary.GetItemByName(ActionTypeNames.WriteLogAction));
// In the Write Log action set Log Text to "Multi-click!".
writeLogAction.Set(Properties.WriteLogActionLogText, "Multi-click!");
}

◆ CreateTrigger() [1/2]

TriggerNodeComponent CreateTrigger ( NodeComponentType triggerType)

Creates a trigger.

Parameters
triggerType
Returns
The trigger you create with this function.
See also
TriggerNodeComponent

Examples

To create an On Property Change trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// In the RootNode node create an On Property Change trigger.
rootNode.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.OnPropertyChangedTrigger));
}

To create a Button: Enter trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// In the RootNode node create a Button 2D node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootNode.GenerateUniqueChildName("Button 2D"), rootNode);
// In the Button 2D node create a message trigger.
var buttonEnterTrigger = button.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.MessageTrigger));
// In the message trigger set Message Trigger Message Type to Button: Enter.
buttonEnterTrigger.Set(Properties.TriggerMessageType, studio.ActiveProject.MessageTypeLibrary.GetItemByName(MessageTypeNames.MessageButtonEnter));
}

To create a List Box: Item Selected trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootNode node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen/RootNode");
// In the RootNode node create a Grid List Box 2D node.
var listBox =
studio.ActiveProject.CreateProjectItem<GridListBox2D>(rootNode.GenerateUniqueChildName("Grid List Box 2D"), rootNode);
// In the Grid List Box 2D node create a message trigger.
var messageTrigger = listBox.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.MessageTrigger));
// In the message trigger set Message Trigger Message Type to List Box: Item Selected.
messageTrigger.Set(Properties.TriggerMessageType, studio.ActiveProject.MessageTypeLibrary.GetItemByName(MessageTypeNames.MessageListBoxItemSelected));
}

◆ CreateTrigger() [2/2]

TriggerNodeComponent CreateTrigger ( TriggerNodeComponent sourceTrigger)

Creates a trigger by copying an existing trigger.

Parameters
sourceTriggerThe trigger you want to copy to create a new trigger.
Returns
The trigger you create with this function.

Examples

To create a trigger from an existing trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// In the RootNode node create an On Property Change trigger.
var trigger = rootNode.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.OnPropertyChangedTrigger));
// In the RootNode node create a Empty Node 2D node.
var node = studio.ActiveProject.CreateProjectItem<EmptyNode2D>(rootNode.GenerateUniqueChildName("node"), rootNode);
// In the Empty Node 2D node create a trigger by cloning the On Property Change trigger in the RootNode node.
node.CreateTrigger(trigger);
}

◆ DeleteNodeComponent()

bool DeleteNodeComponent ( NodeComponent nodeComponent)

Deletes a node component.

This function is the equivalent of calling nodeComponent.Delete().

Parameters
nodeComponentThe node component you want to delete.
Returns
When it deletes the node component successfully, true, otherwise false.
See also
NodeComponents

Examples

To delete the first node component of a node:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// Check if the RootNode node has node components.
if (rootNode.NodeComponents.Any())
{
// Get the first node component in the RootNode node.
var nodeComponent = rootNode.NodeComponents.First();
// Delete the first node component in the RootNode node.
var result = rootNode.DeleteNodeComponent(nodeComponent);
// If Kanzi Studio successfully deletes the node component,
// print the name of the deleted node component to the Log window.
if (result == true)
{
studio.Log("Deleted " + nodeComponent.Name + " from the " + rootNode.Name + " node.");
}
}
else
{
// If the RootNode node has no node components, print that to the Kanzi Studio Log window.
studio.Log("The " + rootNode.Name + " node does not have any node components to delete.");
}
}

◆ DeleteTrigger()

bool DeleteTrigger ( TriggerNodeComponent trigger)

Deletes a trigger.

Parameters
triggerThe trigger you want to delete.
Returns
When it deletes the trigger successfully, true, otherwise false.
See also
Triggers

Examples

To delete a trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen/RootNode");
// In the RootNode node create a Button 2D node named Button.
var button = studio.ActiveProject.CreateProjectItem<Button2D>("Button", rootNode);
// In the Button 2D button get the first Button: Click trigger.
var clickTrigger = button.Triggers.First(
trigger => trigger.Get(Properties.TriggerMessageType) == studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Button.Click"));
// Use the DeleteTrigger function to delete the Button: Click trigger in the button node.
button.DeleteTrigger(clickTrigger);
}

Property Documentation

◆ NodeComponents

IEnumerable<NodeComponent> NodeComponents
get

Gets the node components in a NodeComponentHost.

Examples

To get all the node components in a node:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// Get the node components in the RootNode node.
var rootNodeNodeComponents = rootNode.NodeComponents;
studio.Log(rootNode.Name + " has these node components:");
// Print the name of each node component to the Kanzi Studio Log window.
foreach (var nodeComponent in rootNodeNodeComponents)
{
studio.Log(nodeComponent.Name);
}
}

◆ Triggers

IEnumerable<TriggerNodeComponent> Triggers
get

Gets the triggers in a NodeComponentHost.

Examples

To get all the triggers in a node:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootNode node in the Screens/Screen node.
Node2D rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<EmptyNode2D>("RootNode");
// Get the triggers in the RootNode node.
var rootNodeTriggers = rootNode.Triggers;
studio.Log(rootNode.Name + " has these triggers:");
// Print the name of each trigger to the Kanzi Studio Log window.
// For message triggers, print also the name of the trigger message type.
foreach (var trigger in rootNodeTriggers)
{
var messageType = "";
if (trigger.IsMessageTrigger)
{
messageType = " (" + trigger.Get(Properties.TriggerMessageType.Name) + ")";
}
studio.Log(trigger.Name + messageType);
}
}