No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using Microsoft.Toolkit.Mvvm.Messaging;
- using System.Diagnostics;
- using BPASmart.Model;
- using System.Reflection;
-
- namespace BPASmart.VariableManager.ViewModels
- {
- public class NewDeviceViewModel : ObservableObject
- {
- public NewDeviceViewModel()
- {
- Init();
- CancelCommand = new RelayCommand(() =>
- {
- if (DelegationNotifi.GetInstance.Cancel != null) DelegationNotifi.GetInstance.Cancel(devcieManagerResult);
- });
- ConfirmCommand = new RelayCommand(() =>
- {
- if (DelegationNotifi.GetInstance.AddDeviceVerify != null)
- {
- if (DelegationNotifi.GetInstance.AddDeviceVerify(devcieManagerResult))
- {
- if (DelegationNotifi.GetInstance.Confirm != null) DelegationNotifi.GetInstance.Confirm(devcieManagerResult);
- }
- else
- {
- LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试";
- }
- }
- else
- {
- LogInfo = $"警告:设备添加失败!";
- }
-
- });
- }
-
- public ObservableCollection<string> DeviceType { get; set; } = new ObservableCollection<string>();
-
- public RelayCommand CancelCommand { get; set; }
- public RelayCommand ConfirmCommand { get; set; }
-
- private void Init()
- {
- DeviceType.Clear();
- var assembly = Assembly.GetAssembly(typeof(ICommunicationDevice))?.GetTypes()?.ToList();
- assembly?.ForEach(item =>
- {
- if (item.GetInterfaces().Contains(typeof(ICommunicationDevice)))
- {
- DeviceType.Add(item.Name);
- }
- });
- }
-
- public DeviceManagermentResult devcieManagerResult { get { return _mdevcieManagerResult; } set { _mdevcieManagerResult = value; OnPropertyChanged(); } }
- private DeviceManagermentResult _mdevcieManagerResult = new DeviceManagermentResult();
-
-
- public string LogInfo { get { return _mLogInfo; } set { _mLogInfo = value; OnPropertyChanged(); } }
- private string _mLogInfo;
-
-
-
-
- }
- }
|