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}";
|
||||||
}
|
}
|
@ -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();
|
||||||
|
@ -399,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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,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>
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue
Block a user