Shows the DeepL button depending on the DeepL configuration state

This commit is contained in:
Thorsten Sommer 2022-09-20 20:18:26 +02:00
parent 9ae1111f9e
commit b6493da831
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System.Timers;
using DataModel.Database;
using Processor;
using Timer = System.Timers.Timer;
@ -31,6 +32,12 @@ public sealed partial class Translation : UserControl
AutoReset = false, // runs only once
};
this.saveTimer.Elapsed += this.SaveChanges;
this.Load += async (sender, args) => await this.LateSetup();
}
private async Task LateSetup()
{
this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED;
}
private async void SaveChanges(object? sender, ElapsedEventArgs e)
@ -39,7 +46,7 @@ public sealed partial class Translation : UserControl
await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text);
}
public void Configure(DataModel.Database.Translation translation)
public async Task Configure(DataModel.Database.Translation translation)
{
this.isLoading = true;
@ -47,6 +54,7 @@ public sealed partial class Translation : UserControl
this.textBox.Text = translation.Text;
this.textBox.Multiline = translation.TextElement.IsMultiLine;
this.Height = translation.TextElement.IsMultiLine ? 280 : 106;
this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED;
this.isLoading = false;
}

View File

@ -15,7 +15,7 @@ public partial class Translations : UserControl
var allTranslations = await TranslationProcessor.GetTranslations(textElement);
foreach (var translation in allTranslations)
if (this.translationComponents.ContainsKey(translation.Culture))
this.translationComponents[translation.Culture].Configure(translation);
await this.translationComponents[translation.Culture].Configure(translation);
};
}