Class ParallelActivityHost2D

Class Hierarchy

An Activity Host that can display multiple Activity nodes at a time.

An Activity Host node defines the rules for when its Activity nodes are active. Kanzi has these Activity Host nodes:

  • Parallel Activity Host node can activate more than one of its child Activity nodes at a time.
  • Data-Driven Exclusive Activity Host and Exclusive Activity Host nodes can have only one of its child Activity nodes active at a time. When one child Activity node of a Data-Driven Exclusive Activity Host or an Exclusive Activity Host node is active, all other Activity nodes of that Activity Host node are inactive.

For example, you can use a Data-Driven Exclusive Activity Host or an Exclusive Activity Host node to toggle between views in your application.

See DataDrivenExclusiveActivityHost2D, DataDrivenExclusiveActivityHost3D, ExclusiveActivityHost2D, and ExclusiveActivityHost3D.

Parallel Activity Host can show multiple activities at the same time. When you activate an Activity node, a Parallel Activity Host node brings that Activity to the front. In a Parallel Activity Host node you can group Activity nodes, to show the groups in the same order that you defined in the node tree. When you activate an Activity node in a group, a Parallel Activity Host node brings to the front the Activity in that group. For example, this way you can implement the showing of critical messages, such as engine failure, in front of regular notifications, such as a phone call notification. In both groups a Parallel Activity Host node shows the Activity nodes in order of activation.

You can add Activity nodes to an Activity Host node in real-time. This enables you to use the Kanzi Engine API to generate Activity nodes or to add to the application another application for which the structure of Activity nodes is not known until you run the application. For example, you can use the API to generate a large number of popup windows that you want to show to the user.

The Activity and Activity Host nodes inherit from the ContentLayout class to lay out their content like a Content Layout node. See ContentLayout2D and ContentLayout3D.

See Activity2D and Activity3D.

Controlling Activity nodes in a Parallel Activity Host node The type of the Activity Host node determines the way you control its child Activity nodes. When you use a Parallel Activity Host node, you can control its Activity nodes in these ways:

  • Synchronize the activation of an Activity node with your logic:
  • In an Activity Host node create a DataTrigger.
  • In the DataTrigger add a condition expression which evaluates to true or false, and which uses as input either Properties or a Data Source.
  • Add to the DataTrigger an ApplyActivationAction where you set the ApplyActivationAction::ActivationPathProperty to the Activity node that you want to activate.

The Activity node stays active as long as the condition expression in the DataTrigger evaluates to true. When the condition in the DataTrigger is no longer true, Kanzi reverts the activation. When using this approach, keep in mind that actions of a DataTrigger have higher priority than the actions of any other Trigger. See DataTrigger and ApplyActivationAction.

  • Control Activity nodes with ActivateActivityMessage and DeactivateActivityMessage:
  • In an Activity Host node create any Trigger.
  • Add to the Trigger a condition that defines when an Activity node is activated or deactivated.
  • Activate the Activity node using the ActivateActivityMessage and deactivate it using the DeactivateActivityMessage.

Keep in mind that actions of a DataTrigger have higher priority than the actions of any other Trigger. For example, if you use a DataTrigger with an ApplyActivationAction and any other Trigger to send a DeactivateActivityMessage or ActivateActivityMessage, the effect of the DeactivateActivityMessage or ActivateActivityMessage becomes visible only after Kanzi unapplies the ApplyPropertyAction. See Trigger.

Data and logic programming of Activity nodes For each Parallel Activity Host node you can define properties that are specific to that Parallel Activity Host node.

When you create a property for a Parallel Activity Host node, set the namespace of that property to Activity Property. You can create properties with int, bool, float, and enum data types. If you use code behind for a Parallel Activity Host, Kanzi adds the properties of that Parallel Activity Host to the code behind.

The values of these properties implement the state machine and logic of your Kanzi application, which is why Kanzi preserves the values of these properties even when a Parallel Activity Host is virtual. When Kanzi virtualizes a Parallel Activity Host, it serializes the properties of that Parallel Activity Host and when Kanzi devirtualizes that Parallel Activity Host, it deserializes the state of that Parallel Activity Host and restores its property values.

Code behind Code behind is a workflow where you associate code with an instance of a Parallel Activity Host instead of a type. In Kanzi Studio in the Activity Browser window, you can generate a code behind stub for any Parallel Activity Host node. This stub is associated with that particular Parallel Activity Host and has access to the properties of that Parallel Activity Host. In code behind you can write code that you can associate with the view or controller parts of the model-view-controller pattern. For example, you can:

  • Connect to a remote service when the Parallel Activity Host is instantiated and attached.
  • Install Kanzi command handlers and define their implementations, such as increase the volume when the user presses a button.
  • Implement complex UI interaction, such as drag-and-drop of data between UI elements.

Use a Parallel Activity Host 2D to define the rules when its child Activity nodes are active. A Parallel Activity Host shows its child Activity nodes in order of activation. Each can have more than one of its child Activity nodes active at a time

Inherits properties and message types from ParallelActivityHost2DMetadata.

Synopsis

Methods
create()

Creates a 2D Parallel Activity Host node

ParallelActivityHost2D.ParallelActivityHost2D:create(name)

Creates a 2D Parallel Activity Host node.

Parameters
name (string)

The name of the node.