将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。

This commit is contained in:
QI Mingxuan
2026-04-16 17:31:13 +08:00
parent 6ec4c3ddaa
commit 2bd6e566c3
581 changed files with 74600 additions and 222 deletions
@@ -0,0 +1,50 @@
using System.Windows;
using System.Windows.Controls;
using XP.Hardware.PLC.Sentry.ViewModels;
namespace XP.Hardware.PLC.Sentry.Views
{
/// <summary>
/// 写入值控件模板选择器,根据信号数据类型选择不同的写入控件 | Write value template selector, selects different write controls based on signal data type
/// bool → ToggleButton, byte/short/int → RadNumericUpDown(整数), single/double → RadNumericUpDown(浮点), string → TextBox
/// </summary>
public class WriteValueTemplateSelector : DataTemplateSelector
{
/// <summary>
/// bool 类型写入模板 | Bool type write template
/// </summary>
public DataTemplate BoolTemplate { get; set; }
/// <summary>
/// 整数类型写入模板(byte, short, int| Integer type write template
/// </summary>
public DataTemplate IntegerTemplate { get; set; }
/// <summary>
/// 浮点类型写入模板(single, double| Float type write template
/// </summary>
public DataTemplate FloatTemplate { get; set; }
/// <summary>
/// 字符串类型写入模板 | String type write template
/// </summary>
public DataTemplate StringTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is SignalRowViewModel row)
{
return row.Type?.ToLowerInvariant() switch
{
"bool" => BoolTemplate,
"byte" or "short" or "int" => IntegerTemplate,
"single" or "double" => FloatTemplate,
"string" => StringTemplate,
_ => StringTemplate // 默认使用文本框 | Default to TextBox
};
}
return base.SelectTemplate(item, container);
}
}
}