From 3d41662b26aa207dd2db2c61efa36671c844d0a7 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Wed, 9 Oct 2019 08:09:26 +0200 Subject: [PATCH] add events to settingsmanager --- Pilz.Configuration/SettingsManager.vb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Pilz.Configuration/SettingsManager.vb b/Pilz.Configuration/SettingsManager.vb index 6649651..7639ab7 100644 --- a/Pilz.Configuration/SettingsManager.vb +++ b/Pilz.Configuration/SettingsManager.vb @@ -5,6 +5,10 @@ Imports Newtonsoft.Json.Linq Public NotInheritable Class SettingsManager(Of T As SettingsBase) Implements ISettingsManager + Public Event AutoSavingSettings As EventHandler + Public Event SavingSettings As EventHandler + Public Event SavedSettings As EventHandler + Private defaultInstance As T = Nothing Private enableAutoSave As Boolean = False Private addedHandler As Boolean = False @@ -60,6 +64,7 @@ Public NotInheritable Class SettingsManager(Of T As SettingsBase) End Sub Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs) + RaiseEvent AutoSavingSettings(Me, New EventArgs) Save() End Sub @@ -101,10 +106,14 @@ Public NotInheritable Class SettingsManager(Of T As SettingsBase) End Sub Private Sub SavePrivate() + RaiseEvent SavingSettings(Me, New EventArgs) + Dim obj As JObject = JObject.FromObject(defaultInstance) If obj IsNot Nothing Then File.WriteAllText(ConfigFilePath, obj.ToString) End If + + RaiseEvent SavedSettings(Me, New EventArgs) End Sub -End Class \ No newline at end of file +End Class