add events to settingsmanager
This commit is contained in:
@@ -5,6 +5,10 @@ Imports Newtonsoft.Json.Linq
|
|||||||
Public NotInheritable Class SettingsManager(Of T As SettingsBase)
|
Public NotInheritable Class SettingsManager(Of T As SettingsBase)
|
||||||
Implements ISettingsManager
|
Implements ISettingsManager
|
||||||
|
|
||||||
|
Public Event AutoSavingSettings As EventHandler
|
||||||
|
Public Event SavingSettings As EventHandler
|
||||||
|
Public Event SavedSettings As EventHandler
|
||||||
|
|
||||||
Private defaultInstance As T = Nothing
|
Private defaultInstance As T = Nothing
|
||||||
Private enableAutoSave As Boolean = False
|
Private enableAutoSave As Boolean = False
|
||||||
Private addedHandler As Boolean = False
|
Private addedHandler As Boolean = False
|
||||||
@@ -60,6 +64,7 @@ Public NotInheritable Class SettingsManager(Of T As SettingsBase)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs)
|
Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs)
|
||||||
|
RaiseEvent AutoSavingSettings(Me, New EventArgs)
|
||||||
Save()
|
Save()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -101,10 +106,14 @@ Public NotInheritable Class SettingsManager(Of T As SettingsBase)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub SavePrivate()
|
Private Sub SavePrivate()
|
||||||
|
RaiseEvent SavingSettings(Me, New EventArgs)
|
||||||
|
|
||||||
Dim obj As JObject = JObject.FromObject(defaultInstance)
|
Dim obj As JObject = JObject.FromObject(defaultInstance)
|
||||||
If obj IsNot Nothing Then
|
If obj IsNot Nothing Then
|
||||||
File.WriteAllText(ConfigFilePath, obj.ToString)
|
File.WriteAllText(ConfigFilePath, obj.ToString)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
RaiseEvent SavedSettings(Me, New EventArgs)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Reference in New Issue
Block a user