Added DeepL action setting
This commit is contained in:
7 files changed
+118
No files matched your search
@@ -108,9 +108,51 @@ public sealed partial class Setting : UserControl
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowDeepLActionSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetDeepLAction();
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_play_512__2_,
|
||||
SettingName: () => "DeepL Operation",
|
||||
SettingExplanation: () => "Should the missing translations be automatically completed by DeepL? This can lead to higher costs. By default, DeepL is only applied manually.",
|
||||
SetupDataControl: () =>
|
||||
{
|
||||
// We set up a combo box with the available actions:
|
||||
var dropdown = new ComboBox();
|
||||
dropdown.Items.Add("Manual");
|
||||
dropdown.Items.Add("Automatic");
|
||||
dropdown.SelectedIndex = currentSetting switch
|
||||
{
|
||||
SettingDeepLAction.MANUAL => 0,
|
||||
SettingDeepLAction.AUTOMATIC_ALL => 1,
|
||||
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
// Setup the change event handler:
|
||||
dropdown.SelectedValueChanged += async (sender, args) => await AppSettings.SetDeepLAction(dropdown.SelectedIndex switch
|
||||
{
|
||||
0 => SettingDeepLAction.MANUAL,
|
||||
1 => SettingDeepLAction.AUTOMATIC_ALL,
|
||||
|
||||
_ => SettingDeepLAction.MANUAL,
|
||||
});
|
||||
|
||||
// Apply the desired layout:
|
||||
dropdown.Dock = DockStyle.Fill;
|
||||
dropdown.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
return dropdown;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
public static IEnumerable<Task<Setting>> GetAllSettings()
|
||||
{
|
||||
yield return ShowDeepLActionSettingAsync();
|
||||
yield return ShowDeepLAPIKeySettingAsync();
|
||||
yield return ShowDeepLModeSettingAsync();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user