1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- namespace ConfigFileManager.ViewModels;
- public partial class ConfigFileManagerViewModel : ObservableObject
- {
- public ConfigFileManagerViewModel(DeviceCollection deviceCollection, IDialogService dialogService)
- {
- _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;
- [ObservableProperty]
- private ObservableDictionary<DeviceModel, ObservableCollection<DeviceInfo_VM>> _Devices = [];
- [RelayCommand]
- private void Migrate(DeviceInfo_VM deviceInfo)
- {
- IDialogParameters para = new DialogParameters()
- {
- {"Device",deviceInfo }
- };
- this._DialogService.ShowDialog("Migrate", para);
- }
- [RelayCommand]
- private async Task Update(DeviceInfo_VM deviceInfo)
- {
- deviceInfo.ConfigUpdating = true;
- await Task.Delay(5000);
- deviceInfo.ConfigUpdating = false;
- deviceInfo.UpdateTime = DateTime.Now;
- }
- [RelayCommand]
- private void CheckRecipe(DeviceInfo_VM deviceInfo)
- {
- IDialogParameters para = new DialogParameters()
- {
- {"Device",deviceInfo }
- };
- this._DialogService.ShowDialog("Recipe", para);
- }
- [RelayCommand]
- private void CheckConfig(DeviceInfo_VM deviceInfo)
- {
- IDialogParameters para = new DialogParameters()
- {
- {"Device",deviceInfo }
- };
- this._DialogService.ShowDialog("Config", para);
- }
- }
|