| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using CommunityToolkit.Mvvm.ComponentModel;
- using CommunityToolkit.Mvvm.Input;
- using GlobalData;
- using System.Collections.ObjectModel;
- using System.Windows;
- namespace ConfigFileManager.ViewModels.Dialog;
- internal partial class MigrateViewModel : ObservableObject, IDialogAware
- {
- public MigrateViewModel(DeviceCollection deviceCollection)
- {
- this.Sources = [];
- foreach (IList<DeviceInfo_VM> deviceInfos in deviceCollection.Devices.Values)
- this.Sources.AddRange(deviceInfos);
- }
- [ObservableProperty]
- private ObservableCollection<DeviceInfo_VM> _Sources;
- [ObservableProperty]
- private DeviceInfo_VM? _Source;
- public DialogCloseListener RequestClose { get; set; }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- if (!parameters.TryGetValue("Device", out DeviceInfo_VM? deviceInfo) || deviceInfo is null)
- {
- MessageBox.Show("Config Device Error");
- this.RequestClose.Invoke();
- return;
- }
- this.Sources.Remove(deviceInfo);
- this.Source = deviceInfo;
- }
- [RelayCommand]
- private void Close()
- {
- this.RequestClose.Invoke();
- }
- }
|