Skip to content

Auto populating plugin settings

BarRaider edited this page Mar 24, 2021 · 1 revision

By following a very basic convention, the StreamDeck-Tools can handle populating all the settings between the PropertyInspector and your plugin. All the Stream-Deck Tools samples use this convention so you can see it in the samples too:

  1. In your Plugin create a private class that will hold your plugin's settings. In the samples and in this example, we will call the private class PluginSettings
  2. For each setting in your class, create a public property
  3. For each one of the public properties add a JsonPropery attribute. The PropertyName field should be identical to the name of the setting's field in the PropertyInspector's payload.
private class PluginSettings
{
    [JsonProperty(PropertyName = "title")]
    public String Title { get; set; }
}

In the example above, we created a property named Title, and added a JsonProperty attribute with the PropertyName of title. This means in our Payload we should have a field with the name title

  1. If you followed this for all your other properties, use the Tools.AutoPopulateSettings() method to Auto-populate all the properties inside your ReceivedSettings function:
public override void ReceivedSettings(ReceivedSettingsPayload payload) 
{
    Tools.AutoPopulateSettings(settings, payload.Settings);
}

Note: If you're using the filepicker, it's a little bit trickier: