| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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;
- this.FakeData();
- }
- 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()
- {
- Random r = new();
- 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",
- IP = $"192.168.250.{i}",
- Port = 50002,
- UpdateTime = DateTime.Now,
- Guid = Guid.NewGuid(),
- IsConnected = Convert.ToBoolean(r.Next(0,2))
- };
- _deviceCollection.DeviceList.Add(device.Guid.Value, device);
- }
- 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",
- IP = $"192.168.250.{i}",
- Port = 50002,
- UpdateTime=DateTime.Now,
- Guid = Guid.NewGuid(),
- IsConnected = Convert.ToBoolean(r.Next(0, 2))
- };
- _deviceCollection.DeviceList.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
- {
- }
- }
- }
|