1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2025-02-16 16:34:28 +01:00
msfs-popout-panel-manager/Shared/DataStore.cs

54 lines
1.5 KiB
C#
Raw Normal View History

2022-01-18 15:58:11 +01:00
using System.Linq;
using System.ComponentModel;
namespace MSFSPopoutPanelManager.Shared
{
public class DataStore : INotifyPropertyChanged
{
private int _activeProfileId;
public event PropertyChangedEventHandler PropertyChanged;
public DataStore()
{
_activeProfileId = -1;
ActiveUserProfile = null;
ActiveProfilePanelCoordinates = new BindingList<PanelSourceCoordinate>();
PanelConfigs = new BindingList<PanelConfig>();
}
public BindingList<UserProfileData> UserProfiles { get; set; }
public BindingList<PanelSourceCoordinate> ActiveProfilePanelCoordinates { get; set; }
public BindingList<PanelConfig> PanelConfigs { get; set; }
public UserProfileData ActiveUserProfile { get; set; }
public int ActiveUserProfileId
{
get
{
return _activeProfileId;
}
set
{
_activeProfileId = value;
if(value == -1)
{
ActiveUserProfile = null;
ActiveProfilePanelCoordinates.Clear();
}
else
{
ActiveUserProfile = UserProfiles.ToList().Find(x => x.ProfileId == value);
ActiveProfilePanelCoordinates.Clear();
ActiveUserProfile.PanelSourceCoordinates.ForEach(c => ActiveProfilePanelCoordinates.Add(c));
}
}
}
}
}