Added specific settings for WinForms generator

This commit is contained in:
tsommer committed 2023-02-17 20:58:22 +01:00
1 parent e9b4fa1484
commit 52dcea834b
8 files changed
+136 -2

No files matched your search

@@ -686,6 +686,93 @@ public sealed partial class Setting : UserControl
return new Setting(settingData);
}
private static async Task<Setting> ShowGeneratorDotnetWinFormsEnabledSettingAsync()
{
var currentSetting = await AppSettings.GetGeneratorDotnetWinFormsEnabled();
var settingData = new SettingUIData(
Icon: Icons.icons8_user_interface_512,
SettingName: () => "Generator: .NET WinForms",
ChangeNeedsRestart: false,
SettingExplanation: () => "When enabled, .NET WinForms translation files are generated. Requires a .NET WinForms project.",
SettingExplanationLink: () => (string.Empty, string.Empty),
SetupDataControl: (changeTrigger) =>
{
// Set up an checkbox:
var checkbox = new CheckBox();
checkbox.Checked = currentSetting;
checkbox.CheckedChanged += async (sender, args) => await AppSettings.SetGeneratorDotnetWinFormsEnabled(checkbox.Checked);
checkbox.CheckedChanged += (sender, args) => changeTrigger();
checkbox.Text = "Enable .NET WinForms Generator";
// Apply the desired layout:
checkbox.Dock = DockStyle.Fill;
return checkbox;
}
);
return new Setting(settingData);
}
private static async Task<Setting> ShowGeneratorDotnetWinFormsRootPathSettingAsync()
{
var currentSetting = await AppSettings.GetGeneratorDotnetWinFormsRootPath();
var settingData = new SettingUIData(
Icon: Icons.icons8_user_interface_512,
SettingName: () => "Generator: .NET WinForms Root Path",
ChangeNeedsRestart: false,
SettingExplanation: () => "The root path for the .NET WinForms project. You might use environment variables like %USERPROFILE%. Starting from this path, the generator will search for *.Designer.cs files to find used translation keys.",
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 += async (sender, args) => await AppSettings.SetGeneratorDotnetWinFormsRootPath(textbox.Text);
textbox.TextChanged += (sender, args) => changeTrigger();
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 root path for the .NET WinForms project.";
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);
}
private static async Task<Setting> ShowGeneratorAutoExportEnabledSettingAsync()
{
var currentSetting = await AppSettings.GetAutoExportEnabled();
@@ -837,7 +924,9 @@ public sealed partial class Setting : UserControl
yield return ShowGeneratorAutoExportDestinationPathSettingAsync();
yield return ShowGeneratorAutoExportExportSensitiveDataSettingAsync();
yield return ShowGeneratorAutoExportEnabledSettingAsync();
yield return ShowGeneratorDotnetWinFormsRootPathSettingAsync();
yield return ShowGeneratorDotnetWinFormsEnabledSettingAsync();
yield return ShowGeneratorGodotDestinationPathSettingAsync();
yield return ShowGeneratorGodotEnabledSettingAsync();
yield return ShowGeneratorDotnetDefaultCultureSettingAsync();