76 lines
2.6 KiB
C#
76 lines
2.6 KiB
C#
using DataModel.Database;
|
|
|
|
namespace UI_WinForms;
|
|
|
|
internal static class AppEvents
|
|
{
|
|
static AppEvents()
|
|
{
|
|
AppEvents.AddSomethingHandlers();
|
|
}
|
|
|
|
internal static void ResetAllSubscriptions()
|
|
{
|
|
WhenSettingsChanged = null;
|
|
WhenSectionChanged = null;
|
|
WhenTextElementChanged = null;
|
|
WhenTranslationChanged = null;
|
|
|
|
AppEvents.AddSomethingHandlers();
|
|
}
|
|
|
|
#region Event: Settings changed
|
|
|
|
internal static event EventHandler? WhenSettingsChanged;
|
|
|
|
internal static void SettingsChanged() => WhenSettingsChanged?.Invoke(null, EventArgs.Empty);
|
|
|
|
#endregion
|
|
|
|
#region Event: Section was changed
|
|
|
|
// Section changed event which can be subscribed:
|
|
internal static event EventHandler<Section>? WhenSectionChanged;
|
|
|
|
// Method to raise the section changed event:
|
|
internal static void SectionChanged(Section section) => WhenSectionChanged?.Invoke(null, section);
|
|
|
|
#endregion
|
|
|
|
#region Event: Text element was changed
|
|
|
|
// Text element changed event which can be subscribed:
|
|
internal static event EventHandler<TextElement?>? WhenTextElementChanged;
|
|
|
|
// Method to raise the text element changed event:
|
|
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
|
|
|
|
#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);
|
|
WhenSettingsChanged += (sender, args) => WhenSomethingChanged?.Invoke(sender, EventArgs.Empty);
|
|
}
|
|
|
|
#endregion
|
|
} |