Kanzi 3.9.16
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)
 
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 ()
 
bool Delete ()
 Deletes a project item.
 
void DeregisterThumbnailUser (object user)
 Deregisters a registerd thumbnail user.
 
IEnumerable< Property > GetAddableProperties ()
 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)
 
IEnumerable< Property > GetContextProperties ()
 
IEnumerable< Property > GetFixedProperties ()
 
IEnumerable< Property > GetFrequentlyAddedProperties ()
 
ProjectItem GetProjectItemByPath (string path)
 
string GetRelativeProjectPathTo (ProjectItem anotherItem)
 
IEnumerable< Property > GetRemovableProperties ()
 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< ProjectItem > GetTreeItemsAsList ()
 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)
 
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)
 
void SetPropertyReadOnlyStatus (Property property, bool? value)
 
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< NodeComponent > NodeComponents [get]
 Gets the node components in a NodeComponentHost.
 
IEnumerable< TriggerNodeComponent > Triggers [get]
 Gets the triggers in a NodeComponentHost.
 
- Properties inherited from ProjectItem
IEnumerable< ProjectItem > Children [get]
 Gets all child items of a project item.
 
string IconLocation [get]
 
object IconModifier [get, set]
 
string InvalidityReason [get]
 
bool IsDeleted [get]
 
bool IsDisposed [get]
 
bool IsHidden [get, set]
 
bool IsReadOnly [get, set]
 
bool IsValidState [get]
 
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]
 
string Path [get]
 
Project Project [get]
 Gets the project in which this item is located.
 
Type ProjectItemType [get]
 
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]
 
object this[string propertyName] [get, set]
 
string ToolTip [get]
 
string TypeDisplayName [get]
 Gets the type of a project item.
 
- Properties inherited from PropertyContainer
IEnumerable< Property > Properties [get]
 Gets the properties in a project item or node component.
 

Additional Inherited Members

- Events inherited from ProjectItem
EventHandler< CollectionChangedEventArgs< ProjectItem > > ChildCollectionChanged
 
EventHandler< DeletedEventArgs > Deleted
 
EventHandler< DeletedEventArgs > Deleting
 
EventHandler< CollectionChangedEventArgs< ProjectItem > > DescendantChildCollectionChanged
 
EventHandler< DeletedEventArgs > DescendantDeleted
 
EventHandler< DynamicPropertyChangedEventArgs > DescendantDynamicPropertyChanged
 
EventHandler< ParentChangedEventArgs > DescendantParentChanged
 
EventHandler< CollectionChangedEventArgs< string > > DescendantPropertyCollectionChanged
 
EventHandler< ProjectItemEventArgs > Disposing
 
EventHandler< DynamicPropertyChangedEventArgs > DynamicPropertyChanged
 
EventHandler< ParentChangedEventArgs > ParentChanged
 
EventHandler< PathChangedEventArgs > PathChanged
 
EventHandler< DynamicPropertyChangedEventArgs > PreviewDescendantDynamicPropertyChanged
 
EventHandler< DynamicPropertyChangedEventArgs > PreviewDynamicPropertyChanged
 
EventHandler< CollectionChangedEventArgs< string > > PropertyCollectionChanged
 
EventHandler< ReplaceEventArgs > Replacing
 
EventHandler ThumbnailChanged
 
EventHandler ValidityChanged
 

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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// In the RootPage node create an Animation Player named Root Animation Player.
NodeComponent animationPlayer = rootPage.CreateNodeComponent(
rootPage.GenerateUniqueChildName("Root Animation Player"), studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.AnimationPlayer));
// Create a copy of Root Animation Player in the RootPage node.
rootPage.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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Get the Animation Player node component type.
var animationPlayerType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.AnimationPlayer);
// In the RootPage node create an Animation Player named Root Animation Player.
rootPage.CreateNodeComponent(rootPage.GenerateUniqueChildName("Root Animation Player"), animationPlayerType);
}

To create and configure a Property Target Interpolator:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Get the Property Target Interpolator node component type.
var propertyTargetInterpolatorType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.PropertyTargetInterpolator);
// In the RootPage node create a Property Target Interpolator named Root Property Target Interpolator.
var propertyTargetInterpolator = rootPage.CreateNodeComponent(
rootPage.GenerateUniqueChildName("Root Property Target Interpolator"), propertyTargetInterpolatorType);
// Set the Interpolated Property Type property to Node2D.RenderTransformation
propertyTargetInterpolator.Set(
propertyTargetInterpolator.PropertyTypes.PropertyTargetInterpolatorInterpolatedPropertyType,
rootPage.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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// In the RootPage node create an Image node.
var image = studio.ActiveProject.CreateProjectItem<Image2D>(rootPage.GenerateUniqueChildName("Image"), rootPage);
// 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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// In the RootPage node create an On Property Change trigger.
rootPage.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.OnPropertyChangedTrigger));
}

To create a Button: Enter trigger:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// In the RootPage node create a Button 2D node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// 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/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// In the RootPage node create a Grid List Box 2D node.
var listBox =
studio.ActiveProject.CreateProjectItem<GridListBox2D>(rootPage.GenerateUniqueChildName("Grid List Box 2D"), rootPage);
// 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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// In the RootPage node create an On Property Change trigger.
var trigger1 = rootPage.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.OnPropertyChangedTrigger));
// In the RootPage node create a Page node.
var page = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Page"), rootPage);
// In the Page node create a trigger by cloning the On Property Change trigger in the RootPage node.
page.CreateTrigger(trigger1);
}

◆ 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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Check if the RootPage node has node components.
if (rootPage.NodeComponents.Any())
{
// Get the first node component in the RootPage node.
var nodeComponent = rootPage.NodeComponents.First();
// Delete the first node component in the RootPage node.
var result = rootPage.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 " + rootPage.Name + " node.");
}
}
else
{
// If the RootPage node has no node components, print that to the Kanzi Studio Log window.
studio.Log("The " + rootPage.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 RootPage node in the Screens/Screen node. To make triggers available to the RootPage node,
// cast it as NodeComponentHost.
NodeComponentHost rootPage = (NodeComponentHost)studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Get the first, or the default, Page Deactivated trigger in the RootPage node.
var pageDeactivatedTrigger =
rootPage.Triggers.FirstOrDefault(
trigger => trigger.Get(Properties.TriggerMessageType) == studio.ActiveProject.MessageTypeLibrary.GetItemByName(MessageTypeNames.MessagePageDeactivated));
// Use the DeleteTrigger function to delete the Page Deactivated trigger in the RootPage node.
rootPage.DeleteTrigger(pageDeactivatedTrigger);
}

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 RootPage node in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Get the node components in the RootPage node.
var rootPageNodeComponents = rootPage.NodeComponents;
studio.Log(rootPage.Name + " has these node components:");
// Print the name of each node component to the Kanzi Studio Log window.
foreach (var nodeComponent in rootPageNodeComponents)
{
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 RootPage node in the Screens/Screen node.
Node2D rootPage = (Node2D)studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Get the triggers in the RootPage node.
var rootPageTriggers = rootPage.Triggers;
studio.Log(rootPage.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 rootPageTriggers)
{
var messageType = "";
if (trigger.IsMessageTrigger)
{
messageType = " (" + trigger.Get(Properties.TriggerMessageType.Name) + ")";
}
studio.Log(trigger.Name + messageType);
}
}