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

55 lines
1.9 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;
2024-02-28 02:44:21 +00:00
using System.Collections.Specialized;
2022-07-23 19:23:32 +00:00
namespace MSFSPopoutPanelManager.Orchestration
{
public class AppSettingData : ObservableObject
{
2024-02-28 02:44:21 +00:00
public event EventHandler<bool> OnAlwaysOnTopChanged;
public event EventHandler<bool> OnEnablePanelResetWhenLockedChanged;
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
}
2024-02-28 02:44:21 +00:00
// Auto Save data
ApplicationSetting.PropertyChanged += (_, 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":
2024-02-28 02:44:21 +00:00
OnAlwaysOnTopChanged?.Invoke(this, ApplicationSetting.GeneralSetting.AlwaysOnTop);
2023-07-12 22:41:31 +00:00
break;
case "EnablePanelResetWhenLocked":
2024-02-28 02:44:21 +00:00
OnEnablePanelResetWhenLockedChanged?.Invoke(this,
ApplicationSetting.PopOutSetting.EnablePanelResetWhenLocked);
2023-07-12 22:41:31 +00:00
break;
2022-07-23 19:23:32 +00:00
}
};
2024-02-28 02:44:21 +00:00
ApplicationSetting.DynamicLodSetting.TlodConfigs.CollectionChanged += (_, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Reset)
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
};
ApplicationSetting.DynamicLodSetting.OlodConfigs.CollectionChanged += (_, _) =>
{
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
};
2022-07-23 19:23:32 +00:00
}
}
}