using System.ComponentModel; using Serein.Library; using System.Runtime.CompilerServices; namespace Serein.Workbench.Node.ViewModel { public abstract class NodeControlViewModelBase : INotifyPropertyChanged { public NodeControlViewModelBase(NodeModelBase node) { Node = node; MethodDetails = Node.MethodDetails; } /// /// 对应的节点实体类 /// internal NodeModelBase Node { get; } private bool isSelect; /// /// 表示节点控件是否被选中 /// internal bool IsSelect { get => isSelect; set { isSelect = value; OnPropertyChanged(); } } /// /// 使节点获得中断能力(以及是否启用节点) /// public NodeDebugSetting DebugSetting { get => Node.DebugSetting; set { if (value != null) { Node.DebugSetting = value; OnPropertyChanged(); } } } /// /// 使节点能够表达方法信息 /// public MethodDetails MethodDetails { get => Node.MethodDetails; set { if(value != null) { Node.MethodDetails = value; OnPropertyChanged(); } } } private bool isInterrupt; /// /// 控制中断状态的视觉效果 /// public bool IsInterrupt { get => isInterrupt; set { isInterrupt = value; OnPropertyChanged(); } } /// /// /// public event PropertyChangedEventHandler? PropertyChanged; /// /// /// /// protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } /// /// /// public void Selected() { IsSelect = true; } /// /// /// public void CancelSelect() { IsSelect = false; } } }