Public Member Functions | Properties | Events | List of all members
Project Interface Reference

Create and access nodes and resources. More...

Public Member Functions

Brush CreateBrush (string name, BrushLibrary parent, BrushTypeEnum brushType)
 Creates a brush in the Brushes library. More...
 
Brush CreateBrush (string name, BrushLibrary parent, BrushType brushType)
 Creates a brush in the Brushes library. More...
 
Node CreateComponentNode (string name, Node parent, ComponentType componentType)
 
DataSource CreateDataSource (string name, [NotNull] DataSourceType dataSourceType)
 
NodeComponent CreateNodeComponent (string name, NodeComponentHost parent, NodeComponentType nodeComponentType)
 Creates a node component to the specified parent. More...
 
ProjectItem CreateProjectItem (Type projectItemType, string name, ProjectItem parent)
 Creates a project item. More...
 
CreateProjectItem< T > (string name, ProjectItem parent)
 Creates a project item. More...
 
RenderPass CreateRenderPass (string name, IComposerContainer parent, RenderPassType renderPassType)
 Creates a render pass. More...
 
StudioPluginItem CreateStudioPluginItem (string name, [CanBeNull] StudioPluginItem parent, [CanBeNull] string logicFactoryName)
 
ProjectItem GetProjectItem (string projectItemPath)
 Gets a project item. More...
 
ProjectItem GetProjectItemByKzbUrl (string kzbUrl, bool searchFromReferencedProjects)
 
IEnumerable< string > GetReferringItemsKzbNames (string propertyTypeName)
 
bool IsAbstract (Type projectItemType)
 

Properties

ProjectItem ActiveComposition [get]
 
AnimationClipLibrary AnimationClipLibrary [get]
 
AnimationLibrary AnimationLibrary [get]
 
ApplicationConfigurationResourceFileDirectory ApplicationDirectory [get]
 
Asset3DImportSourceDirectory Asset3DImportSourceDirectory [get]
 
string BinaryExportDirectory [get]
 
BinaryShaderFormatLibrary BinaryShaderFormatLibrary [get]
 
BrushLibrary BrushLibrary [get]
 Gets the Brushes library which stores brushes used in a Kanzi Studio project. More...
 
BrushTypeLibrary BrushTypeLibrary [get]
 Gets the brush types available in a Kanzi Studio project. More...
 
ComponentTypeLibrary ComponentTypeLibrary [get]
 
ComposerLibrary ComposerLibrary [get]
 Gets the Render Passes library which stores the legacy render passes used in a Kanzi Studio project. More...
 
DataSourceLibrary DataSourceLibrary [get]
 
DataSourceTypeLibrary DataSourceTypeLibrary [get]
 
EnginePluginLibrary EnginePluginLibrary [get]
 
FontDirectory FontDirectory [get]
 Gets the Fonts directory which contains the fonts in a Kanzi Studio project. More...
 
GenericResourceFileDirectory GenericResourceFileDirectory [get]
 Gets the Generic directory which contains the generic resource files in a Kanzi Studio project. More...
 
IEnumerable< Guide > Guides [get]
 
ImageDirectory ImageDirectory [get]
 Gets the Images directory which contains the image files in a Kanzi Studio project. More...
 
MaterialLibrary MaterialLibrary [get]
 Gets the Materials library which contains the materials in a Kanzi Studio project. More...
 
MaterialTypeLibrary MaterialTypeLibrary [get]
 Gets the Material Types library which contains the material types in a Kanzi Studio project. More...
 
MeshLibrary MeshLibrary [get]
 Gets the Meshes library which contains the meshes in a Kanzi Studio project. More...
 
NodeComponentTypeLibrary NodeComponentTypeLibrary [get]
 Gets the node component types available in a Kanzi Studio project. More...
 
PageTransitionCollectionLibrary PageTransitionCollectionLibrary [get]
 Gets the Page Transitions library which contains the page transitions in a Kanzi Studio project. More...
 
PipelineItemLibrary PipelineItemLibrary [get]
 Gets the Object Sources library which contains the object sources and filters in a Kanzi Studio project. More...
 
PrefabLibrary PrefabLibrary [get]
 Gets the Prefabs library which contains the prefabs used in a Kanzi Studio project. More...
 
ProjectReferenceLibrary ProjectReferenceLibrary [get]
 Gets the Project References library which stores the project references and kzb file references in a Kanzi Studio project. More...
 
RenderPassTypeLibrary RenderPassTypeLibrary [get]
 Gets the render pass types available in a Kanzi Studio project. More...
 
Screen Screen [get]
 Gets the Screen node in a Kanzi Studio project. More...
 
ShaderSourceDirectory ShaderSourceDirectory [get]
 Gets the Shaders directory which stores the shader source files in a Kanzi Studio project. More...
 
ShortcutLibrary ShortcutLibrary [get]
 Gets the Bookmarks library which stores the bookmarks in a Kanzi Studio project. More...
 
StateManagerLibrary StateManagerLibrary [get]
 Gets the State Managers library which stores state managers used in a Kanzi Studio project. More...
 
StudioPluginItemLibrary StudioPluginItemLibrary [get]
 
StyleLibrary StyleLibrary [get]
 Gets the Styles library which stores styles used in a Kanzi Studio project. More...
 
TagLibrary TagLibrary [get]
 Gets the Tags library which stores tags used in a Kanzi Studio project. More...
 
TextureLibrary TextureLibrary [get]
 Gets the Textures library which stores textures used in a Kanzi Studio project. More...
 
TimelineSequenceLibrary TimelineSequenceLibrary [get]
 
TrajectoryLibrary TrajectoryLibrary [get]
 

Events

EventHandler ActiveCompositionChanged
 
EventHandler BinaryExported
 Occurs after the export of the kzb file of the project is completed. More...
 
EventHandler BinaryExporting
 Occurs when the export of the kzb file of the project starts. More...
 
EventHandler Closing
 
EventHandler< ProjectSavingEventArgs > Saved
 Occurs after Kanzi Studio successfully saves the project. More...
 
EventHandler< ProjectSavingEventArgs > Saving
 Occurs when the saving of the project starts. More...
 

Detailed Description

Create and access nodes and resources.

Use the functions in this class to create nodes and resources in a project and to access the resources in resource libraries in a project.

Member Function Documentation

Brush CreateBrush ( string  name,
BrushLibrary  parent,
BrushTypeEnum  brushType 
)

Creates a brush in the Brushes library.

You can use this function to create brushes of types that come with Kanzi Studio.

Parameters
nameThe name of the brush.
parentThe library in which you create the brush.
brushTypeThe type of the brush you create with this function. Use BrushTypeEnum.COLOR for Color Brush, BrushTypeEnum.CONTENT for Content Brush, BrushTypeEnum.MATERIAL for Material brush, and BrushTypeEnum.TEXTURE for Texture Brush.
Returns
The brush you create with this function.
See also
CreateBrush(string, BrushLibrary, BrushType), BrushLibrary

Examples

To create a green Color Brush use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Brush Color property of the Color Brush.

public void Execute(PluginCommandParameter parameter)
{
// 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 Green in the Brushes library.
var colorBrush = studio.ActiveProject.CreateBrush(brushLibrary.GenerateUniqueChildName("Green"), brushLibrary, BrushTypeEnum.COLOR);
// Set the Brush Color property of the Color Brush to green (A=255, R=0, G=255, B=0).
colorBrush.Set(colorBrush.PropertyTypes.ColorBrushColor, System.Windows.Media.Color.FromArgb(255, 0, 255, 0));
}
Brush CreateBrush ( string  name,
BrushLibrary  parent,
BrushType  brushType 
)

Creates a brush in the Brushes library.

Parameters
nameThe name of the brush.
parentThe library in which you create the brush.
brushTypeThe type of the brush you create with this function. BrushTypeLibrary stores the brush types available in a Kanzi Studio project.
Returns
The brush you create with this function.
See also
BrushTypeLibrary, BrushLibrary, TextureLibrary, CreateBrush(string, BrushLibrary, BrushTypeEnum), ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a green Color Brush use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Brush Color property of the Color Brush.

public void Execute(PluginCommandParameter parameter)
{
// 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 Green in the Brushes library.
var colorBrush = studio.ActiveProject.CreateBrush(
brushLibrary.GenerateUniqueChildName("Green"),
brushLibrary,
studio.ActiveProject.BrushTypeLibrary.GetItemByName("Kanzi.ColorBrush"));
// Set the Brush Color property of the Color Brush to green (A=255, R=0, G=255, B=0).
colorBrush.Set(colorBrush.PropertyTypes.ColorBrushColor, System.Windows.Media.Color.FromArgb(255, 0, 255, 0));
}

To create a function that creates texture brushes that use PNG images from a directory:

// For example, to create texture brushes which use images in the
// <KanziInstallationDirectory>\Studio\Asset Library\AssetPackages\Album List\Tool_project\Images directory,
// use CreateTextureBrush("../Asset Library/AssetPackages/Album List/Tool_project/Images").
private void CreateTextureBrush(string directory)
{
// Get the names of all PNG files in the directory that you pass to this function.
// To use this function, in the class library file that implements the PluginCommand interface add the using directive for the System.IO namespace.
var pngFiles = Directory.GetFiles(directory, "*.png").Select(x => Path.GetFileName(x)).ToArray();
// Get the Library > Materials and Textures > Textures library which stores all the textures in a Kanzi Studio project.
var textureLibrary = studio.ActiveProject.TextureLibrary;
// Get the Library > Materials and Textures > Brushes library which stores all the brushes in a Kanzi Studio project.
var brushLibrary = studio.ActiveProject.BrushLibrary;
// Create a Texture Brush for each of the images.
foreach (var pngFile in pngFiles)
{
// Get the name of a file without the extension.
var resourceName = Path.GetFileNameWithoutExtension(pngFile);
// Import the image file to the Library > Resource Files > Images directory and create a Single Texture that uses this image.
// To import an image without creating a texture, set the second parameter of the ImportImages command to false.
studio.Commands.ImportImages(studio.ActiveProject, Path.Combine(directory, pngFile), true);
// Get the texture you created.
var texture = textureLibrary.GetItemByName(resourceName);
// Create a Texture Brush in the Library > Materials and Textures > Brushes and name it after the texture.
var myTextureBrush = studio.ActiveProject.CreateBrush(
brushLibrary.GenerateUniqueChildName(resourceName),
brushLibrary,
studio.ActiveProject.BrushTypeLibrary.GetItemByName("Kanzi.TextureBrush"));
// Set the Brush Texture property of the Texture Brush to the texture you created.
myTextureBrush.Set(myTextureBrush.PropertyTypes.TextureBrushRenderTexture.Name, texture);
}
}
NodeComponent CreateNodeComponent ( string  name,
NodeComponentHost  parent,
NodeComponentType  nodeComponentType 
)

Creates a node component to the specified parent.

Parameters
nameThe name of the node component.
parentThe NodeComponentHost in which you want to create the node component.
nodeComponentTypeThe type of the node component you create with this function. NodeComponentTypeLibrary stores the node component types available in a Kanzi Studio project.
Returns
The node component you create with this function.
See also
NodeComponentTypeLibrary, NodeComponentHost.CreateNodeComponent(string, NodeComponentType), NodeComponentHost.CreateNodeComponent(NodeComponent), ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a 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");
// Get the Animation Player node component type.
var animationPlayerType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName("Kanzi.AnimationPlayer");
// Create an Animation Player named Root Animation Player in the RootPage node.
var animationPlayer = studio.ActiveProject.CreateNodeComponent(
rootPage.GenerateUniqueChildName("Root Animation Player"), rootPage, animationPlayerType);
}
ProjectItem CreateProjectItem ( Type  projectItemType,
string  name,
ProjectItem  parent 
)

Creates a project item.

Use this function to create Kanzi nodes and resources.

Parameters
projectItemTypeThe type of the item.
nameThe name of the item.
parentThe parent item of the item you create with this function.
Returns
The item you create with this function.
See also
ChildContainer.GenerateUniqueChildName, CreateProjectItem<T>(string, ProjectItem), GetProjectItem

Examples

To create five Page nodes in the RootPage node:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create five Page nodes in the RootPage node.
var count = "";
for (var i = 1; i <= 5; i++)
{
count = i.ToString();
studio.ActiveProject.CreateProjectItem(typeof(Page), rootPage.GenerateUniqueChildName("Page " + count), rootPage);
}
// Print "Created 5 Page nodes in the RootPage node" to the Kanzi Studio Log window.
studio.Log("Created " + count + " " + typeof(Page).Name + " nodes in the " + rootPage.Name + " node");
}
T CreateProjectItem< T > ( string  name,
ProjectItem  parent 
)

Creates a project item.

Use this function to create Kanzi nodes and resources.

Template Parameters
TThe type of the item you want to create with this function.
Parameters
nameThe name of the item.
parentThe parent item of the item you create with this function.
Returns
The item you create with this function.
See also
ChildContainer.GenerateUniqueChildName, CreateProjectItem(Type, string, ProjectItem), GetProjectItem

Examples

To create a function which creates an Empty Node 2D:

// This example shows how you can create a function which creates an Empty Node 2D node as a child node of the node,
// location of which you pass as a parameter. For example, you can prompt the user to provide the path of the parent node,
// or use the GetProjectItem function to get the parent node.
private Node2D CreateEmptyNode2D(Node2D parentNode)
{
// Create an Empty Node 2D node. You use the Project as a factory.
// The first parameter defines the name of the node. Use the GenerateUniqueChildName function,
// because the names of sibling nodes must be unique. The second parameter defines the location
// of the parent node of the Empty Node 2D node you create. You pass this parameter to the
// CreateEmptyNode2D function when you call it.
var emptyNode2D = studio.ActiveProject.CreateProjectItem<EmptyNode2D>(parentNode.GenerateUniqueChildName("Empty Node 2D"), parentNode);
// Make the Empty Node 2D 300 pixels high by setting its Layout Height property.
emptyNode2D.Set(emptyNode2D.PropertyTypes.NodeHeight, 300.0f);
// Make the Empty Node 2D 400 pixels wide by setting its Layout Width property.
emptyNode2D.Set(emptyNode2D.PropertyTypes.NodeWidth, 400.0f);
return emptyNode2D;
}
Type Constraints
T :ProjectItem 
RenderPass CreateRenderPass ( string  name,
IComposerContainer  parent,
RenderPassType  renderPassType 
)

Creates a render pass.

Use this function to create render passes of different types in the Render Passes library of a Kanzi Studio project.

Parameters
nameThe name of the render pass.
parentThe parent render pass of the render pass you create with this function.
renderPassTypeThe type of the render pass. RenderPassTypeLibrary stores the render pass types available in a Kanzi Studio project.
Returns
The render pass you create with this function.
See also
RenderPassTypeLibrary, ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a basic set of render passes which first clear depth and then draw all the content of the scene:

// This example creates this hierarchy of render passes:
// - Group Render Pass
// - Clear Render Pass
// - Draw Objects Render Pass
// It then sets Kanzi Studio to render the Screens/Screen/RootPage/Viewport 2D/Scene node using the Group Render Pass.
public void Execute(PluginCommandParameter parameter)
{
// Get the Group Render Pass render pass type.
var groupRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.RenderPass");
// Create a Group Render Pass in the Library > Rendering > Render Passes.
var groupRenderPass = studio.ActiveProject.CreateRenderPass(
studio.ActiveProject.GenerateUniqueChildName("Group Render Pass"), Project.ComposerLibrary.PluginWrapper, groupRenderPassType);
// Get the Clear Render Pass render pass type.
var clearRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.ClearRenderPass");
// Create a Clear Render Pass in the Group Render Pass you created.
var clearRenderPass = studio.ActiveProject.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Clear Render Pass"), groupRenderPass, clearRenderPassType);
// Get the Draw Objects Render Pass render pass type.
var drawObjectsRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.DrawObjectsRenderPass");
// Create a Draw Objects Render Pass in the Group Render Pass you created.
var drawObjectsRenderPass = studio.ActiveProject.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Draw Objects Render Pass"), groupRenderPass, drawObjectsRenderPassType);
// Get the Screens/Screen/RootPage/Viewport 2D/Scene node.
var sceneNode = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Set the Render Pass property of the Scene node to the Group Render Pass you created.
sceneNode.Set(Properties.SceneRenderPass.Name, groupRenderPass);
}

To create render passes which render to a composition target and draw that to the screen use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Clear Color property for a Clear Render Pass.

// This example creates this hierarchy of render passes:
// - Group Render Pass
// - Composition Target Render Pass which divides the resolution of its composition target by 4
// - Clear Render Pass which clears the color buffer with transparent black color
// - Draw Objects Render Pass which renders all content
// - Blit Render Pass which draws the Composition Target Render Pass to the screen
// It then creates a Sphere node in the Screens/Screen/RootPage/Viewport 2D/Scene node and
// sets Kanzi Studio to render the Scene node using the Group Render Pass.
public void Execute(PluginCommandParameter parameter)
{
// Get the Group Render Pass render pass type.
var groupRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.RenderPass");
// Create a Group Render Pass in the Library > Rendering > Render Passes.
var groupRenderPass = studio.ActiveProject.CreateRenderPass(
studio.ActiveProject.GenerateUniqueChildName("Group Render Pass"), Project.ComposerLibrary.PluginWrapper, groupRenderPassType);
// Get the Composition Target Render Pass render pass type.
var compositionTargetRenderPassType
= studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.CompositionTargetRenderPass");
// Create a Composition Target Render Pass in the Group Render Pass you created.
var compositionTargetRenderPass = studio.ActiveProject.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Composition Target Render Pass"), groupRenderPass, compositionTargetRenderPassType);
// Set the Resolution Divisor property of the Composition Target Render Pass to 4.
compositionTargetRenderPass.Set(
compositionTargetRenderPass.PropertyTypes.CompositionTargetRenderPassResolutionDivisor, 4);
// Get the Clear Render Pass render pass type.
var clearRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.ClearRenderPass");
// Create a Clear Render Pass in the Composition Target Render Pass you created.
var clearRenderPass = studio.ActiveProject.CreateRenderPass(
compositionTargetRenderPass.GenerateUniqueChildName("Clear Render Pass"), compositionTargetRenderPass, clearRenderPassType);
// In the Clear Render Pass add the Clear Color property and set it to transparent black.
clearRenderPass.Set(
clearRenderPass.PropertyTypes.ClearRenderPassClearColor, System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
// Get the Draw Objects Render Pass render pass type.
var drawObjectsRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.DrawObjectsRenderPass");
// Create a Draw Objects Render Pass in the Composition Target Render Pass you created.
studio.ActiveProject.CreateRenderPass(
compositionTargetRenderPass.GenerateUniqueChildName("Draw Objects Render Pass"), compositionTargetRenderPass, drawObjectsRenderPassType);
// Get the Blit Render Pass render pass type.
var blitRenderPassType = studio.ActiveProject.RenderPassTypeLibrary.GetItemByName("Kanzi.BlitRenderPass");
// Create a Blit Render Pass in the Group Render Pass you created.
var blitRenderPass = studio.ActiveProject.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Blit Render Pass"), groupRenderPass, blitRenderPassType);
// Set the Texture0 property of the Blit Render Pass to the Composition Target Render Pass you created.
blitRenderPass.Set(blitRenderPass.PropertyTypes.BlitRenderPassTexture0.Name, compositionTargetRenderPass);
// Get the Screens/Screen/RootPage/Viewport 2D/Scene node.
var sceneNode = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Create a Sphere node in the Scene node.
studio.ActiveProject.CreateProjectItem<SphereMeshNode>(sceneNode.GenerateUniqueChildName("Sphere"), sceneNode);
// Set the Render Pass property of the Scene node to the Group Render Pass you created.
sceneNode.Set(Properties.SceneRenderPass.Name, groupRenderPass);
}
ProjectItem GetProjectItem ( string  projectItemPath)

Gets a project item.

For example, use this function to get a node in the scene graph and then add child nodes to it, or add, set, and modify the values of the node properties.

Parameters
projectItemPathThe path to the project item you want to get.
Returns
The project item at the path you pass to the function.

Examples

To get a project item:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootPage node in the scene graph.
var rootNode = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
}

Property Documentation

BrushLibrary BrushLibrary
get

Gets the Brushes library which stores brushes used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Brushes library in a Kanzi Studio project.

See also
CreateBrush(string, BrushLibrary, BrushType), CreateBrush(string, BrushLibrary, BrushTypeEnum), BrushTypeLibrary, ProjectItemLibrary<T>.GetItemByName(string)

Examples

To get a brush from the Brushes library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Brushes library which stores brushes used in a Kanzi Studio project.
var brushesLibrary = studio.ActiveProject.BrushLibrary;
// Get the DefaultBackground texture brush from the Brushes library.
var defaultBackground = brushesLibrary.GetItemByName("DefaultBackground");
}
BrushTypeLibrary BrushTypeLibrary
get

Gets the brush types available in a Kanzi Studio project.

See also
CreateBrush(string, BrushLibrary, BrushType), BrushLibrary, ProjectItemLibrary<T>.Items

Examples

To get the brush types available in a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Brush Type library which stores the brush type available in a Kanzi Studio project.
var brushTypeLibrary = studio.ActiveProject.BrushTypeLibrary;
// Print the available brush types to the Kanzi Studio Log window.
studio.Log("These brush types are available in this Kanzi Studio project:");
foreach (var brushType in brushTypeLibrary.Items)
{
studio.Log(brushType.Name);
}
}
ComposerLibrary ComposerLibrary
get

Gets the Render Passes library which stores the legacy render passes used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

See also
RenderPassTypeLibrary, ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem)

Examples

To create a Legacy Render Pass in the Render Passes library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Composers library which stores composers and render passes used in a Kanzi Studio project.
var composersLibrary = studio.ActiveProject.ComposerLibrary;
// Create a Legacy Render Pass named MyRenderPass in the Composers library.
var renderPass = studio.ActiveProject.CreateProjectItem<LegacyRenderPass>(
composersLibrary.GenerateUniqueChildName("MyRenderPass"),
composersLibrary);
}
FontDirectory FontDirectory
get

Gets the Fonts directory which contains the fonts in a Kanzi Studio project.

After you get the directory, you can access and import fonts.

GenericResourceFileDirectory GenericResourceFileDirectory
get

Gets the Generic directory which contains the generic resource files in a Kanzi Studio project.

After you get the directory, you can access and import files.

Examples

To import a text file to the Generic directory:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Resource Files > Generic directory which stores
// all the generic resource files in a Kanzi Studio project.
var genericResourceDirectory = studio.ActiveProject.GenericResourceFileDirectory;
// Import the C:\\Temp\MyFile.xml file to the Generic directory.
// To import multiple files, use commas to separate the file locations.
// You set the last parameter as null because you do not want to import the file to the Textures library.
studio.Commands.ImportResources(new List<string> { "C:\\Temp\\MyFile.xml" }, genericResourceDirectory, null);
}
ImageDirectory ImageDirectory
get

Gets the Images directory which contains the image files in a Kanzi Studio project.

See also
TextureLibrary, CreateBrush(string, BrushLibrary, BrushType)

Examples

To get an image file in the Images directory of a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Images directory which contains the image files in a Kanzi Studio project.
var imageDirectory = studio.ActiveProject.ImageDirectory;
// Get an image file in the Images directory.
var imageFile = imageDirectory.Children.OfType<ImageFile>().First();
// Print the path to the Images directory to the Kanzi Studio Log window.
studio.Log("The image files of this project are stored in " + imageFile.FileSystemParentDirectory);
}

To import an image to the Images directory:

public void Execute(PluginCommandParameter parameter)
{
// Import the C:\\Temp\MyImage.png file to the Library > Resource Files > Images directory
// and create a Single Texture that uses this image. To import an image without creating a texture,
// set the third parameter of the ImportImages command to false.
studio.Commands.ImportImages(studio.ActiveProject, "C:\\Temp\\MyImage.png", true);
}
MaterialLibrary MaterialLibrary
get

Gets the Materials library which contains the materials in a Kanzi Studio project.

After you get the library, you can access and create materials.

See also
MaterialTypeLibrary, CreateProjectItem<T>(string, ProjectItem), ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a material in the Materials library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Materials and Textures > Material Types library
// which stores all the material types in a Kanzi Studio project.
var materialTypeLibrary = studio.ActiveProject.MaterialTypeLibrary;
// In the Material Types library create a Material Type named MyMaterialType.
var myMaterialType = studio.ActiveProject.CreateProjectItem<MaterialType>(
materialTypeLibrary.GenerateUniqueChildName("MyMaterialType"), materialTypeLibrary);
// Get the Library > Materials and Textures > Materials library
// which stores all the materials in a Kanzi Studio project.
var materialLibrary = studio.ActiveProject.MaterialLibrary;
// In the Materials library create a material named MyMaterialTypeMaterial.
var myMaterial = studio.ActiveProject.CreateProjectItem<Material>(
materialLibrary.GenerateUniqueChildName(myMaterialType.Name + "Material"), materialLibrary);
// Set the Material Type property of MyMaterialTypeMaterial to MyMaterialType.
myMaterial.Set(myMaterial.PropertyTypes.MaterialType.Name, materialTypeLibrary.GetItemByName(myMaterialType.Name));
}
MaterialTypeLibrary MaterialTypeLibrary
get

Gets the Material Types library which contains the material types in a Kanzi Studio project.

After you get the library, you can access and create material types.

See also
MaterialLibrary, ShaderSourceDirectory, CreateProjectItem<T>(string, ProjectItem), ProjectItemLibrary<T>.Items

Examples

To get all material types in the Material Types library of a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Materials and Textures > Material Types library
// which stores all the material types in a Kanzi Studio project.
var materialTypeLibrary = studio.ActiveProject.MaterialTypeLibrary;
// Print the name of all material types in your project to the Kanzi Studio Log window.
studio.Log("This Kanzi Studio project contains these material types:");
foreach (var materialType in materialTypeLibrary.Items)
{
studio.Log(materialType.Name);
}
}

To create a function that creates a material type from vertex and fragment shaders:

// Create a function that creates a Material Type and takes as its input the paths to the files
// that contain the vertex and fragment shaders for this material type.
private void CreateMaterialType(string name, string vertexShaderPath, string fragmentShaderPath)
{
// Create a Material Type in the Library > Materials and Textures > Material Types library.
var materialTypeLibrary = studio.ActiveProject.MaterialTypeLibrary;
var materialType = studio.ActiveProject.CreateProjectItem<MaterialType>(
materialTypeLibrary.GenerateUniqueChildName(name), materialTypeLibrary);
// Set the material type you created to use the vertex shader that you pass to the function.
// Read the content of the file which contains the vertex shader code that you want to use.
// To use this function, in the class library file that implements the PluginCommand interface
// add the using directive for the System.IO namespace.
string vertexShaderSource = File.ReadAllText(vertexShaderPath);
// Get the vertex shader of the material type you created.
var vertexShader = materialType.Children.OfType<VertexShader>().First();
// Get the vertex shader source file.
var vertexShaderSourceFile = vertexShader.Get(vertexShader.PropertyTypes.ShaderSourceFile);
// Get the path to the vertex shader source file.
var vertexShaderSourceFileFileSystemPath = vertexShaderSourceFile.FileSystemPath;
if (File.Exists(vertexShaderSourceFileFileSystemPath))
{
// Replace the content of the existing vertex shader with the vertex shader you pass to the function.
File.WriteAllText(vertexShaderSourceFileFileSystemPath, vertexShaderSource);
}
// Set the material type you created to use the fragment shader you pass to the function.
// Use the same approach you used to set the vertex shader.
string fragmentShaderSource = File.ReadAllText(fragmentShaderPath);
var fragmentShader = materialType.Children.OfType<FragmentShader>().First();
var fragmentShaderSourceFile = fragmentShader.Get(fragmentShader.PropertyTypes.ShaderSourceFile);
var fragmentShaderSourceFileFileSystemPath = fragmentShaderSourceFile.FileSystemPath;
if (File.Exists(fragmentShaderSourceFileFileSystemPath))
{
File.WriteAllText(fragmentShaderSourceFileFileSystemPath, fragmentShaderSource);
}
// Create a material which uses the material type you created.
var materialLibrary = studio.ActiveProject.MaterialLibrary;
var material = studio.ActiveProject.CreateProjectItem<Material>(
materialLibrary.GenerateUniqueChildName(name + "Material"), materialLibrary);
material.Set(material.PropertyTypes.MaterialType, materialType);
}
MeshLibrary MeshLibrary
get

Gets the Meshes library which contains the meshes in a Kanzi Studio project.

See also
ProjectItemLibrary<T>.Items

Examples

To get the meshes in a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Meshes library which stores all the meshes in a Kanzi Studio project.
var meshLibrary = studio.ActiveProject.MeshLibrary;
// If the project contains meshes, print their names and the number of meshes in the Kanzi Studio Log window.
if (meshLibrary.Items.Any())
{
var count = meshLibrary.Items.Count().ToString();
studio.Log("This Kanzi Studio project contains " + count + " meshes:");
foreach (var mesh in meshLibrary.Items)
{
studio.Log(mesh.Name);
}
}
else
{
studio.Log("This Kanzi Studio project does not contain meshes.");
}
}
NodeComponentTypeLibrary NodeComponentTypeLibrary
get

Gets the node component types available in a Kanzi Studio project.

See also
CreateNodeComponent, NodeComponentHost, ProjectItemLibrary<T>.Items

Examples

To get the node component types available in Kanzi:

public void Execute(PluginCommandParameter parameter)
{
// Get the node component type library.
var nodeComponentsLibrary = studio.ActiveProject.NodeComponentTypeLibrary;
// Print the available node component types to the Kanzi Studio Log window.
studio.Log("These node component types are available in this Kanzi Studio project:");
foreach (var nodeComponentType in nodeComponentsLibrary.Items)
{
studio.Log(nodeComponentType.Name);
}
}
PageTransitionCollectionLibrary PageTransitionCollectionLibrary
get

Gets the Page Transitions library which contains the page transitions in a Kanzi Studio project.

After you get the library, you can access and create page transitions.

Examples

To create and configure a page transition:

// This example creates a Fade Transition which animates the opacity of the Page nodes
// between which the transition happens.
public void Execute(PluginCommandParameter parameter)
{
// Get the Page Transitions library which stores the page transitions in a Kanzi Studio project.
var pageTransitionsLibrary = studio.ActiveProject.PageTransitionCollectionLibrary;
// Create a Page Transition Collection named My Transition Collection in the Page Transitions library.
var myTransitionCollection = studio.ActiveProject.CreateProjectItem<PageTransitionCollection>(
pageTransitionsLibrary.GenerateUniqueChildName("My Transition Collection"),
pageTransitionsLibrary);
// Get the Page Host node RootPage in the Screens/Screen node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen").GetChild<PageHost>("RootPage");
// Set the Transition property of the RootPage node to My Transition Collection.
// This way you set the RootPage node to use the page transitions in My Transition Collection.
rootPage.Set(rootPage.PropertyTypes.PageHostTransitions.Name, myTransitionCollection);
// Create three Page nodes in the RootPage node. In each Page node create a Text Block 2D node and
// set the Text property of the Text Block 2D node to the name of its parent Page node.
for (var i = 1; i <= 3; i++)
{
var page = studio.ActiveProject.CreateProjectItem<Page>(
rootPage.GenerateUniqueChildName("Page"),
rootPage);
var textBlock = studio.ActiveProject.CreateProjectItem<TextBlock2D>(
page.GenerateUniqueChildName("Text Block 2D"),
page);
textBlock.Set(textBlock.PropertyTypes.TextBlockConceptText, page.Name);
}
// Get the Page node named Page in the RootPage node.
var pageNode = rootPage.GetChild<Page>("Page");
// Set the Default Subpage property of the RootPage node to the Page node.
rootPage.Set(rootPage.PropertyTypes.PageHostDefaultSubPage, new NodeReference<Node2D>(pageNode));
// Create a Page Transition named Fade Transition in My Transition Collection.
var fadeTransition = studio.ActiveProject.CreateProjectItem<PageTransition>(
myTransitionCollection.GenerateUniqueChildName("Fade Transition"),
myTransitionCollection);
// Configure the Fade Transition:
// Set the Duration property to 200. This way you set the length of the transition to 200 ms.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionDuration, 200);
// Set the From property to the node named Page.
// This way you make the transition apply only when navigating from the node named Page.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionFrom, pageNode.Name);
// Set the To property to *. This way you apply the transition when navigating to all Page nodes.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionTo, "*");
// Set the Direction property to Unidirectional.
// Use the Direction property to set whether the transition applies to the transition
// from the nodes you set in the From property to the nodes you set in the To property,
// or to the transitions from both nodes.
// To set the Direction property of a Page Transition:
// - For Bidirectional use 0.
// This way you apply the transition to the transition from the nodes in the From property to
// the nodes in the To property, and from the nodes in the To property to the nodes in the From property.
// - For Unidirectional use 1.
// This way you apply the transition only to the transition from the nodes in the From property
// to the nodes in the To property.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionDirection, 1);
// Create a Page Transition Animation named Opacity In.
var fadeTransitionInAnimation = studio.ActiveProject.CreateProjectItem<PageTransitionAnimation>(
fadeTransition.GenerateUniqueChildName("Opacity In"),
fadeTransition);
// Configure the Opacity In animation:
// Set the Animation Target property to Page In.
// To set the Animation Target property of a Page Transition Animation:
// - For Page In use 0.
// This way you use the animation when navigating to the set Page or Page Host node.
// - For Page Out use 1.
// This way you use the animation when navigating from the set Page or Page Host node.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationAnimationTarget, 0);
// Set the Transition Property to Node.Opacity. This way you animate the Opacity property.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationPropertyType,
Properties.NodeOpacity);
// Set the Start Value property to 0.
// This way you set the value of the Transition Property to 0 when the transition animation starts.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationStartValue, "0");
// Set the End Value property to 1.
// This way you set the value of the Transition Property to 1 when the transition animation ends.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationEndValue, "1");
// Create a Page Transition Animation named Opacity Out.
var fadeTransitionOutAnimation = studio.ActiveProject.CreateProjectItem<PageTransitionAnimation>(
fadeTransition.GenerateUniqueChildName("Opacity Out"),
fadeTransition);
// Configure the Opacity Out animation:
// Set the Animation Target property to Page Out.
fadeTransitionOutAnimation.Set(
fadeTransitionOutAnimation.PropertyTypes.PageTransitionAnimationAnimationTarget, 1);
// Set the Transition Property to Node.Opacity.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationPropertyType,
Properties.NodeOpacity);
// Set the Start Value property to 1.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationStartValue, "1");
// Set the End Value property to 0.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationEndValue, "0");
}
PipelineItemLibrary PipelineItemLibrary
get

Gets the Object Sources library which contains the object sources and filters in a Kanzi Studio project.

After you get the library, you can access and create object sources and filters.

See also
TagLibrary

Examples

To create a Tag Filter:

public void Execute(PluginCommandParameter parameter)
{
// Get the Object Sources library in Library > Rendering which stores
// the object sources and filters in a Kanzi Studio project.
var pipeLineItemLibrary = studio.ActiveProject.PipelineItemLibrary;
// Create a Tag Filter named My Tag Filter in the Object Sources library.
var myTagFilter = studio.ActiveProject.CreateProjectItem<TagFilterObjectSource>(
pipeLineItemLibrary.GenerateUniqueChildName("My Tag Filter"),
pipeLineItemLibrary);
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.ActiveProject.TagLibrary;
// Create a tag named My Tag in the Tags library.
var myTag = studio.ActiveProject.CreateProjectItem<Tag>(
tagsLibrary.GenerateUniqueChildName("My Tag"), tagsLibrary);
// Create a list of tags which contains the My Tag tag.
var tagList = new List<Tag>(new Tag[] { myTag });
// Set the Included Tags property of the My Tag Filter to My Tag.
// This way you set the filter to pick the nodes that have the My Tag tag.
myTagFilter.Set(myTagFilter.PropertyTypes.TagFilterIncludeList, tagList);
}
PrefabLibrary PrefabLibrary
get

Gets the Prefabs library which contains the prefabs used in a Kanzi Studio project.

After you get the library, you can access and create prefabs.

The Prefabs library in a Kanzi Studio project.

See also
CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem), GetProjectItem(string)

Examples

To create a prefab in the Prefabs library and instantiate it:

public void Execute(PluginCommandParameter parameter)
{
// Create a prefab template:
// Get the Prefabs library which stores all the prefabs in a Kanzi Studio project.
var prefabsLibrary = studio.ActiveProject.PrefabLibrary;
// In the Prefabs library create a prefab template named My Prefab which can hold 3D nodes.
// For 2D nodes you have to create a 2D prefab template.
var myPrefabTemplate = studio.ActiveProject.CreateProjectItem<Node3DPrefabTemplate>(
prefabsLibrary.GenerateUniqueChildName("My Prefab"), prefabsLibrary);
// Create an Empty Node 3D node named My Prefab as the root node of the prefab.
var rootNode = studio.ActiveProject.CreateProjectItem<EmptyNode>(
myPrefabTemplate.GenerateUniqueChildName(myPrefabTemplate.Name), myPrefabTemplate);
// If the Empty Node 3D node is the root of a 3D prefab template
// print to the Log a message about successful creation of the prefab template.
if (rootNode.Parent.ProjectItemType == typeof(Node3DPrefabTemplate))
{
studio.Log("Created a prefab named " + rootNode.Name);
}
// Create in the prefab a child node:
// Get the component type of the Button 3D node.
var componentType = studio.ActiveProject.ComponentTypeLibrary.GetComponentType("Kanzi.Button3D");
// Use the component type you just created to create a Button 3D node in the root node of My Prefab.
var button = studio.ActiveProject.CreateComponentNode("Button 3D", rootNode, componentType);
// Instantiate the prefab that you created:
// Get the node where you want to instantiate the prefab.
var instantiateHere = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Create the Prefab Placeholder node which instantiates the prefab in the scene graph.
var prefabInstance = studio.ActiveProject.CreateProjectItem<Node3DPrefabPlaceholder>(
instantiateHere.GenerateUniqueChildName("Placeholder"), instantiateHere);
// Create a resource reference from the prefab template which you want to instantiate.
var reference = new ResourceReference<Node3DPrefabTemplate>(myPrefabTemplate);
// Instantiate the prefab you created by setting the Prefab Template property
// to the prefab template reference you created in the previous line.
prefabInstance.Set(prefabInstance.PropertyTypes.Node3DPrefabPlaceholderTemplate, reference);
}
ProjectReferenceLibrary ProjectReferenceLibrary
get

Gets the Project References library which stores the project references and kzb file references in a Kanzi Studio project.

See also
ProjectItemLibrary<T>.Items

Examples

To convert all project references to kzb file references:

public void Execute(PluginCommandParameter parameter)
{
// Get the Project References library which stores all the project references and kzb file references in
// a Kanzi Studio project, iterate through the items in the library, and convert each project reference
// to a kzb file reference.
foreach (var reference in studio.ActiveProject.ProjectReferenceLibrary.Items.OfType<ProjectReferenceItem>())
{
studio.Commands.ConvertProjectReferenceItemToKzbReferenceItem(reference);
}
}
RenderPassTypeLibrary RenderPassTypeLibrary
get

Gets the render pass types available in a Kanzi Studio project.

See also
CreateRenderPass, ProjectItemLibrary<T>.Items

Examples

To get the render pass types available in Kanzi:

public void Execute(PluginCommandParameter parameter)
{
// Get the render pass type library.
var renderPassTypeLibrary = studio.ActiveProject.RenderPassTypeLibrary;
// Print the available render pass types to the Kanzi Studio Log window.
studio.Log("These render pass types are available in this Kanzi Studio project:");
foreach (var renderPassType in renderPassTypeLibrary.Items)
{
studio.Log(renderPassType.Name);
}
}

Gets the Screen node in a Kanzi Studio project.

The Screen node is the root node of the scene graph in Kanzi.

The Screen node.

See also
PluginInterface.Screen.RootNode2D

Examples

To get the Screen node:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screen node.
var screen = studio.ActiveProject.Screen;
// Set the Metrics Type property of the Screen node to Absolute.
screen.Set(screen.PropertyTypes.WindowMetricsType, LengthTypeEnum.ABSOLUTE);
// Set the Width property of the Screen node to 1920.
screen.Set(screen.PropertyTypes.WindowAbsoluteWidth, 1920);
// Set the Height property of the Screen node to 1080.
screen.Set(screen.PropertyTypes.WindowAbsoluteHeight, 1080);
}
ShaderSourceDirectory ShaderSourceDirectory
get

Gets the Shaders directory which stores the shader source files in a Kanzi Studio project.

See also
MaterialTypeLibrary

Examples

To get all shader source files in the Shaders directory of a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Shaders directory which contains the shader source files in a Kanzi Studio project.
var shaderSourceDirectory = studio.ActiveProject.ShaderSourceDirectory;
// Print the path of all shader source files in your project to the Kanzi Studio Log window.
studio.Log("This Kanzi Studio project contains these shader source files:");
foreach (var shaderFile in shaderSourceDirectory.Items)
{
studio.Log(shaderFile.FileSystemPath);
}
}
ShortcutLibrary ShortcutLibrary
get

Gets the Bookmarks library which stores the bookmarks in a Kanzi Studio project.

After you get the library, you can access and create bookmarks.

Examples

To create a bookmark in the Bookmarks library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Bookmarks library which stores the bookmarks in a Kanzi Studio project.
var bookmarkLibrary = studio.ActiveProject.ShortcutLibrary;
// 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);
// Create a bookmark named Button 2D in the Bookmarks library.
var buttonBookmark = studio.ActiveProject.CreateProjectItem<Shortcut>(
bookmarkLibrary.GenerateUniqueChildName("Button 2D"),
bookmarkLibrary);
// Set the Target property of the bookmark to the Button 2D node.
buttonBookmark.Set(buttonBookmark.PropertyTypes.ShortcutTarget, button);
}
StateManagerLibrary StateManagerLibrary
get

Gets the State Managers library which stores state managers used in a Kanzi Studio project.

After you get the library, you can access and create state managers in that library.

The State Manager library in a Kanzi Studio project.

See also
StateGroup, State, StateObject, StateTransition, ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a state manager with a state group, state, and a state object in the State Managers library:

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"),
myStateManager);
// Create a state named MyState in the MyStateGroup state group.
var myState = studio.ActiveProject.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("MyState"),
myStateGroup);
// Create a state object named MyStateObject in MyState state.
var myStateObject = studio.ActiveProject.CreateProjectItem<StateObject>(
myState.GenerateUniqueChildName("MyStateObject"),
myState);
}

To get a state manager from the State Managers library:

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.
studio.ActiveProject.CreateProjectItem<StateManager>(stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Get a state manager named MyStateManager from the State Managers library.
var myStateManager = stateManagerLibrary.GetItemByName("MyStateManager");
}
StyleLibrary StyleLibrary
get

Gets the Styles library which stores styles used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Styles library in a Kanzi Studio project.

See also
ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem), ProjectItemLibrary<T>.GetItemByName(string)

Examples

To create a named style in the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.ActiveProject.StyleLibrary;
// Create a named style named MyNamedStyle in the Styles library.
var myNamedStyle = studio.ActiveProject.CreateProjectItem<StyleItem>(
stylesLibrary.GenerateUniqueChildName("MyNamedStyle"), stylesLibrary);
}

To create a typed style in the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.ActiveProject.StyleLibrary;
// Create a named style named MyTypedStyle in the Styles library.
var myTypedStyle = studio.ActiveProject.CreateProjectItem<StyleItem>(
stylesLibrary.GenerateUniqueChildName("MyTypedStyle"), stylesLibrary);
// Convert the named style you just created to a typed style
myTypedStyle.Set(myTypedStyle.PropertyTypes.StyleType, StyleTypeEnum.GENERIC);
}

To get a style from the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.ActiveProject.StyleLibrary;
// Create a named style named MyNamedStyle in the Styles library.
studio.ActiveProject.CreateProjectItem<StyleItem>(stylesLibrary.GenerateUniqueChildName("MyNamedStyle"), stylesLibrary);
// Get the named style named MyNamedStyle from the Styles library.
var myNamedStyle = stylesLibrary.GetItemByName("MyNamedStyle");
}
TagLibrary TagLibrary
get

Gets the Tags library which stores tags used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Tags library in a Kanzi Studio project.

See also
ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem), ProjectItemLibrary<T>.GetItemByName(string), PipelineItemLibrary

Examples

To get a tag from the Tags library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.ActiveProject.TagLibrary;
// Get the default tag Transparent from the Tags library.
var tagTransparent = tagsLibrary.GetItemByName("Transparent");
}

To create a tag in the Tags library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.ActiveProject.TagLibrary;
// Create a tag named MyTag in the Tags library.
var tag = studio.ActiveProject.CreateProjectItem<Tag>(tagsLibrary.GenerateUniqueChildName("MyTag"), tagsLibrary);
}
TextureLibrary TextureLibrary
get

Gets the Textures library which stores textures used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Textures library in a Kanzi Studio project.

See also
ProjectItem.GetChild, ProjectItemLibrary<T>.GetItemByName(string)

Examples

To get a texture from the Textures library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Materials and Textures > Textures library
// which stores all the textures in a Kanzi Studio project.
var texturesLibrary = studio.ActiveProject.TextureLibrary;
// Get the DefaultTexture texture from the Textures library.
var defaultTexture = texturesLibrary.GetItemByName("Default Texture");
}

To create a Single Texture in the Textures library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Materials and Textures > Textures library.
var textureLibrary = studio.ActiveProject.TextureLibrary;
// Get the DefaultTextureImage.png image in the Images directory of the project.
if (studio.ActiveProject.ImageDirectory.GetChild("DefaultTextureImage.png") is ImageFile defaultImage)
{
// In the Textures library, create a Single Texture named My Single Texture.
var singleTexture = studio.ActiveProject.CreateProjectItem<SingleTexture>(
textureLibrary.GenerateUniqueChildName("My Single Texture"), textureLibrary);
// Set the Image property of the Single Texture to DefaultTextureImage.png.
singleTexture.Set(singleTexture.PropertyTypes.TextureImage, defaultImage);
}
}

To create a function that creates a Single Texture from an image file:

private Texture CreateTextureFromImage(string path)
{
// Get the Library > Materials and Textures > Textures library.
var textureLibrary = studio.ActiveProject.TextureLibrary;
// Get the name of the image file without the file extension.
// To use this function, in the class library file that implements the PluginCommand interface add the using directive for the System.IO namespace.
var resourceName = Path.GetFileNameWithoutExtension(path);
// Import the image file to the Library > Resource Files > Images library and create a Single Texture that uses this image file.
// To import an image without creating a texture, set the second parameter of the ImportImages command to false.
studio.Commands.ImportImages(studio.ActiveProject, path, true);
// Get the texture you created.
var texture = textureLibrary.GetItemByName(resourceName);
return texture;
}

To create a Render Target Texture in the Textures library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Library > Materials and Textures > Textures library.
var textureLibrary = studio.ActiveProject.TextureLibrary;
// In the Textures library, create a Render Target Texture named My Render Target Texture.
var renderTargetTexture = studio.ActiveProject.CreateProjectItem<RenderTargetTexture>(
textureLibrary.GenerateUniqueChildName("My Render Target Texture"), textureLibrary);
// Set the Width and Height properties of the Render Target Texture to 256.
renderTargetTexture.Set(renderTargetTexture.PropertyTypes.RenderTargetTextureWidth, 256);
renderTargetTexture.Set(renderTargetTexture.PropertyTypes.RenderTargetTextureHeight, 256);
}

Event Documentation

EventHandler BinaryExported

Occurs after the export of the kzb file of the project is completed.

Examples

To subscribe to the BinaryExported event:

// Create the event handler and subscribe to the BinaryExported event to get
// notified when Kanzi Studio finishes exporting the kzb file of the project.
public void Execute(PluginCommandParameter parameter)
{
// Create the event handler that is set off when Kanzi Studio finishes
// exporting the kzb file of the project.
studio.ActiveProject.BinaryExported += Project_BinaryExported;
}
private void Project_BinaryExported(object sender, EventArgs e)
{
// When Kanzi Studio finishes exporting the kzb file of the project,
// print a message to the Kanzi Studio Log window.
studio.Log("Finished exporting the kzb file of the project.");
}
EventHandler BinaryExporting

Occurs when the export of the kzb file of the project starts.

Examples

To subscribe to the BinaryExporting event:

// Create the event handler and subscribe to the BinaryExporting event to get
// notified when Kanzi Studio is exporting the kzb file of the project.
public void Execute(PluginCommandParameter parameter)
{
// Create the event handler that is set off when Kanzi Studio is exporting
// the kzb file of the project.
studio.ActiveProject.BinaryExporting += Project_BinaryExporting;
}
private void Project_BinaryExporting(object sender, EventArgs e)
{
// When Kanzi Studio is exporting the kzb file of the project,
// print a message to the Kanzi Studio Log window.
studio.Log("Exporting the kzb file of the project...");
}
EventHandler<ProjectSavingEventArgs> Saved

Occurs after Kanzi Studio successfully saves the project.

EventHandler<ProjectSavingEventArgs> Saving

Occurs when the saving of the project starts.