Kanzi  3.9.7
Kanzi Studio API
IUserPreferences Interface Reference

Access Kanzi Studio user preferences. More...

Public Member Functions

object GetSetting ([NotNull] string settingKey)
 Gets the value of a project-independent user preference setting. More...
 
GetSetting< T > ([NotNull] string settingKey, T defaultValue)
 Gets the value of a project-independent user preference setting. More...
 
void SetSetting ([NotNull] string settingKey, object value)
 Sets the value of project-independent user preference setting. More...
 

Events

EventHandler< UserPreferenceSettingChangedEventArgs > SettingChanged
 Raised when a user preference setting is changed. More...
 

Detailed Description

Access Kanzi Studio user preferences.

Use the IUserPreferences interface to store project-independent settings for your Kanzi Studio window plugins. For example, you can set the style or size of the icons in your plugin.

Member Function Documentation

object GetSetting ( [NotNull] string  settingKey)

Gets the value of a project-independent user preference setting.

Parameters
settingKeyThe key of the setting.
Returns
The value of the setting.

Examples

To get the value of a project-independent setting:

// This example sets the value of the MyPluginWindow.MySetting setting.
public void Execute(PluginCommandParameter parameter)
{
// Get the Kanzi Studio user preferences.
var userPreferences = studio.UserPreferences;
// Get the value of the MyPluginWindow.MySetting setting.
var mySetting = userPreferences.GetSetting("MyPluginWindow.MySetting");
// Print the value of the MyPluginWindow.MySetting setting to the Log window.
studio.Log(mySetting?.ToString());
}
T GetSetting< T > ( [NotNull] string  settingKey,
defaultValue 
)

Gets the value of a project-independent user preference setting.

Performs the type cast internally. If the value is missing or cannot be casted, returns the supplied default value.

Template Parameters
TThe expected type of the value.
Parameters
settingKeyThe key of the setting.
defaultValueThe value to use when failing to get the expected value.
Returns
The value of the setting. If the value is missing or cannot be casted, returns the supplied default value.
void SetSetting ( [NotNull] string  settingKey,
object  value 
)

Sets the value of project-independent user preference setting.

Replaces a possible existing value.

Parameters
settingKeyThe key of the setting.
valueThe value of the setting.

Examples

To set the value of a project-independent setting:

// This example gets the value of the MyPluginWindow.MySetting setting.
public void Execute(PluginCommandParameter parameter)
{
// Get the Kanzi Studio user preferences.
var userPreferences = studio.UserPreferences;
// Set the value of the MyPluginWindow.MySetting setting to the integer 10.
// If the setting does not exist, this command creates it.
userPreferences.SetSetting("MyPluginWindow.MySetting", 10);
}

Event Documentation

EventHandler<UserPreferenceSettingChangedEventArgs> SettingChanged

Raised when a user preference setting is changed.