Settings
Loading, Using, Saving Settings
To add settings to your plugin, you need to create a class and add public properties to it.
public class MySettings{ public string City { get; set; } = "New York";}Then, you need to add a field of this class to your plugin class with the settings attribute.
public class MyPlugin : ExtendedPlugin{ [Settings] public MySettings _settings;}This is it, now your settings are read from the settings file for you,
you can access them using the _settings field, and any changes in them are saved for you when you close Flow Launcher.
Settings UI
Let’s create a simple UI that will let us change the city in our MySettings class.
Create a UserControl in your project called MySettingsUi.xaml in your project and add the following code:
<UserControl x:Class="Your.Namespace.Here.MyPlugin.MySettingsUi" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Your.Namespace.Here.MyPlugin" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DataContext="{d:DesignInstance local:MySettings}" d:DesignHeight="300" d:DesignWidth="300" mc:Ignorable="d"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions>
<Label Content="Enter the city you'd like to look up the weather for:" />
<TextBox Grid.Column="1" Text="{Binding City}" /> </Grid></UserControl>Now, you need to modify MySettingsUi.xaml.cs.
You’ll accept your MySettings instance as a parameter of the constructor here
and set it as this control’s DataContext.
public partial class MySettingsUi : UserControl{ public SettingsUi(MySettings settings) { DataContext = settings; InitializeComponent(); }}All you have to do now is tell Flow Launcher how to create your settings UI.
You can do this back in Main.cs with the CreateSettingsUi attribute.
public class MyPlugin : ExtendedPlugin{ [Settings] public MySettings _settings;
[CreateSettingsUi] public Control CreateMySettingsUi() { return new MySettingsUi(_settings); }}Now, when you open the settings for your plugin in Flow Launcher, you should see a textbox where you can enter the city name. The settings are ready.