Added the generator mode setting
This commit is contained in:
7 files changed
+146
-1
No files matched your search
@@ -388,9 +388,55 @@ public sealed partial class Setting : UserControl
|
||||
cultureIndices.Remove(innerLoopIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorModeSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetGeneratorMode();
|
||||
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_code_512,
|
||||
SettingName: () => "Generator Mode",
|
||||
ChangeNeedsRestart: false,
|
||||
SettingExplanation: () => "The generator mode determines how the translation files are generated.",
|
||||
SettingExplanationLink: () => (string.Empty, string.Empty),
|
||||
SetupDataControl: (changeTrigger) =>
|
||||
{
|
||||
// We set up a combo box with the available actions:
|
||||
var dropdown = new ComboBox();
|
||||
dropdown.Items.Add("Automatic generation");
|
||||
dropdown.Items.Add("Manual generation");
|
||||
dropdown.SelectedIndex = currentSetting switch
|
||||
{
|
||||
SettingGeneratorMode.AUTOMATIC => 0,
|
||||
SettingGeneratorMode.MANUAL => 1,
|
||||
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
// Setup the change event handler:
|
||||
dropdown.SelectedValueChanged += (sender, args) => changeTrigger();
|
||||
dropdown.SelectedValueChanged += async (sender, args) => await AppSettings.SetGeneratorMode(dropdown.SelectedIndex switch
|
||||
{
|
||||
0 => SettingGeneratorMode.AUTOMATIC,
|
||||
1 => SettingGeneratorMode.MANUAL,
|
||||
|
||||
_ => SettingGeneratorMode.AUTOMATIC,
|
||||
});
|
||||
|
||||
// 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 ShowGeneratorModeSettingAsync();
|
||||
yield return ShowDeepLSourceCultureSettingAsync();
|
||||
foreach (var setting in ShowCultureSettingsAsync())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user