Draft: Resolve "Add code generator for win form projects" #92
@ -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_DESTINATION_PATH = "Auto-Export Destination Path";
|
||||||
public static readonly string AUTO_EXPORT_FILENAME = "Auto-Export Filename";
|
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 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";
|
||||||
}
|
}
|
@ -425,6 +425,22 @@ public static class AppSettings
|
|||||||
|
|
||||||
#endregion
|
#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
|
#endregion
|
||||||
|
|
||||||
#region Auto-Export Settings
|
#region Auto-Export Settings
|
||||||
|
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 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}";
|
||||||
}
|
}
|
@ -441,7 +441,7 @@ public sealed partial class Setting : UserControl
|
|||||||
var currentSetting = await AppSettings.GetGeneratorDotnetEnabled();
|
var currentSetting = await AppSettings.GetGeneratorDotnetEnabled();
|
||||||
|
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.icons8_c_sharp_logo_svg,
|
||||||
SettingName: () => "Generator: .NET",
|
SettingName: () => "Generator: .NET",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "When enabled, .NET translation files are generated. Requires a .NET 7 or newer project.",
|
SettingExplanation: () => "When enabled, .NET translation files are generated. Requires a .NET 7 or newer project.",
|
||||||
@ -469,7 +469,7 @@ public sealed partial class Setting : UserControl
|
|||||||
var currentSetting = await AppSettings.GetGeneratorDotnetDestinationPath();
|
var currentSetting = await AppSettings.GetGeneratorDotnetDestinationPath();
|
||||||
|
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.icons8_c_sharp_logo_svg,
|
||||||
SettingName: () => "Generator: .NET Destination Path",
|
SettingName: () => "Generator: .NET Destination Path",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "The destination path for the .NET translation files. You might use environment variables like %USERPROFILE%.",
|
SettingExplanation: () => "The destination path for the .NET translation files. You might use environment variables like %USERPROFILE%.",
|
||||||
@ -528,7 +528,7 @@ public sealed partial class Setting : UserControl
|
|||||||
var currentSetting = await AppSettings.GetGeneratorDotnetNamespace();
|
var currentSetting = await AppSettings.GetGeneratorDotnetNamespace();
|
||||||
|
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.icons8_c_sharp_logo_svg,
|
||||||
SettingName: () => "Generator: .NET Namespace",
|
SettingName: () => "Generator: .NET Namespace",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "The namespace for the .NET I18N files.",
|
SettingExplanation: () => "The namespace for the .NET I18N files.",
|
||||||
@ -560,7 +560,7 @@ public sealed partial class Setting : UserControl
|
|||||||
// Attention: We have to store the culture's index, because the index is not
|
// Attention: We have to store the culture's index, because the index is not
|
||||||
// continuous and can change when the user adds or removes a culture!
|
// continuous and can change when the user adds or removes a culture!
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.icons8_c_sharp_logo_svg,
|
||||||
SettingName: () => "Generator: .NET Default Culture",
|
SettingName: () => "Generator: .NET Default Culture",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "The default culture for the .NET, which is used when no culture is specified or available.",
|
SettingExplanation: () => "The default culture for the .NET, which is used when no culture is specified or available.",
|
||||||
@ -604,7 +604,7 @@ public sealed partial class Setting : UserControl
|
|||||||
var currentSetting = await AppSettings.GetGeneratorGodotEnabled();
|
var currentSetting = await AppSettings.GetGeneratorGodotEnabled();
|
||||||
|
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.godot_icon,
|
||||||
SettingName: () => "Generator: Godot",
|
SettingName: () => "Generator: Godot",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "When enabled, Godot translation files are generated. Requires a Godot 3.5 or newer project.",
|
SettingExplanation: () => "When enabled, Godot translation files are generated. Requires a Godot 3.5 or newer project.",
|
||||||
@ -632,7 +632,7 @@ public sealed partial class Setting : UserControl
|
|||||||
var currentSetting = await AppSettings.GetGeneratorGodotDestinationPath();
|
var currentSetting = await AppSettings.GetGeneratorGodotDestinationPath();
|
||||||
|
|
||||||
var settingData = new SettingUIData(
|
var settingData = new SettingUIData(
|
||||||
Icon: Icons.icons8_code_512,
|
Icon: Icons.godot_icon,
|
||||||
SettingName: () => "Generator: Godot Destination Path",
|
SettingName: () => "Generator: Godot Destination Path",
|
||||||
ChangeNeedsRestart: false,
|
ChangeNeedsRestart: false,
|
||||||
SettingExplanation: () => "The destination path for the Godot translation files. You might use environment variables like %USERPROFILE%.",
|
SettingExplanation: () => "The destination path for the Godot translation files. You might use environment variables like %USERPROFILE%.",
|
||||||
@ -686,6 +686,93 @@ public sealed partial class Setting : UserControl
|
|||||||
return new Setting(settingData);
|
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()
|
private static async Task<Setting> ShowGeneratorAutoExportEnabledSettingAsync()
|
||||||
{
|
{
|
||||||
var currentSetting = await AppSettings.GetAutoExportEnabled();
|
var currentSetting = await AppSettings.GetAutoExportEnabled();
|
||||||
@ -838,6 +925,8 @@ public sealed partial class Setting : UserControl
|
|||||||
yield return ShowGeneratorAutoExportExportSensitiveDataSettingAsync();
|
yield return ShowGeneratorAutoExportExportSensitiveDataSettingAsync();
|
||||||
yield return ShowGeneratorAutoExportEnabledSettingAsync();
|
yield return ShowGeneratorAutoExportEnabledSettingAsync();
|
||||||
|
|
||||||
|
yield return ShowGeneratorDotnetWinFormsRootPathSettingAsync();
|
||||||
|
yield return ShowGeneratorDotnetWinFormsEnabledSettingAsync();
|
||||||
yield return ShowGeneratorGodotDestinationPathSettingAsync();
|
yield return ShowGeneratorGodotDestinationPathSettingAsync();
|
||||||
yield return ShowGeneratorGodotEnabledSettingAsync();
|
yield return ShowGeneratorGodotEnabledSettingAsync();
|
||||||
yield return ShowGeneratorDotnetDefaultCultureSettingAsync();
|
yield return ShowGeneratorDotnetDefaultCultureSettingAsync();
|
||||||
|
@ -70,6 +70,16 @@ namespace UI_WinForms.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap godot_icon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("godot_icon", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -120,6 +130,16 @@ namespace UI_WinForms.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap icons8_c_sharp_logo_svg {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("icons8_c_sharp_logo_svg", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -379,5 +399,15 @@ namespace UI_WinForms.Resources {
|
|||||||
return ((System.Drawing.Bitmap)(obj));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,9 @@
|
|||||||
<data name="deepl_logo_icon_170284" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="deepl_logo_icon_170284" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>deepl_logo_icon_170284.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>deepl_logo_icon_170284.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="godot_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>godot-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="icons8_add_folder_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8_add_folder_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons8-add-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons8-add-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -151,6 +154,9 @@
|
|||||||
<data name="icons8_collectibles_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8_collectibles_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons8-collectibles-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons8-collectibles-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="icons8_c_sharp_logo_svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>icons8-c-sharp-logo.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="icons8_delete_folder_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8_delete_folder_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons8-delete-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons8-delete-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -214,4 +220,7 @@
|
|||||||
<data name="icons8_trigger_1__svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<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>
|
<value>icons8-trigger(1).svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</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>
|
</root>
|
BIN
I18N Commander/UI WinForms/Resources/godot-icon.png
Normal file
BIN
I18N Commander/UI WinForms/Resources/godot-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
I18N Commander/UI WinForms/Resources/icons8-c-sharp-logo.svg.png
Normal file
BIN
I18N Commander/UI WinForms/Resources/icons8-c-sharp-logo.svg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue
Block a user