using BPASmartClient.CustomResource.Pages.Model; using BPA.Helper; using BPA.Helper; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.ViewModel { internal class ChangeDeviceNameViewModel:NotifyBase { private static string IpAddress = string.Empty; public BPARelayCommand ConfirmCommand { get; set; } public BPARelayCommand 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 BPARelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); ConfirmCommand = new BPARelayCommand(() => { if (string.IsNullOrEmpty(DeviceName)) { ErrorInfo = "设备名称不能为空"; return; } ActionManage.GetInstance.Send("UpdateDeviceName", DeviceName); MessageNotify.GetInstance.ShowUserLog($"修改了设备名称为【{DeviceName}】。"); ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); } } }