IWidgetSettings

Description

interface Tinman.Engine.Widgets.IWidgetSettings

Derived from

IDisposable
IJsonizable

Extended by

IWidget

Base interface for widgets that have JSON settings.

After creating a IWidgetSettings instance, the SettingsPath may be specified while the object is in the LifecycleState.Created state. Calling Initialize will put it into the LifecycleState.Initialized state, where the settings path cannot be changed any more. As best practice, initialization code that does not depend on any settings and does complete quickly should be placed into the constructor, the remaining code should be put into Initialize.

Public / Methods

Initialize


[ThrowAny]
public method Initialize → ()

returns → bool

true if the object has been initialized,
false if the object has already been initialized before.

Initializes the widget, if necessary.

Screenshot


public method Screenshot → (1)

result in : WidgetScreenshotDelegate

[not-null]
The screenshot pixels will be passed to this delegate.

Takes a screenshot the next time this widget is rendered.

Public / Attributes

Settings​Path


public attribute SettingsPath → (get,set)

value : Path

Canonical path to the settings directory or null.

Path to a directory that this widget can use to store own data and settings.

The settings path may only be set before Initialize is called on the widget. Afterwards, the settings path cannot be changed.

Extensions

Settings​Load


public static method SettingsLoad → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → Path

Canonical path of the settings file that has been loaded or null if there were no previously saved settings or if the widget does not have a settings directory.

Loads the settings of this widget.

IOException

If an I/O error has occurred while reading the settings file.

ValidatingException

If the contents of the settings file is malformed.

Settings​Load​Try


public static method SettingsLoadTry → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → bool

true if the settings have been loaded, false if not.

Tries to load the settings of this widget, ignoring errors.

Settings​Save


public static method SettingsSave → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → Path

Canonical path of the settings file that has been saved or null if the widget does not have a settings directory.

Saves the settings of this widget.

IOException

If an I/O error has occurred while writing the settings file.

Settings​Save​Try


public static method SettingsSaveTry → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → bool

true if the settings have been saved, false if not.

Tries to save the settings of this widget, ignoring errors.