1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-22 05:40:11 +00:00
msfs-popout-panel-manager/Shared/DataStore.cs
2022-01-20 18:50:12 -05:00

53 lines
1.5 KiB
C#

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));
}
}
}
}
}