Shows the DeepL button depending on the DeepL configuration state
This commit is contained in:
parent
9ae1111f9e
commit
b6493da831
@ -1,4 +1,5 @@
|
|||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using DataModel.Database;
|
||||||
using Processor;
|
using Processor;
|
||||||
using Timer = System.Timers.Timer;
|
using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
@ -31,6 +32,12 @@ public sealed partial class Translation : UserControl
|
|||||||
AutoReset = false, // runs only once
|
AutoReset = false, // runs only once
|
||||||
};
|
};
|
||||||
this.saveTimer.Elapsed += this.SaveChanges;
|
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)
|
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);
|
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;
|
this.isLoading = true;
|
||||||
|
|
||||||
@ -47,6 +54,7 @@ public sealed partial class Translation : UserControl
|
|||||||
this.textBox.Text = translation.Text;
|
this.textBox.Text = translation.Text;
|
||||||
this.textBox.Multiline = translation.TextElement.IsMultiLine;
|
this.textBox.Multiline = translation.TextElement.IsMultiLine;
|
||||||
this.Height = translation.TextElement.IsMultiLine ? 280 : 106;
|
this.Height = translation.TextElement.IsMultiLine ? 280 : 106;
|
||||||
|
this.buttonDeepL.Visible = await AppSettings.GetDeepLMode() != SettingDeepLMode.DISABLED;
|
||||||
|
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public partial class Translations : UserControl
|
|||||||
var allTranslations = await TranslationProcessor.GetTranslations(textElement);
|
var allTranslations = await TranslationProcessor.GetTranslations(textElement);
|
||||||
foreach (var translation in allTranslations)
|
foreach (var translation in allTranslations)
|
||||||
if (this.translationComponents.ContainsKey(translation.Culture))
|
if (this.translationComponents.ContainsKey(translation.Culture))
|
||||||
this.translationComponents[translation.Culture].Configure(translation);
|
await this.translationComponents[translation.Culture].Configure(translation);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user