Added specific settings for WinForms generator
This commit is contained in:
parent
e9b4fa1484
commit
52dcea834b
@ -18,4 +18,6 @@ public static class SettingNames
|
||||
public static readonly string AUTO_EXPORT_DESTINATION_PATH = "Auto-Export Destination Path";
|
||||
public static readonly string AUTO_EXPORT_FILENAME = "Auto-Export Filename";
|
||||
public static readonly string AUTO_EXPORT_SENSITIVE_DATA = "Auto-Export Sensitive Data";
|
||||
public static readonly string GENERATOR_DOTNET_WIN_FORMS_ENABLED = "Generator .NET WinForms Enabled";
|
||||
public static readonly string GENERATOR_DOTNET_WIN_FORMS_ROOT_PATH = "Generator .NET WinForms Root Path";
|
||||
}
|
@ -423,6 +423,22 @@ public static class AppSettings
|
||||
|
||||
public static async Task SetGeneratorGodotDestinationPath(string path) => await AppSettings.SetSetting(SettingNames.GENERATOR_GODOT_DESTINATION_PATH, path);
|
||||
|
||||
#endregion
|
||||
|
||||
#region .NET WinForms Generator Enabled/Disabled
|
||||
|
||||
public static async Task<bool> GetGeneratorDotnetWinFormsEnabled() => await AppSettings.GetSetting(SettingNames.GENERATOR_DOTNET_WIN_FORMS_ENABLED, false);
|
||||
|
||||
public static async Task SetGeneratorDotnetWinFormsEnabled(bool enabled) => await AppSettings.SetSetting(SettingNames.GENERATOR_DOTNET_WIN_FORMS_ENABLED, enabled);
|
||||
|
||||
#endregion
|
||||
|
||||
#region .NET WinForms Generator Root Path
|
||||
|
||||
public static async Task<string> GetGeneratorDotnetWinFormsRootPath() => await AppSettings.GetSetting(SettingNames.GENERATOR_DOTNET_WIN_FORMS_ROOT_PATH, string.Empty);
|
||||
|
||||
public static async Task SetGeneratorDotnetWinFormsRootPath(string path) => await AppSettings.SetSetting(SettingNames.GENERATOR_DOTNET_WIN_FORMS_ROOT_PATH, path);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
14
I18N Commander/Processor/Generators/DotnetWinForms.cs
Normal file
14
I18N Commander/Processor/Generators/DotnetWinForms.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Processor.Generators;
|
||||
|
||||
public class DotnetWinForms : IGenerator
|
||||
{
|
||||
#region Implementation of IGenerator
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ProcessorResult<long>> GenerateAsync()
|
||||
{
|
||||
return new ProcessorResult<long>(1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
|
||||
public static class Version
|
||||
{
|
||||
public static string Text => $"v0.9.7 (2023-02-16), .NET {Environment.Version}";
|
||||
public static string Text => $"v0.10.1 (2023-02-17), .NET {Environment.Version}";
|
||||
}
|
@ -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();
|
||||
|
@ -399,5 +399,15 @@ namespace UI_WinForms.Resources {
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_user_interface_512 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8_user_interface_512", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,4 +220,7 @@
|
||||
<data name="icons8_trigger_1__svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons8-trigger(1).svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8_user_interface_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons8-user-interface-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue
Block a user