Added DeepL action setting

This commit is contained in:
tsommer committed 2022-07-30 16:38:38 +02:00
1 parent 9cd735ad5c
commit c211c9ef62
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();
}
+10
View File
@@ -200,6 +200,16 @@ namespace UI_WinForms.Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_play_512__2_ {
get {
object obj = ResourceManager.GetObject("icons8_play_512__2_", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -160,6 +160,9 @@
<data name="icons8_open_file_under_cursor_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-open-file-under-cursor-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_play_512__2_" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-play-512 (2).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_remove_tag_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-remove-tag-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB