Kanzi  3.9.6
Kanzi Studio API
CustomEnumProperty Interface Reference

Configure enumeration property types. More...

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

Properties

IDictionary< string, int > Options [get, set]
 Gets or sets the set of unique key value pairs of an enumation property type. More...
 
- Properties inherited from TypedProperty< int >
DefaultValueTyped [get, set]
 

Detailed Description

Configure enumeration property types.

See also
PropertyTypeLibrary.CreateCustomEnumProperty(string, string, string, Dictionary<string, int>)

Examples

To create a property type of the enumeration data type and access its enumeration options:

public void Execute(PluginCommandParameter parameter)
{
// Get the Property Types library in the project.
var propertyTypesLibrary = studio.ActiveProject.PropertyTypeLibrary;
// Create a variable for the enumeration options of the enumeration property type.
// The enumeration options are a list of items (string) and values (int) to which Kanzi maps the items.
var options = new Dictionary<string, int>();
for (int i = 0; i <= 4; i++)
{
options.Add("Level" + i, i);
}
// Create an enumeration property type in the Property Types library and set:
// - Name to MyPlugin.MyEnumProperty
// Use the name of your plugin as the property type namespace to avoid naming conflicts
// with other property types in the Kanzi Studio project that use the project name as
// the default property type namespace.
// - Name as it is shown in Kanzi Studio to My Enum Property
// - Category in which Kanzi Studio shows the property type to My Plugin Properties
// - Enumeration Options to:
// Key | Value
// -------------------
// Level0 | 0
// Level1 | 1
// Level2 | 2
// Level3 | 3
// Level4 | 4
// Kanzi Studio by default sets:
// - Editor to Enumeration dropdown
// - Default Value to the first key in the enumeration options
var myCustomEnumProperty = propertyTypesLibrary.CreateCustomEnumProperty(
propertyTypesLibrary.GenerateUniqueChildName("MyPlugin.MyEnumProperty"),
"My Enum Property",
"My Plugin Properties",
options);
// Add to the enumeration options the key value pair Level5 and 5.
myCustomEnumProperty.Options.Add("Level5", 5);
// Print the enumeration options to the Kanzi Studio Log window.
studio.Log(myCustomEnumProperty.Name + " has these enumeration options:");
foreach (KeyValuePair<string, int> kvp in myCustomEnumProperty.Options)
{
studio.Log(kvp.Key + "\t" + kvp.Value);
}
}

Property Documentation

◆ Options

IDictionary<string, int> Options
getset

Gets or sets the set of unique key value pairs of an enumation property type.