Files
CapMachine/CapMachine.Wpf/ViewModels/LinSchTabNode.cs

110 lines
3.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Prism.Mvvm;
using System.Collections.ObjectModel;
namespace CapMachine.Wpf.ViewModels
{
/// <summary>
/// 调度表节点(父节点)。
/// 与 XAML 中父级 <TreeView> 的 <HierarchicalDataTemplate> 绑定:
/// - 显示字段:<see cref="SchTabName"/>
/// - 选择字段:<see cref="IsSelected"/>TwoWay 绑定至 CheckBox
/// - 子集合:<see cref="Children"/>(用于展开显示消息/帧子节点)
///
/// 使用 Prism 的 <see cref="BindableBase.SetProperty{T}(ref T, T, string?)"/>
/// 以避免值未发生变化时重复触发 PropertyChanged 引起的联动递归。
/// </summary>
public class LinSchTabNode : BindableBase
{
/// <summary>
/// 调度表名称(父节点标题)。
/// </summary>
private string _SchTabName;
public string SchTabName
{
get => _SchTabName;
set => SetProperty(ref _SchTabName, value);
}
private bool _IsSelected;
/// <summary>
/// 是否被激活/选中(父节点单选)。
/// 该属性与 XAML 中父节点的 CheckBox 进行 TwoWay 绑定,
/// 其变更由 ViewModel 监听并处理“单选联动”和“子节点跟随”。
/// </summary>
public bool IsSelected
{
get => _IsSelected;
set => SetProperty(ref _IsSelected, value);
}
/// <summary>
/// 子节点集合(消息/帧条目)。
/// </summary>
private ObservableCollection<LinMsgNode> _Children = new ObservableCollection<LinMsgNode>();
public ObservableCollection<LinMsgNode> Children
{
get => _Children;
set => SetProperty(ref _Children, value);
}
}
/// <summary>
/// 消息/帧 节点(子节点)。
/// 与 XAML 中父级 <HierarchicalDataTemplate.ItemTemplate> 绑定:
/// - 显示字段:<see cref="MsgName"/> / <see cref="MsgNameIndex"/>
/// - 选择字段:<see cref="IsSelected"/>(当前设计作为“显示联动”,非编辑入口)
/// </summary>
public class LinMsgNode : BindableBase
{
/// <summary>
/// 所属的调度表名称(便于回写 DTO 时定位)。
/// </summary>
private string _SchTabName;
public string SchTabName
{
get => _SchTabName;
set => SetProperty(ref _SchTabName, value);
}
/// <summary>
/// 消息/帧名称。
/// </summary>
private string _MsgName;
public string MsgName
{
get => _MsgName;
set => SetProperty(ref _MsgName, value);
}
/// <summary>
/// 消息/帧 Index。
/// </summary>
private int _MsgNameIndex;
public int MsgNameIndex
{
get => _MsgNameIndex;
set => SetProperty(ref _MsgNameIndex, value);
}
private bool _IsSelected;
/// <summary>
/// 是否被选中(随父节点联动显示)。
/// </summary>
public bool IsSelected
{
get => _IsSelected;
set => SetProperty(ref _IsSelected, value);
}
/// <summary>
/// 子节点勾选是否可用(仅当父调度表被选中时可编辑)。
/// </summary>
private bool _CanEdit;
public bool CanEdit
{
get => _CanEdit;
set => SetProperty(ref _CanEdit, value);
}
}
}