Added an event for a changed translation

This commit is contained in:
Thorsten Sommer 2022-09-26 19:25:51 +02:00
parent 1071439348
commit 6101f49f44
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 15 additions and 2 deletions

View File

@ -23,4 +23,14 @@ internal static class AppEvents
internal static void TextElementChanged(TextElement? textElement) => WhenTextElementChanged?.Invoke(null, textElement);
#endregion
#region Translation was changed
// Translation changed event which can be subscribed:
internal static event EventHandler<Translation?> WhenTranslationChanged;
// Method to raise the translation changed event:
internal static void TranslationChanged(Translation? translation) => WhenTranslationChanged?.Invoke(null, translation);
#endregion
}

View File

@ -124,8 +124,11 @@ public sealed partial class Translation : UserControl
private async void SaveChanges(object? sender, ElapsedEventArgs e)
{
if (this.currentTranslationId > -1)
await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text, this.checkBoxManual.Checked);
{
var storedTranslation = await TranslationProcessor.SaveChangedTranslation(this.currentTranslationId, this.textBox.Text, this.checkBoxManual.Checked);
AppEvents.TranslationChanged(storedTranslation.Result);
}
if(this.ParentForm is UI_WinForms.Main main)
main.RemoveDeferredSaveOperation(this.currentTranslationId);