1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-28 08:40:09 +00:00
msfs-popout-panel-manager/DomainModel/Profile/RefocusOnDisplay.cs

46 lines
1.8 KiB
C#
Raw Normal View History

2023-07-23 05:13:23 +00:00
using MSFSPopoutPanelManager.Shared;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace MSFSPopoutPanelManager.DomainModel.Profile
{
public class RefocusOnDisplay : ObservableObject
{
public RefocusOnDisplay()
{
Monitors = new ObservableCollection<MonitorInfo>();
Monitors.CollectionChanged += (sender, e) =>
{
switch (e.Action)
{
case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
2024-02-28 02:44:21 +00:00
if (e.NewItems?[0] == null)
2023-07-23 05:13:23 +00:00
return;
2024-02-28 02:44:21 +00:00
((MonitorInfo)e.NewItems[0]).PropertyChanged += (innerSender, innerArg) =>
2023-07-23 05:13:23 +00:00
{
2024-02-28 02:44:21 +00:00
if (innerArg is PropertyChangedExtendedEventArgs { DisableSave: false })
base.OnPropertyChanged(innerSender, innerArg);
2023-07-23 05:13:23 +00:00
};
base.OnPropertyChanged(sender, new PropertyChangedEventArgs("Monitors"));
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
base.OnPropertyChanged(sender, new PropertyChangedEventArgs("Monitors"));
break;
}
};
InitializeChildPropertyChangeBinding();
}
2024-02-28 02:44:21 +00:00
public bool IsEnabled { get; set; } = false;
2023-07-23 05:13:23 +00:00
public ObservableCollection<MonitorInfo> Monitors { get; set; }
}
}