Files
ADP/UIShare/UIViewModel/TcpConfigVM.cs
2026-06-10 16:05:35 +08:00

63 lines
1.6 KiB
C#

using Prism.Mvvm;
namespace UIShare.UIViewModel
{
/// <summary>
/// TCP 连接配置(与 DeviceCommand.Base.Tcp 保持字段一致)。
/// </summary>
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() { }
/// <summary>拷贝构造,用于对话框编辑副本。</summary>
public TcpConfigVM(TcpConfigVM? src)
{
if (src == null) return;
IPAddress = src.IPAddress;
Port = src.Port;
SendTimeout = src.SendTimeout;
ReceiveTimeout = src.ReceiveTimeout;
}
/// <summary>把字段拷回目标对象(保存时用)。</summary>
public void CopyTo(TcpConfigVM? dst)
{
if (dst == null) return;
dst.IPAddress = IPAddress;
dst.Port = Port;
dst.SendTimeout = SendTimeout;
dst.ReceiveTimeout = ReceiveTimeout;
}
}
}