2022-07-12 18:50:03 +00:00
|
|
|
|
using DataModel.Database;
|
|
|
|
|
|
|
|
|
|
namespace UI_WinForms;
|
|
|
|
|
|
|
|
|
|
internal static class AppEvents
|
|
|
|
|
{
|
2023-01-22 18:35:57 +00:00
|
|
|
|
static AppEvents()
|
|
|
|
|
{
|
|
|
|
|
AppEvents.AddSomethingHandlers();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 11:26:31 +00:00
|
|
|
|
internal static void ResetAllSubscriptions()
|
|
|
|
|
{
|
|
|
|
|
WhenSettingsChanged = null;
|
|
|
|
|
WhenSectionChanged = null;
|
|
|
|
|
WhenTextElementChanged = null;
|
|
|
|
|
WhenTranslationChanged = null;
|
2023-01-22 18:35:57 +00:00
|
|
|
|
|
|
|
|
|
AppEvents.AddSomethingHandlers();
|
2022-11-01 11:26:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-22 13:20:40 +00:00
|
|
|
|
#region Event: Settings changed
|
2022-10-29 18:16:44 +00:00
|
|
|
|
|
2022-10-30 15:23:20 +00:00
|
|
|
|
internal static event EventHandler? WhenSettingsChanged;
|
2022-10-29 18:16:44 +00:00
|
|
|
|
|
|
|
|
|
internal static void SettingsChanged() => WhenSettingsChanged?.Invoke(null, EventArgs.Empty);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-07-23 19:34:51 +00:00
|
|
|
|
#region Event: Section was changed
|
|
|
|
|
|
2022-07-20 18:51:12 +00:00
|
|
|
|
// Section changed event which can be subscribed:
|
2022-10-30 15:23:20 +00:00
|
|
|
|
internal static event EventHandler<Section>? WhenSectionChanged;
|
2022-07-12 18:50:03 +00:00
|
|
|
|
|
2022-07-20 18:51:12 +00:00
|
|
|
|
// Method to raise the section changed event:
|
2022-07-23 19:34:51 +00:00
|
|
|
|
internal static void SectionChanged(Section section) => WhenSectionChanged?.Invoke(null, section);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Event: Text element was changed
|
|
|
|
|
|
2022-07-20 18:51:12 +00:00
|
|
|
|
// Text element changed event which can be subscribed:
|
2022-10-30 15:23:20 +00:00
|
|
|
|
internal static event EventHandler<TextElement?>? WhenTextElementChanged;
|
2022-07-20 18:51:12 +00:00
|
|
|
|
|
|
|
|
|
// Method to raise the text element changed event:
|
2022-09-21 16:21:52 +00:00
|
|
|
|
internal static void TextElementChanged(TextElement? textElement) => WhenTextElementChanged?.Invoke(null, textElement);
|
2022-07-23 19:34:51 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2022-09-26 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
#region Translation was changed
|
|
|
|
|
|
|
|
|
|
// Translation changed event which can be subscribed:
|
2022-10-30 15:23:20 +00:00
|
|
|
|
internal static event EventHandler<Translation?>? WhenTranslationChanged;
|
2022-09-26 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
// Method to raise the translation changed event:
|
|
|
|
|
internal static void TranslationChanged(Translation? translation) => WhenTranslationChanged?.Invoke(null, translation);
|
|
|
|
|
|
|
|
|
|
#endregion
|
2023-01-22 18:35:57 +00:00
|
|
|
|
|
|
|
|
|
#region Event: Something was changed
|
|
|
|
|
|
|
|
|
|
internal static event EventHandler? WhenSomethingChanged;
|
|
|
|
|
|
|
|
|
|
internal static void SomethingChanged() => WhenSomethingChanged?.Invoke(null, EventArgs.Empty);
|
|
|
|
|
|
|
|
|
|
private static void AddSomethingHandlers()
|
|
|
|
|
{
|
|
|
|
|
// Raise the something event when any of the other change-events are raised:
|
|
|
|
|
WhenSectionChanged += (sender, args) => WhenSomethingChanged?.Invoke(sender, EventArgs.Empty);
|
|
|
|
|
WhenTextElementChanged += (sender, args) => WhenSomethingChanged?.Invoke(sender, EventArgs.Empty);
|
|
|
|
|
WhenTranslationChanged += (sender, args) => WhenSomethingChanged?.Invoke(sender, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2022-07-12 18:50:03 +00:00
|
|
|
|
}
|