Implemented .NET generator settings
This commit is contained in:
6 files changed
+252
No files matched your search
@@ -434,8 +434,97 @@ public sealed partial class Setting : UserControl
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorDotnetEnabledSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetGeneratorDotnetEnabled();
|
||||
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_code_512,
|
||||
SettingName: () => "Generator: .NET",
|
||||
ChangeNeedsRestart: false,
|
||||
SettingExplanation: () => "When enabled, .NET translation files are generated. Requires a .NET 6 or newer project.",
|
||||
SettingExplanationLink: () => (string.Empty, string.Empty),
|
||||
SetupDataControl: (changeTrigger) =>
|
||||
{
|
||||
// Set up an checkbox:
|
||||
var checkbox = new CheckBox();
|
||||
checkbox.Checked = currentSetting;
|
||||
checkbox.CheckedChanged += (sender, args) => changeTrigger();
|
||||
checkbox.CheckedChanged += async (sender, args) => await AppSettings.SetGeneratorDotnetEnabled(checkbox.Checked);
|
||||
checkbox.Text = "Enable .NET Generator";
|
||||
|
||||
// Apply the desired layout:
|
||||
checkbox.Dock = DockStyle.Fill;
|
||||
return checkbox;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowGeneratorDotnetDestinationPathSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetGeneratorDotnetDestinationPath();
|
||||
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_code_512,
|
||||
SettingName: () => "Generator: .NET Destination Path",
|
||||
ChangeNeedsRestart: false,
|
||||
SettingExplanation: () => "The destination path for the .NET translation files. You might use environment variables like %USERPROFILE%.",
|
||||
SettingExplanationLink: () => (string.Empty, string.Empty),
|
||||
SetupDataControl: (changeTrigger) =>
|
||||
{
|
||||
// Set up a horizontal layout:
|
||||
var layout = new TableLayoutPanel();
|
||||
layout.ColumnCount = 2;
|
||||
layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
layout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 66F));
|
||||
layout.RowCount = 1;
|
||||
layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
layout.Dock = DockStyle.Fill;
|
||||
|
||||
// Set up a textbox:
|
||||
var textbox = new TextBox();
|
||||
textbox.Text = currentSetting;
|
||||
textbox.TextChanged += (sender, args) => changeTrigger();
|
||||
textbox.TextChanged += async (sender, args) => await AppSettings.SetGeneratorDotnetDestinationPath(textbox.Text);
|
||||
textbox.Dock = DockStyle.Fill;
|
||||
textbox.Margin = new Padding(0, 13, 0, 13);
|
||||
layout.Controls.Add(textbox, 0, 0);
|
||||
|
||||
// Set up a button:
|
||||
var button = new Button();
|
||||
button.Text = string.Empty;
|
||||
button.Image = Icons.icons8_folder_tree_512;
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.BorderSize = 0;
|
||||
button.BackColor = Color.Empty;
|
||||
button.UseVisualStyleBackColor = true;
|
||||
button.Size = new Size(60, 60);
|
||||
button.Click += (sender, args) =>
|
||||
{
|
||||
var dialog = new FolderBrowserDialog();
|
||||
dialog.SelectedPath = textbox.Text;
|
||||
dialog.InitialDirectory = textbox.Text;
|
||||
dialog.Description = "Select the destination path for the .NET translation files.";
|
||||
dialog.ShowNewFolderButton = true;
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
textbox.Text = dialog.SelectedPath;
|
||||
};
|
||||
button.Dock = DockStyle.Fill;
|
||||
layout.Controls.Add(button, 1, 0);
|
||||
|
||||
return layout;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData);
|
||||
}
|
||||
|
||||
public static IEnumerable<Task<Setting>> GetAllSettings()
|
||||
{
|
||||
yield return ShowGeneratorDotnetDestinationPathSettingAsync();
|
||||
yield return ShowGeneratorDotnetEnabledSettingAsync();
|
||||
yield return ShowGeneratorModeSettingAsync();
|
||||
yield return ShowDeepLSourceCultureSettingAsync();
|
||||
foreach (var setting in ShowCultureSettingsAsync())
|
||||
|
||||
Reference in new issue
Block a user