From 7c5ace5b87efb6cbcbdab24a2d26168d8a94b16e Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Tue, 20 Sep 2022 20:38:12 +0200 Subject: [PATCH] Changed DeepL button appearance based on wherever a translation is the main culture --- .../Components/Translation.Designer.cs | 2 +- .../UI WinForms/Components/Translation.cs | 22 +++++++++++++----- .../UI WinForms/Components/Translations.cs | 2 +- .../UI WinForms/Resources/Icons.Designer.cs | 10 ++++++++ .../UI WinForms/Resources/Icons.resx | 3 +++ .../Resources/icons8-trigger(1).svg.png | Bin 0 -> 3111 bytes 6 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 I18N Commander/UI WinForms/Resources/icons8-trigger(1).svg.png diff --git a/I18N Commander/UI WinForms/Components/Translation.Designer.cs b/I18N Commander/UI WinForms/Components/Translation.Designer.cs index f5878d2..dc5cb15 100644 --- a/I18N Commander/UI WinForms/Components/Translation.Designer.cs +++ b/I18N Commander/UI WinForms/Components/Translation.Designer.cs @@ -87,7 +87,7 @@ this.buttonDeepL.Name = "buttonDeepL"; this.buttonDeepL.Size = new System.Drawing.Size(60, 60); this.buttonDeepL.TabIndex = 2; - this.toolTip.SetToolTip(this.buttonDeepL, "Auto-generate this text by using DeepL"); + this.toolTip.SetToolTip(this.buttonDeepL, "Auto-generate this text by using DeepL sourced by the source culture."); this.buttonDeepL.UseVisualStyleBackColor = true; // // toolTip diff --git a/I18N Commander/UI WinForms/Components/Translation.cs b/I18N Commander/UI WinForms/Components/Translation.cs index 6bd5590..8536f08 100644 --- a/I18N Commander/UI WinForms/Components/Translation.cs +++ b/I18N Commander/UI WinForms/Components/Translation.cs @@ -1,6 +1,7 @@ using System.Timers; using DataModel.Database; using Processor; +using UI_WinForms.Resources; using Timer = System.Timers.Timer; namespace UI_WinForms.Components; @@ -10,8 +11,9 @@ public sealed partial class Translation : UserControl private readonly string culture = "en-US"; private readonly Timer saveTimer; - private int currentTranslationId = -1; private bool isLoading = false; + private int currentTranslationId = -1; + private bool isDeepLSourceCulture = false; public Translation() { @@ -19,11 +21,11 @@ public sealed partial class Translation : UserControl this.Dock = DockStyle.Top; } - public Translation(string cultureCode) + public Translation(AppSettings.CultureInfo cultureInfo) { this.InitializeComponent(); - this.culture = cultureCode; - this.labelHead.Text = $"Culture: {cultureCode}"; + this.culture = cultureInfo.Code; + this.labelHead.Text = $"Culture: {cultureInfo.Code}"; this.Dock = DockStyle.Top; this.saveTimer = new Timer { @@ -32,12 +34,20 @@ public sealed partial class Translation : UserControl AutoReset = false, // runs only once }; this.saveTimer.Elapsed += this.SaveChanges; - this.Load += async (sender, args) => await this.LateSetup(); + this.Load += async (sender, args) => await this.LateSetup(cultureInfo); } - private async Task LateSetup() + private async Task LateSetup(AppSettings.CultureInfo cultureInfo) { + this.isDeepLSourceCulture = await AppSettings.GetDeepLSourceCultureIndex() == cultureInfo.Index; this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED; + this.buttonDeepL.Image = this.isDeepLSourceCulture ? Icons.icons8_trigger_1__svg : Icons.deepl_logo_icon_170284; + + if (this.isDeepLSourceCulture) + { + this.labelHead.Text = $"Culture: {cultureInfo.Code} (DeepL source culture)"; + this.toolTip.SetToolTip(this.buttonDeepL, "Replaces all other translations by DeepL translations using this culture as source culture.\nWarning: already translated texts will be replaced as well."); + } } private async void SaveChanges(object? sender, ElapsedEventArgs e) diff --git a/I18N Commander/UI WinForms/Components/Translations.cs b/I18N Commander/UI WinForms/Components/Translations.cs index 5d8e7fc..40b2a59 100644 --- a/I18N Commander/UI WinForms/Components/Translations.cs +++ b/I18N Commander/UI WinForms/Components/Translations.cs @@ -46,7 +46,7 @@ public partial class Translations : UserControl await foreach (var cultureInfo in DesiredOrder()) { - var translationComponent = new Translation(cultureInfo.Code); + var translationComponent = new Translation(cultureInfo); this.translationComponents.Add(cultureInfo.Code, translationComponent); this.panelTranslations.Controls.Add(translationComponent); } diff --git a/I18N Commander/UI WinForms/Resources/Icons.Designer.cs b/I18N Commander/UI WinForms/Resources/Icons.Designer.cs index 3110d9e..cedf6c1 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.Designer.cs +++ b/I18N Commander/UI WinForms/Resources/Icons.Designer.cs @@ -319,5 +319,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_trigger_1__svg { + get { + object obj = ResourceManager.GetObject("icons8_trigger_1__svg", 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 2273449..9cfa843 100644 --- a/I18N Commander/UI WinForms/Resources/Icons.resx +++ b/I18N Commander/UI WinForms/Resources/Icons.resx @@ -196,4 +196,7 @@ icons8-trash-can-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + icons8-trigger(1).svg.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-trigger(1).svg.png b/I18N Commander/UI WinForms/Resources/icons8-trigger(1).svg.png new file mode 100644 index 0000000000000000000000000000000000000000..d0e58638b84d1fdf47369c9c5b75484d91b2f30c GIT binary patch literal 3111 zcmai02UwHW8cvu(WQYPOQi%a&q#1;v1i}ncpn(7h$cp3-1jsOdFag>S*;NdpfP+yA zj#?K55yi?-P^u{9R<_olB2=_sD{4{8{R0+jZSQ@a{7KGv-|s!&`Bw4;HP}~2+e8}% zgX#GDQ9_|ltnyi=0lkw z2(<-B{xziQ|_c1ZWw-VF?*22~I4uo2#~qgaiq20TB}= z;imFHl7x(2&?Q0NmD_kUYJnn3A)^^VRFoHA2%sEr4mbkZRU73ZWU)!16rZ=o(29&s z5{U#PJYFmo*VBwClK*OA{Js`!E~O8DZ%nUbE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