mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-21 13:20:11 +00:00
54 lines
1.9 KiB
C#
54 lines
1.9 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;
|
|
}
|
|
};
|
|
|
|
ApplicationSetting.DynamicLodSetting.TlodConfigs.CollectionChanged += (_, e) =>
|
|
{
|
|
if (e.Action == NotifyCollectionChangedAction.Reset)
|
|
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
|
|
};
|
|
|
|
ApplicationSetting.DynamicLodSetting.OlodConfigs.CollectionChanged += (_, _) =>
|
|
{
|
|
AppSettingDataManager.WriteAppSetting(ApplicationSetting);
|
|
};
|
|
}
|
|
}
|
|
}
|