automapper框架优化
This commit is contained in:
@@ -21,7 +21,7 @@ namespace UIShare.Converters
|
||||
return allParameters;
|
||||
|
||||
// 过滤出类型匹配的参数
|
||||
return allParameters.Cast<ParameterModel>()
|
||||
return allParameters.Cast<ParameterVM>()
|
||||
.Where(p => IsTypeMatch(currentParamType, p.Type))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using static UIShare.UIViewModel.ParameterModel;
|
||||
using static UIShare.UIViewModel.ParameterVM;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using static UIShare.UIViewModel.ParameterModel;
|
||||
using static UIShare.UIViewModel.ParameterVM;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace UIShare.GlobalVariable
|
||||
public class ScopedContext
|
||||
{
|
||||
private static readonly Random _randomSeed = new Random();
|
||||
public ProgramModel Program { get; set; } = new();
|
||||
public ProgramVM Program { get; set; } = new();
|
||||
public String SelectedStepList { get; set; } = "主程序";
|
||||
public string CurrentFilePath { get; set; }
|
||||
public bool? IsStop { get; set; }
|
||||
@@ -26,8 +26,8 @@ namespace UIShare.GlobalVariable
|
||||
public bool IsTerminate { get; set; } = false;
|
||||
public ObservableCollection<Assembly> Assemblies { get; set; } = new();
|
||||
public PackIconKind RunIcon { get; set; } = PackIconKind.Play;
|
||||
public StepModel SelectedStep { get; set; }
|
||||
public ParameterModel SelectedParameter { get; set; }
|
||||
public StepVM SelectedStep { get; set; }
|
||||
public ParameterVM SelectedParameter { get; set; }
|
||||
|
||||
public List<IBaseInterface> DeviceList { get; set; } = new();
|
||||
// 【新增测试属性】:每个实例被 new 出来时独一无二的随机身份
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UIShare.GlobalVariable;
|
||||
using static UIShare.UIViewModel.ParameterModel;
|
||||
using static UIShare.UIViewModel.ParameterVM;
|
||||
|
||||
|
||||
namespace UIShare
|
||||
@@ -26,7 +26,7 @@ namespace UIShare
|
||||
private IContainerProvider containerProvider;
|
||||
private IEventAggregator _eventAggregator;
|
||||
|
||||
private readonly Dictionary<Guid, ParameterModel> tmpParameters = [];
|
||||
private readonly Dictionary<Guid, ParameterVM> tmpParameters = [];
|
||||
|
||||
private readonly Stopwatch stepStopwatch = new();
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace UIShare
|
||||
_eventAggregator = eventAggregator;
|
||||
//_devices = containerProvider.Resolve<Devices>();
|
||||
}
|
||||
public async Task<bool> ExecuteErrorSteps(ProgramModel program, int depth = 0, CancellationToken cancellationToken = default)
|
||||
public async Task<bool> ExecuteErrorSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
int index = 0;
|
||||
bool stepSuccess = false;
|
||||
@@ -211,7 +211,7 @@ namespace UIShare
|
||||
|
||||
return loopStack.Count == 0 && stepSuccess;
|
||||
}
|
||||
public async Task<bool> ExecuteSteps(ProgramModel program, int depth = 0, CancellationToken cancellationToken = default)
|
||||
public async Task<bool> ExecuteSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
int index = 0;
|
||||
bool stepSuccess = false;
|
||||
@@ -388,7 +388,7 @@ namespace UIShare
|
||||
return loopStack.Count == 0 && stepSuccess;
|
||||
}
|
||||
|
||||
public async Task ExecuteMethodStep(StepModel step, Dictionary<Guid, ParameterModel> parameters, int depth, CancellationToken cancellationToken = default)
|
||||
public async Task ExecuteMethodStep(StepVM step, Dictionary<Guid, ParameterVM> parameters, int depth, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -417,7 +417,7 @@ namespace UIShare
|
||||
// 3. 准备参数
|
||||
var inputParams = new List<object?>();
|
||||
var paramTypes = new List<Type>();
|
||||
ParameterModel? outputParam = null;
|
||||
ParameterVM? outputParam = null;
|
||||
foreach (var param in step.Method!.Parameters)
|
||||
{
|
||||
if (param.Category == ParameterCategory.Input)
|
||||
@@ -656,7 +656,7 @@ namespace UIShare
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAllStepStatus(ObservableCollection<StepModel> StepCollection)
|
||||
public void ResetAllStepStatus(ObservableCollection<StepVM> StepCollection)
|
||||
{
|
||||
foreach (var step in StepCollection)
|
||||
{
|
||||
@@ -665,7 +665,7 @@ namespace UIShare
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCurrentStepResult(StepModel step, bool paraResult = true, bool stepResult = true, int depth = 0)
|
||||
private void UpdateCurrentStepResult(StepVM step, bool paraResult = true, bool stepResult = true, int depth = 0)
|
||||
{
|
||||
if (stepResult && paraResult)
|
||||
{
|
||||
@@ -721,7 +721,7 @@ namespace UIShare
|
||||
public int LoopCount { get; set; }
|
||||
public int CurrentLoop { get; set; }
|
||||
public int StartIndex { get; set; }
|
||||
public StepModel? LoopStartStep { get; set; }
|
||||
public StepVM? LoopStartStep { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace UIShare.GlobalVariable
|
||||
public string DefaultProgramFilePath { get; set; } = "";
|
||||
public string DefaultBLFFilePath { get; set; } = "";
|
||||
public string DefaultDBCFilePath { get; set; } = "";
|
||||
public ObservableCollection<DeviceInfoModel> DeviceList = new();
|
||||
// public ObservableCollection<DeviceInfoModel> DeviceList { get; set; } = new()
|
||||
public ObservableCollection<DeviceInfoVM> DeviceList = new();
|
||||
// public ObservableCollection<DeviceInfoVM> DeviceList { get; set; } = new()
|
||||
//{
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "IT7800E",
|
||||
// DeviceType = "IT7800E",
|
||||
@@ -39,7 +39,7 @@ namespace UIShare.GlobalVariable
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "N36200",
|
||||
// DeviceType = "N36200",
|
||||
@@ -49,7 +49,7 @@ namespace UIShare.GlobalVariable
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "N36600",
|
||||
// DeviceType = "N36600",
|
||||
@@ -59,7 +59,7 @@ namespace UIShare.GlobalVariable
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "N69200",
|
||||
// DeviceType = "N69200",
|
||||
@@ -69,7 +69,7 @@ namespace UIShare.GlobalVariable
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "SDS2000X_HD",
|
||||
// DeviceType = "SDS2000X_HD",
|
||||
@@ -79,7 +79,7 @@ namespace UIShare.GlobalVariable
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// new DeviceInfoVM
|
||||
// {
|
||||
// DeviceName = "SPAW7000",
|
||||
// DeviceType = "SPAW7000",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class CanMessageShowModel : BindableBase
|
||||
public class CanMessageShowVM : BindableBase
|
||||
{
|
||||
// 字段声明
|
||||
private byte _通道;
|
||||
@@ -2,17 +2,17 @@ using Prism.Mvvm;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class CustomPanelItem : BindableBase
|
||||
public class CustomPanelItemVM : BindableBase
|
||||
{
|
||||
private string _name;
|
||||
private string _pointY;
|
||||
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
private string _pointY;
|
||||
public string PointY
|
||||
{
|
||||
get => _pointY;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class DeviceInfoModel : BindableBase
|
||||
public class DeviceInfoVM : BindableBase
|
||||
{
|
||||
private string _deviceName;
|
||||
public string DeviceName
|
||||
@@ -51,16 +51,16 @@ namespace UIShare.UIViewModel
|
||||
}
|
||||
|
||||
/// <summary>TCP 连接参数(首次访问时自动初始化,便于 XAML 直接绑定)。</summary>
|
||||
private TcpConnectionConfig _tcpConfig = new();
|
||||
public TcpConnectionConfig TcpConfig
|
||||
private TcpConfigVM _tcpConfig = new();
|
||||
public TcpConfigVM TcpConfig
|
||||
{
|
||||
get => _tcpConfig;
|
||||
set => SetProperty(ref _tcpConfig, value);
|
||||
}
|
||||
|
||||
/// <summary>串口连接参数(首次访问时自动初始化,便于 XAML 直接绑定)。</summary>
|
||||
private SerialPortConnectionConfig _serialPortConfig = new();
|
||||
public SerialPortConnectionConfig SerialPortConfig
|
||||
private SerialPortConfigVM _serialPortConfig = new();
|
||||
public SerialPortConfigVM SerialPortConfig
|
||||
{
|
||||
get => _serialPortConfig;
|
||||
set => SetProperty(ref _serialPortConfig, value);
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class InstructionNode
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public ObservableCollection<InstructionNode> Children { get; set; } = new();
|
||||
public object Tag { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
36
UIShare/UIViewModel/InstructionNodeVM.cs
Normal file
36
UIShare/UIViewModel/InstructionNodeVM.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Prism.Mvvm; // 确保引入了 Prism 命名空间
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class InstructionNodeVM : BindableBase
|
||||
{
|
||||
private string _name = string.Empty;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<InstructionNodeVM> _children = new();
|
||||
public ObservableCollection<InstructionNodeVM> Children
|
||||
{
|
||||
get => _children;
|
||||
set => SetProperty(ref _children, value);
|
||||
}
|
||||
|
||||
private object? _tag;
|
||||
public object? Tag
|
||||
{
|
||||
get => _tag;
|
||||
set => SetProperty(ref _tag, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class MethodModel
|
||||
public class MethodVM
|
||||
{
|
||||
|
||||
#region 构造函数
|
||||
|
||||
public MethodModel()
|
||||
public MethodVM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MethodModel(MethodModel source)
|
||||
public MethodVM(MethodVM source)
|
||||
{
|
||||
if (source == null) return;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace UIShare.UIViewModel
|
||||
FullName = source.FullName;
|
||||
|
||||
// 深拷贝参数
|
||||
Parameters = new ObservableCollection<ParameterModel>(
|
||||
source.Parameters.Select(p => new ParameterModel(p)));
|
||||
Parameters = new ObservableCollection<ParameterVM>(
|
||||
source.Parameters.Select(p => new ParameterVM(p)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -35,6 +35,6 @@ namespace UIShare.UIViewModel
|
||||
|
||||
public string? FullName { get; set; }
|
||||
|
||||
public ObservableCollection<ParameterModel> Parameters { get; set; } = [];
|
||||
public ObservableCollection<ParameterVM> Parameters { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,16 @@ using System.Collections.Generic;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class ParameterModel : BindableBase
|
||||
public class ParameterVM : BindableBase
|
||||
{
|
||||
#region 构造函数
|
||||
|
||||
public ParameterModel()
|
||||
public ParameterVM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ParameterModel(ParameterModel source)
|
||||
public ParameterVM(ParameterVM source)
|
||||
{
|
||||
if (source == null) return;
|
||||
|
||||
@@ -139,10 +139,10 @@ namespace UIShare.UIViewModel
|
||||
Temp
|
||||
}
|
||||
|
||||
public object? GetActualValue(Dictionary<Guid, ParameterModel> paraList)
|
||||
public object? GetActualValue(Dictionary<Guid, ParameterVM> paraList)
|
||||
{
|
||||
HashSet<Guid> visitedIds = new HashSet<Guid>();
|
||||
ParameterModel current = this;
|
||||
ParameterVM current = this;
|
||||
|
||||
while (current != null)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ namespace UIShare.UIViewModel
|
||||
}
|
||||
}
|
||||
|
||||
ParameterModel? next = paraList[(Guid)current.VariableID!];
|
||||
ParameterVM? next = paraList[(Guid)current.VariableID!];
|
||||
if (next == null)
|
||||
{
|
||||
return null;
|
||||
@@ -184,10 +184,10 @@ namespace UIShare.UIViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParameterModel? GetCurrentParameter(Dictionary<Guid, ParameterModel> paraList)
|
||||
public ParameterVM? GetCurrentParameter(Dictionary<Guid, ParameterVM> paraList)
|
||||
{
|
||||
HashSet<Guid> visitedIds = new HashSet<Guid>();
|
||||
ParameterModel current = this;
|
||||
ParameterVM current = this;
|
||||
|
||||
while (current != null)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ namespace UIShare.UIViewModel
|
||||
}
|
||||
}
|
||||
|
||||
ParameterModel? next = paraList[(Guid)current.VariableID!];
|
||||
ParameterVM? next = paraList[(Guid)current.VariableID!];
|
||||
if (next == null)
|
||||
{
|
||||
return null;
|
||||
@@ -1,51 +0,0 @@
|
||||
using Prism.Mvvm; // 引入 Prism 的 BindableBase
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class ProgramModel : BindableBase
|
||||
{
|
||||
#region 构造函数
|
||||
|
||||
public ProgramModel()
|
||||
{
|
||||
// 可以进行初始化操作
|
||||
}
|
||||
|
||||
public ProgramModel(ProgramModel source)
|
||||
{
|
||||
ID = source.ID;
|
||||
StepCollection = new ObservableCollection<StepModel>(source.StepCollection.Select(p => new StepModel(p)));
|
||||
ErrorStepCollection = new ObservableCollection<StepModel>(source.ErrorStepCollection.Select(p => new StepModel(p)));
|
||||
Parameters = new ObservableCollection<ParameterModel>(source.Parameters.Select(p => new ParameterModel(p)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Guid ID { get; set; } = Guid.NewGuid();
|
||||
|
||||
private ObservableCollection<StepModel> _stepCollection = new ObservableCollection<StepModel>();
|
||||
public ObservableCollection<StepModel> StepCollection
|
||||
{
|
||||
get => _stepCollection;
|
||||
set => SetProperty(ref _stepCollection, value);
|
||||
}
|
||||
private ObservableCollection<StepModel> _errorStepCollection = new ObservableCollection<StepModel>();
|
||||
public ObservableCollection<StepModel> ErrorStepCollection
|
||||
{
|
||||
get => _errorStepCollection;
|
||||
set => SetProperty(ref _errorStepCollection, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<ParameterModel> _parameters = new ObservableCollection<ParameterModel>();
|
||||
public ObservableCollection<ParameterModel> Parameters
|
||||
{
|
||||
get => _parameters;
|
||||
set => SetProperty(ref _parameters, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
51
UIShare/UIViewModel/ProgramVM.cs
Normal file
51
UIShare/UIViewModel/ProgramVM.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Prism.Mvvm; // 引入 Prism 的 BindableBase
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class ProgramVM : BindableBase
|
||||
{
|
||||
#region 构造函数
|
||||
|
||||
public ProgramVM()
|
||||
{
|
||||
// 可以进行初始化操作
|
||||
}
|
||||
|
||||
public ProgramVM(ProgramVM source)
|
||||
{
|
||||
ID = source.ID;
|
||||
StepCollection = new ObservableCollection<StepVM>(source.StepCollection.Select(p => new StepVM(p)));
|
||||
ErrorStepCollection = new ObservableCollection<StepVM>(source.ErrorStepCollection.Select(p => new StepVM(p)));
|
||||
Parameters = new ObservableCollection<ParameterVM>(source.Parameters.Select(p => new ParameterVM(p)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Guid ID { get; set; } = Guid.NewGuid();
|
||||
|
||||
private ObservableCollection<StepVM> _stepCollection = new ObservableCollection<StepVM>();
|
||||
public ObservableCollection<StepVM> StepCollection
|
||||
{
|
||||
get => _stepCollection;
|
||||
set => SetProperty(ref _stepCollection, value);
|
||||
}
|
||||
private ObservableCollection<StepVM> _errorStepCollection = new ObservableCollection<StepVM>();
|
||||
public ObservableCollection<StepVM> ErrorStepCollection
|
||||
{
|
||||
get => _errorStepCollection;
|
||||
set => SetProperty(ref _errorStepCollection, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<ParameterVM> _parameters = new ObservableCollection<ParameterVM>();
|
||||
public ObservableCollection<ParameterVM> Parameters
|
||||
{
|
||||
get => _parameters;
|
||||
set => SetProperty(ref _parameters, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,16 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// TCP 连接配置(与 DeviceCommand.Base.Tcp 保持字段一致)。
|
||||
/// </summary>
|
||||
public class TcpConnectionConfig : 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 TcpConnectionConfig() { }
|
||||
|
||||
/// <summary>拷贝构造,用于对话框编辑副本。</summary>
|
||||
public TcpConnectionConfig(TcpConnectionConfig? src)
|
||||
{
|
||||
if (src == null) return;
|
||||
IPAddress = src.IPAddress;
|
||||
Port = src.Port;
|
||||
SendTimeout = src.SendTimeout;
|
||||
ReceiveTimeout = src.ReceiveTimeout;
|
||||
}
|
||||
|
||||
/// <summary>把字段拷回目标对象(保存时用)。</summary>
|
||||
public void CopyTo(TcpConnectionConfig? dst)
|
||||
{
|
||||
if (dst == null) return;
|
||||
dst.IPAddress = IPAddress;
|
||||
dst.Port = Port;
|
||||
dst.SendTimeout = SendTimeout;
|
||||
dst.ReceiveTimeout = ReceiveTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 串口连接配置(与 DeviceCommand.Base.Serial_Port 保持字段一致)。
|
||||
/// StopBits / Parity 用字符串保存,避免 UIShare 引入 System.IO.Ports 依赖。
|
||||
/// </summary>
|
||||
public class SerialPortConnectionConfig : BindableBase
|
||||
public class SerialPortConfigVM : BindableBase
|
||||
{
|
||||
private string _portName = "COM1";
|
||||
public string PortName
|
||||
@@ -115,9 +63,9 @@ namespace UIShare.UIViewModel
|
||||
set => SetProperty(ref _writeTimeout, value);
|
||||
}
|
||||
|
||||
public SerialPortConnectionConfig() { }
|
||||
public SerialPortConfigVM() { }
|
||||
|
||||
public SerialPortConnectionConfig(SerialPortConnectionConfig? src)
|
||||
public SerialPortConfigVM(SerialPortConfigVM? src)
|
||||
{
|
||||
if (src == null) return;
|
||||
PortName = src.PortName;
|
||||
@@ -129,7 +77,7 @@ namespace UIShare.UIViewModel
|
||||
WriteTimeout = src.WriteTimeout;
|
||||
}
|
||||
|
||||
public void CopyTo(SerialPortConnectionConfig? dst)
|
||||
public void CopyTo(SerialPortConfigVM? dst)
|
||||
{
|
||||
if (dst == null) return;
|
||||
dst.PortName = PortName;
|
||||
@@ -4,13 +4,13 @@ using System;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class StepModel : BindableBase
|
||||
public class StepVM : BindableBase
|
||||
{
|
||||
#region 构造函数
|
||||
|
||||
public StepModel() { }
|
||||
public StepVM() { }
|
||||
|
||||
public StepModel(StepModel source)
|
||||
public StepVM(StepVM source)
|
||||
{
|
||||
if (source == null) return;
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace UIShare.UIViewModel
|
||||
|
||||
if (source.Method != null)
|
||||
{
|
||||
Method = new MethodModel(source.Method);
|
||||
Method = new MethodVM(source.Method);
|
||||
}
|
||||
if (source.SubProgram != null)
|
||||
{
|
||||
SubProgram = new ProgramModel(source.SubProgram);
|
||||
SubProgram = new ProgramVM(source.SubProgram);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,17 +79,17 @@ namespace UIShare.UIViewModel
|
||||
set => SetProperty(ref _stepType, value);
|
||||
}
|
||||
|
||||
private MethodModel? _method;
|
||||
private MethodVM? _method;
|
||||
|
||||
public MethodModel? Method
|
||||
public MethodVM? Method
|
||||
{
|
||||
get => _method;
|
||||
set => SetProperty(ref _method, value);
|
||||
}
|
||||
|
||||
private ProgramModel? _subProgram;
|
||||
private ProgramVM? _subProgram;
|
||||
|
||||
public ProgramModel? SubProgram
|
||||
public ProgramVM? SubProgram
|
||||
{
|
||||
get => _subProgram;
|
||||
set => SetProperty(ref _subProgram, value);
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class SubProgramItem
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public string FilePath { get; set; } = "";
|
||||
}
|
||||
}
|
||||
28
UIShare/UIViewModel/SubProgramItemVM.cs
Normal file
28
UIShare/UIViewModel/SubProgramItemVM.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UIShare.UIViewModel
|
||||
{
|
||||
public class SubProgramItemVM : BindableBase
|
||||
{
|
||||
|
||||
private string _name="";
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
private string _filePath = "";
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get => _filePath;
|
||||
set => SetProperty(ref _filePath, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
62
UIShare/UIViewModel/TcpConfigVM.cs
Normal file
62
UIShare/UIViewModel/TcpConfigVM.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user