1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-29 01:00:13 +00:00
msfs-popout-panel-manager/Orchestration/AppSettingData.cs
2023-07-12 18:47:24 -04:00

41 lines
1.4 KiB
C#

using MSFSPopoutPanelManager.DomainModel.Setting;
using MSFSPopoutPanelManager.Shared;
using System;
namespace MSFSPopoutPanelManager.Orchestration
{
public class AppSettingData : ObservableObject
{
public event EventHandler<bool> AlwaysOnTopChanged;
public event EventHandler<bool> EnablePanelResetWhenLockedChanged;
public ApplicationSetting ApplicationSetting { get; private set; }
public void ReadSettings()
{
ApplicationSetting = AppSettingDataManager.ReadAppSetting();
if (ApplicationSetting == null)
{
ApplicationSetting = new ApplicationSetting();
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
}
// Autosave data
ApplicationSetting.PropertyChanged += (sender, e) =>
{
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
switch (e.PropertyName)
{
case "AlwaysOnTop":
AlwaysOnTopChanged?.Invoke(this, ApplicationSetting.GeneralSetting.AlwaysOnTop);
break;
case "EnablePanelResetWhenLocked":
EnablePanelResetWhenLockedChanged?.Invoke(this, ApplicationSetting.PopOutSetting.EnablePanelResetWhenLocked);
break;
}
};
}
}
}