Changed DeepL button appearance based on wherever a translation is the main culture

This commit is contained in:
Thorsten Sommer 2022-09-20 20:38:12 +02:00
parent b6493da831
commit 7c5ace5b87
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
6 changed files with 31 additions and 8 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);
}

View File

@ -319,5 +319,15 @@ namespace UI_WinForms.Resources {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_trigger_1__svg {
get {
object obj = ResourceManager.GetObject("icons8_trigger_1__svg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -196,4 +196,7 @@
<data name="icons8_trash_can_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-trash-can-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<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>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB