123456789101112131415161718192021222324252627282930313233 |
- namespace DashBoard.ViewModel;
- internal partial class DashBoardMainViewModel : ObservableObject
- {
- public DashBoardMainViewModel(DeviceCollection deviceCollection, IDialogService dialogService)
- {
- this._DeviceCollection = deviceCollection;
- this._DialogService = dialogService;
- deviceCollection.DeviceList.CollectionChanged += DeviceList_CollectionChanged;
- this.DeviceList_CollectionChanged(deviceCollection.DeviceList, null);
- }
- private void DeviceList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs? e)
- {
- if (sender is not ObservableDictionary<Guid, DeviceInfo_VM> deviceList)
- return;
- this.Devices.Clear();
- foreach (DeviceInfo_VM device in deviceList.Values)
- {
- this.Devices[device.DeviceModel] ??= [];
- this.Devices[device.DeviceModel].Add(device);
- }
- }
- private readonly IDialogService _DialogService;
- private readonly DeviceCollection _DeviceCollection;
- [ObservableProperty]
- private ObservableDictionary<DeviceModel, ObservableCollection<DeviceInfo_VM>> _Devices = [];
- }
|