1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-24 06:40:09 +00:00
msfs-popout-panel-manager/Orchestration/AppSettingData.cs

42 lines
1.4 KiB
C#
Raw Normal View History

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