1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-25 07:10:10 +00:00
msfs-popout-panel-manager/Orchestration/AppSettingData.cs
2022-07-23 15:23:32 -04:00

53 lines
1.8 KiB
C#

using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.UserDataAgent;
using System;
namespace MSFSPopoutPanelManager.Orchestration
{
public class AppSettingData : ObservableObject
{
public event EventHandler AppSettingUpdated;
public event EventHandler<bool> AlwaysOnTopChanged;
public event EventHandler<bool> AutoPopOutPanelsChanged;
public event EventHandler<bool> TouchPanelIntegrationChanged;
public AppSetting AppSetting { get; private set; }
public void ReadSettings()
{
AppSetting = AppSettingManager.ReadAppSetting();
if (AppSetting == null)
{
AppSetting = new AppSetting();
AppSettingManager.WriteAppSetting(AppSetting);
}
// Autosave data
AppSetting.PropertyChanged += (sender, e) =>
{
var arg = e as PropertyChangedExtendedEventArgs;
if (arg.OldValue != arg.NewValue)
{
AppSettingManager.WriteAppSetting(AppSetting);
switch (arg.PropertyName)
{
case "AlwaysOnTop":
AlwaysOnTopChanged?.Invoke(this, (bool)arg.NewValue);
break;
case "AutoPopOutPanels":
AutoPopOutPanelsChanged?.Invoke(this, (bool)arg.NewValue);
break;
case "EnableTouchPanelIntegration":
TouchPanelIntegrationChanged?.Invoke(this, (bool)arg.NewValue);
break;
}
AppSettingUpdated?.Invoke(this, null);
}
};
}
}
}