Kanzi 4.1.0
StateGroup Interface Reference

Configure state groups in a state manager. More...

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

Public Member Functions

StateTransition CloneTransition (StateTransition sourceTransition)
 Duplicates a transition.
 
StateTransition CreateTransition (State startState, State endState)
 Creates a transition between two states.
 
void DeleteTransition (StateTransition transition)
 Deletes a transition.
 
void MoveTransition (StateTransition transition, int indicesToMove)
 Moves a transition relative to its current position.
 
- 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

bool IgnoreStateValidityCheck [get, set]
 Gets or sets whether to ignore state validity checks for this state group.
 
bool IsDisabledOnExport [get, set]
 Gets or sets whether this state group is disabled when exporting the project to a kzb file.
 
new StateGroupProperties PropertyTypes [get]
 
IEnumerable< StateStates [get]
 Gets the states in a state group.
 
IEnumerable< StateTransitionStateTransitions [get]
 Gets the state transitions in a state group.
 
- 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.
 
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 state groups in a state manager.

State groups contain states, define controller properties, and transitions between states in a state group. A typical transition defines a period and interpolation paths between property values of two states. You can define transitions using a general guideline for all properties, using interpolations for each property as specified, or using animation items.

See also
State, StateObject, StateTransition, ProjectItem, Project.StateManagerLibrary

Examples

To create, duplicate, move, and get transitions in a state group:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
var myStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Create a state group named MyStateGroup in the MyStateManager state manager.
var myStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("MyStateGroup"),
// Create five states in the MyStateGroup state group
for (int i = 0; i <= 4; i++)
{
myStates.Add(studio.ActiveProject.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("MyState" + i),
}
// Create transitions between states. Kanzi adds new transitions to the end.
var myTransition1 = myStateGroup.CreateTransition(myStates[0], myStates[1]);
var myTransition2 = myStateGroup.CreateTransition(myStates[1], myStates[2]);
var myTransition3 = myStateGroup.CreateTransition(myStates[2], myStates[3]);
// Duplicate transition myTransition3;
// Move the transition myTransition4 to the first position. The position value is relative to the current position.
myStateGroup.MoveTransition(myTransition3, -3);
// Get all transitions in the MyStateGroup state group and print the start state, end state, and duration for each transition.
foreach (var transition in myStateGroup.StateTransitions)
{
studio.Log(transition.StartState + " -> " + transition.EndState + ", Duration: " + transition.Duration + "ms");
}
}

To set the controller property in a state group:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named ToggleButtonStateManager in the State Managers library.
var toggleButtonStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("ToggleButtonStateManager"), stateManagerLibrary);
// Create a state group named StateGroup in the ToggleButtonStateManager state manager.
var stateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
toggleButtonStateManager.GenerateUniqueChildName("StateGroup"), toggleButtonStateManager);
// Create a state named Off in the StateGroup state group.
var offState = studio.ActiveProject.CreateProjectItem<State>(
stateGroup.GenerateUniqueChildName("Off"), stateGroup);
// Create a state named On in the StateGroup state group.
var onState = studio.ActiveProject.CreateProjectItem<State>(
stateGroup.GenerateUniqueChildName("On"), stateGroup);
// Set the Controller Property of the StateGroup state group to ButtonConcept.ToggleState (Toggle State).
// In the Off state set the value of the Toggle State controller property to 0.
// In the On state set the value of the Toggle State controller property to 1.
}

To set a custom controller property in a state group:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named LevelStateManager in the State Managers library.
var levelStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("LevelStateManager"), stateManagerLibrary);
// Create a state group named StateGroup in the LevelStateManager state manager.
var levelStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
levelStateManager.GenerateUniqueChildName("LevelStateGroup"),
// Create five states in the StateGroup state group
for (int i = 0; i <= 4; i++)
{
levelStates.Add(studio.ActiveProject.CreateProjectItem<State>(
levelStateGroup.GenerateUniqueChildName("Level" + i),
}
// Get the Property Types library in the project.
var propertyTypesLibrary = studio.ActiveProject.PropertyTypeLibrary;
// Create five enumeration options and assign values to them.
for (int i = 0; i <= 4; i++)
{
options.Add("Level" + i, i);
}
// Create an enumeration controller property type Level Property and assign to it the five enumeration options.
propertyTypesLibrary.GenerateUniqueChildName("MyPlugin.LevelProperty"),
"Level Property",
"Controller Properties",
// Set the Controller Property of LevelStateGroup to Level Property.
// In each state in LevelStateGroup, set the value of Level Property to one of the enumeration options.
// For example, in the Level0 state set the value of Level Property to Level0.
foreach (var state in levelStateGroup.States)
{
int value;
if (levelProperty.Options.TryGetValue(state.Name, out value))
{
}
}
}

Member Function Documentation

◆ CloneTransition()

StateTransition CloneTransition ( StateTransition sourceTransition)

Duplicates a transition.

Kanzi adds a duplicated transition as the last transition in a state group. You can move transitions in a state group using MoveTransition.

Parameters
sourceTransitionThe name of the transition you want to duplicate.
See also
MoveTransition

◆ CreateTransition()

StateTransition CreateTransition ( State startState,
State endState )

Creates a transition between two states.

Kanzi adds a new transition as the last transition in a state group. You can move transitions in a state group using MoveTransition.

Parameters
startStateThe state from which the transition starts.
endStateThe state where the transition ends.
See also
MoveTransition

◆ DeleteTransition()

void DeleteTransition ( StateTransition transition)

Deletes a transition.

Parameters
transitionThe name of the transition you want to delete.

◆ MoveTransition()

void MoveTransition ( StateTransition transition,
int indicesToMove )

Moves a transition relative to its current position.

Parameters
transitionThe transition you want to move.
indicesToMoveThe position relative to the current position of the transition. Positive values move the transition down, negative values move the transition up.

Property Documentation

◆ IgnoreStateValidityCheck

bool IgnoreStateValidityCheck
getset

Gets or sets whether to ignore state validity checks for this state group.

◆ IsDisabledOnExport

bool IsDisabledOnExport
getset

Gets or sets whether this state group is disabled when exporting the project to a kzb file.

◆ PropertyTypes

new StateGroupProperties PropertyTypes
get

Implements ProjectItem.

◆ States

IEnumerable<State> States
get

Gets the states in a state group.

The states.

Examples

To get all states in a state group:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
var myStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Create a state group named MyStateGroup in the MyStateManager state manager.
var myStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("MyStateGroup"),
// Create five states in the MyStateGroup state group
for (int i = 0; i <= 4; i++)
{
myStates.Add(studio.ActiveProject.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("MyState" + i),
}
// Get all states in the state group MyStateGroup.
var statesInStateGroup = myStateManager.GetChild("MyStateGroup").Children;
// Print the names of the states in the MyStateGroup state group to the Kanzi Studio Log window.
{
studio.Log(state.Name);
}
}

◆ StateTransitions

IEnumerable<StateTransition> StateTransitions
get

Gets the state transitions in a state group.

The state transitions.