1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-21 13:20:11 +00:00
msfs-popout-panel-manager/Orchestration/AppSettingData.cs
2024-07-27 20:12:07 -04:00

43 lines
1.5 KiB
C#

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