| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using CommunityToolkit.Mvvm.ComponentModel;
- using CommunityToolkit.Mvvm.Input;
- using Device;
- using EEMSMain.Data;
- using GeneralData;
- using GlobalData;
- using UICommon.CommonContainer;
- using UICommon.DataType;
- namespace EEMSMain.ViewModels;
- public partial class MainWindowViewModel : ObservableObject
- {
- public MainWindowViewModel(ICommonContainer commonContainer, ContainerManager containerManager, DeviceCollection deviceCollection)
- {
- this._commonContainer = commonContainer;
- this.ContainerManager = containerManager;
- this._deviceCollection = deviceCollection;
- containerManager.Containers.CollectionChanged += Containers_CollectionChanged;
- //deviceCollection.RawDevices.CollectionChanged += RawDevices_CollectionChanged;
- this.FakeData();
- }
- //private void RawDevices_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- //{
- // if (e.NewItems is null)
- // return;
- // foreach (object item in e.NewItems)
- // {
- // if (item is KeyValuePair<Guid, DeviceInfo_VM> devicePair)
- // {
- // }
- // }
- //}
- private void Containers_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- if (sender is not ObservableDictionary<int, ContainerInfo> t)
- return;
- ContainerInfo? containerInfo = t.Values.FirstOrDefault(x => x.IsDefault);
- if (containerInfo is null)
- return;
- this.Open(containerInfo);
- }
- private readonly ICommonContainer _commonContainer;
- public ContainerManager ContainerManager { get; }
- private readonly DeviceCollection _deviceCollection;
- void FakeData()
- {
- _deviceCollection.Devices ??= [];
- _deviceCollection.Devices[DeviceModel.JetKepler] = [];
- for (int i = 1; i <= 6; i++)
- {
- DeviceInfo_VM device = new()
- {
- DeviceModel = DeviceModel.JetKepler,
- DeviceSubModel = KeplerSubModel.JetKepler_2200A.ToString(),
- DeviceName = $"Device {i}",
- Position = $"position-{i}",
- SoftwareVersion = "1.0.0.0",
- Guid = Guid.NewGuid(),
- };
- _deviceCollection.Devices[DeviceModel.JetKepler].Add(device);
- //_deviceCollection.RawDevices.Add(device.Guid.Value, device);
- }
- _deviceCollection.Devices[DeviceModel.Proxima] = [];
- for (int i = 1; i <= 3; i++)
- {
- DeviceInfo_VM device = new()
- {
- DeviceModel = DeviceModel.Proxima,
- DeviceSubModel = ProximaSubModel.Proxima_ELK.ToString(),
- DeviceName = $"Device {i}",
- Position = $"position-{i}",
- SoftwareVersion = "1.0.0.0",
- Guid = Guid.NewGuid(),
- };
- _deviceCollection.Devices[DeviceModel.Proxima].Add(device);
- //_deviceCollection.RawDevices.Add(device.Guid.Value, device);
- }
- }
- [ObservableProperty]
- private string? _CurrentModule;
- [RelayCommand]
- private void Open(ContainerInfo para)
- {
- try
- {
- _commonContainer.RequestNavigation(para.ModuleName);
- this.CurrentModule = para.Name;
- }
- catch
- {
- }
- }
- }
|