using BPASmartClient.Helper; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.ViewModel { internal class ChangeDeviceNameViewModel:ObservableObject { private static string IpAddress = string.Empty; public RelayCommand ConfirmCommand { get; set; } public RelayCommand CancleCommand { get; set; } public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } private string _mErrorInfo; public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } private string _mDeviceName; public ChangeDeviceNameViewModel() { ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is string str) IpAddress = str; }), "ChangeDeviceNameViewOpen"); CancleCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); ConfirmCommand = new RelayCommand(() => { if (string.IsNullOrEmpty(DeviceName)) { ErrorInfo = "设备名称不能为空"; return; } ActionManage.GetInstance.Send("UpdateDeviceName", DeviceName); ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); } } }