using Prism.Mvvm;
namespace UIShare.UIViewModel
{
///
/// TCP 连接配置(与 DeviceCommand.Base.Tcp 保持字段一致)。
///
public class TcpConfigVM : BindableBase
{
private string _ipAddress = "127.0.0.1";
public string IPAddress
{
get => _ipAddress;
set => SetProperty(ref _ipAddress, value);
}
private int _port = 502;
public int Port
{
get => _port;
set => SetProperty(ref _port, value);
}
private int _sendTimeout = 3000;
public int SendTimeout
{
get => _sendTimeout;
set => SetProperty(ref _sendTimeout, value);
}
private int _receiveTimeout = 3000;
public int ReceiveTimeout
{
get => _receiveTimeout;
set => SetProperty(ref _receiveTimeout, value);
}
public TcpConfigVM() { }
/// 拷贝构造,用于对话框编辑副本。
public TcpConfigVM(TcpConfigVM? src)
{
if (src == null) return;
IPAddress = src.IPAddress;
Port = src.Port;
SendTimeout = src.SendTimeout;
ReceiveTimeout = src.ReceiveTimeout;
}
/// 把字段拷回目标对象(保存时用)。
public void CopyTo(TcpConfigVM? dst)
{
if (dst == null) return;
dst.IPAddress = IPAddress;
dst.Port = Port;
dst.SendTimeout = SendTimeout;
dst.ReceiveTimeout = ReceiveTimeout;
}
}
}