From 52dcea834b7005e7925ec98307fb82aa340deeaf Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 17 Feb 2023 20:58:22 +0100 Subject: [PATCH] Added specific settings for WinForms generator --- .../DataModel/Database/SettingNames.cs | 2 + I18N Commander/Processor/AppSettings.cs | 16 +++ .../Processor/Generators/DotnetWinForms.cs | 14 +++ I18N Commander/Processor/Version.cs | 2 +- .../UI WinForms/Components/Setting.cs | 91 +++++++++++++++++- .../UI WinForms/Resources/Icons.Designer.cs | 10 ++ .../UI WinForms/Resources/Icons.resx | 3 + .../Resources/icons8-user-interface-512.png | Bin 0 -> 3934 bytes 8 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 I18N Commander/Processor/Generators/DotnetWinForms.cs create mode 100644 I18N Commander/UI WinForms/Resources/icons8-user-interface-512.png 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 133bf45..790bb2c 100644 --- a/I18N Commander/UI WinForms/Components/Setting.cs +++ b/I18N Commander/UI WinForms/Components/Setting.cs @@ -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 366c5b6..7d02295 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.Designer.cs +++ b/I18N Commander/UI WinForms/Resources/Icons.Designer.cs @@ -399,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 1de0062..7c1ae01 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.resx +++ b/I18N Commander/UI WinForms/Resources/Icons.resx @@ -220,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/icons8-user-interface-512.png b/I18N Commander/UI WinForms/Resources/icons8-user-interface-512.png new file mode 100644 index 0000000000000000000000000000000000000000..ed78e8b7304c01fa1b51c633e4f6e8305cfe6653 GIT binary patch literal 3934 zcmai1c|6o>`yP=svS&9~-Y@mmd){--@At=iXP)P}?(4aq`+A;xKHnrq2Rm_5B~cIvB#uE_ zI|JX^>mOl3;E7OreHH`~xK49*W4mDwB8c=L7@kBYkYSu427rS=NOKMYPYfWl!2~ju z7L0<-HZ(!NG!hDO*bu9OWmu8@Xy^zg*(Jikl^78~G$BFE%|wwL1RxMZX5+z}puk`j zf`fu==pumM>(g)uc!RzbIDz;*QCdV1ObLz{Ipn2qOX2eWppOMKI?CbNi48iP%v2ZPr& z@dSD(8wG&?IQY9bn@0Jm9?bf_eV`EVbp);p(}Djtoy?*A1AQI&3!ULdXVY1JbjFVj z{Ar0F@LvLf^8I}X2haFBG8X%P(}RNkv<(*9CJZRV_oDtOr~fR#ay`l*!=1@2dMJ}f zwh1E#vv+J%V!bX1Oc0(*K1dFxvi(pH1H=CT4%0~gJHIXz7`pBRE|>-^t@ks;?I(tU z80*1xe?snm3$2$L;Yj0<1Kq4?LF8Z-p!y?=pP>6cfL8QCI@1L>)?^gq+gd+-Kx|-G zIthUEH`4eCVXUkinRE&*5WrZ@c9vj_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