From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
HMI.Core/Entity/NotifyBase.cs | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/HMI.Core/Entity/NotifyBase.cs b/HMI.Core/Entity/NotifyBase.cs
new file mode 100644
index 0000000..09b4634
--- /dev/null
+++ b/HMI.Core/Entity/NotifyBase.cs
@@ -0,0 +1,96 @@
+锘縰sing System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows.Input;
+
+namespace HMI.Core.Entity
+{
+ public class NotifyBase : INotifyPropertyChanged
+ {
+ #region ...
+ public virtual event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void Set([CallerMemberName] string name = null)
+ {
+
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+ }
+
+ protected void Set<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
+ {
+ old = @new;
+ if (propertyName != null)
+ {
+ Set(propertyName);
+ }
+ }
+ #endregion
+ }
+
+ public class RelayCommand<T> : ICommand
+ {
+ /// <summary>
+ /// 鍛戒护鑳藉惁鎵ц
+ /// </summary>
+ readonly Func<bool> _canExecute;
+ /// <summary>
+ /// 鍛戒护鎵ц鐨勬柟娉�
+ /// </summary>
+ readonly Action<T> _execute;
+
+ /// <summary>
+ /// 鍛戒护鐨勬瀯閫犲嚱鏁�
+ /// </summary>
+ /// <param name="action">鍛戒护闇�鎵ц鐨勬柟娉�</param>
+ /// <param name="canExecute">鍛戒护鏄惁鍙互鎵ц鐨勬柟娉�</param>
+ public RelayCommand(Action<T> action, Func<bool> canExecute)
+ {
+ _execute = action;
+ _canExecute = canExecute;
+ }
+
+ public RelayCommand(Action<T> action)
+ {
+ _execute = action;
+ }
+
+ /// <summary>
+ /// 鍒ゆ柇鍛戒护鏄惁鍙互鎵ц
+ /// </summary>
+ /// <param name="parameter"></param>
+ /// <returns></returns>
+ public bool CanExecute(Object parameter)
+ {
+ if (_canExecute == null)
+ return true;
+ return _canExecute();
+ }
+
+ /// <summary>
+ /// 鎵ц鍛戒护
+ /// </summary>
+ /// <param name="parameter"></param>
+ public void Execute(Object parameter)
+ {
+ _execute((T)parameter);
+ }
+
+ /// <summary>
+ /// 浜嬩欢杩藉姞銆佺Щ闄�
+ /// </summary>
+ public event EventHandler CanExecuteChanged
+ {
+ add
+ {
+ if (_canExecute != null)
+ CommandManager.RequerySuggested += value;
+ }
+ remove
+ {
+ if (_canExecute != null)
+ CommandManager.RequerySuggested -= value;
+ }
+ }
+
+ }
+}
--
Gitblit v1.9.1