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)
|
||||
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
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user