diff --git a/I18N Commander/DataModel/Database/SettingNames.cs b/I18N Commander/DataModel/Database/SettingNames.cs index 040b428..75d5dfb 100644 --- a/I18N Commander/DataModel/Database/SettingNames.cs +++ b/I18N Commander/DataModel/Database/SettingNames.cs @@ -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"; } \ No newline at end of file diff --git a/I18N Commander/Processor/AppSettings.cs b/I18N Commander/Processor/AppSettings.cs index 401be31..67d1135 100644 --- a/I18N Commander/Processor/AppSettings.cs +++ b/I18N Commander/Processor/AppSettings.cs @@ -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 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 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 diff --git a/I18N Commander/Processor/Generators/DotnetWinForms.cs b/I18N Commander/Processor/Generators/DotnetWinForms.cs new file mode 100644 index 0000000..a5ae782 --- /dev/null +++ b/I18N Commander/Processor/Generators/DotnetWinForms.cs @@ -0,0 +1,14 @@ +namespace Processor.Generators; + +public class DotnetWinForms : IGenerator +{ + #region Implementation of IGenerator + + /// + public async Task> GenerateAsync() + { + return new ProcessorResult(1); + } + + #endregion +} \ No newline at end of file diff --git a/I18N Commander/Processor/Version.cs b/I18N Commander/Processor/Version.cs index ff8a151..c258519 100644 --- a/I18N Commander/Processor/Version.cs +++ b/I18N Commander/Processor/Version.cs @@ -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}"; } \ No newline at end of file diff --git a/I18N Commander/UI WinForms/Components/Setting.cs b/I18N Commander/UI WinForms/Components/Setting.cs index 504157f..790bb2c 100644 --- a/I18N Commander/UI WinForms/Components/Setting.cs +++ b/I18N Commander/UI WinForms/Components/Setting.cs @@ -441,7 +441,7 @@ public sealed partial class Setting : UserControl var currentSetting = await AppSettings.GetGeneratorDotnetEnabled(); var settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.icons8_c_sharp_logo_svg, SettingName: () => "Generator: .NET", ChangeNeedsRestart: false, 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 settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.icons8_c_sharp_logo_svg, SettingName: () => "Generator: .NET Destination Path", ChangeNeedsRestart: false, 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 settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.icons8_c_sharp_logo_svg, SettingName: () => "Generator: .NET Namespace", ChangeNeedsRestart: false, 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 // continuous and can change when the user adds or removes a culture! var settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.icons8_c_sharp_logo_svg, SettingName: () => "Generator: .NET Default Culture", ChangeNeedsRestart: false, 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 settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.godot_icon, SettingName: () => "Generator: Godot", ChangeNeedsRestart: false, 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 settingData = new SettingUIData( - Icon: Icons.icons8_code_512, + Icon: Icons.godot_icon, SettingName: () => "Generator: Godot Destination Path", ChangeNeedsRestart: false, 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); } + private static async Task 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 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 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(); diff --git a/I18N Commander/UI WinForms/Resources/Icons.Designer.cs b/I18N Commander/UI WinForms/Resources/Icons.Designer.cs index 9425012..7d02295 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.Designer.cs +++ b/I18N Commander/UI WinForms/Resources/Icons.Designer.cs @@ -70,6 +70,16 @@ namespace UI_WinForms.Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap godot_icon { + get { + object obj = ResourceManager.GetObject("godot_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -120,6 +130,16 @@ namespace UI_WinForms.Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + 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)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -379,5 +399,15 @@ namespace UI_WinForms.Resources { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_user_interface_512 { + get { + object obj = ResourceManager.GetObject("icons8_user_interface_512", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/I18N Commander/UI WinForms/Resources/Icons.resx b/I18N Commander/UI WinForms/Resources/Icons.resx index 5e58ae2..7c1ae01 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.resx +++ b/I18N Commander/UI WinForms/Resources/Icons.resx @@ -121,6 +121,9 @@ deepl_logo_icon_170284.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + godot-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + icons8-add-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -151,6 +154,9 @@ icons8-collectibles-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + icons8-c-sharp-logo.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + icons8-delete-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -214,4 +220,7 @@ icons8-trigger(1).svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + icons8-user-interface-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/I18N Commander/UI WinForms/Resources/godot-icon.png b/I18N Commander/UI WinForms/Resources/godot-icon.png new file mode 100644 index 0000000..5439e21 Binary files /dev/null and b/I18N Commander/UI WinForms/Resources/godot-icon.png differ diff --git a/I18N Commander/UI WinForms/Resources/icons8-c-sharp-logo.svg.png b/I18N Commander/UI WinForms/Resources/icons8-c-sharp-logo.svg.png new file mode 100644 index 0000000..8d48630 Binary files /dev/null and b/I18N Commander/UI WinForms/Resources/icons8-c-sharp-logo.svg.png differ diff --git a/I18N Commander/UI WinForms/Resources/icons8-user-interface-512.png b/I18N Commander/UI WinForms/Resources/icons8-user-interface-512.png new file mode 100644 index 0000000..ed78e8b Binary files /dev/null and b/I18N Commander/UI WinForms/Resources/icons8-user-interface-512.png differ