refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
using ExtendedGrid.Microsoft.Windows.Controls;
|
||||
using MECF.Framework.Common.Account;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
||||
{
|
||||
public interface IParam
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前参数所属列名称。
|
||||
/// </summary>
|
||||
string DisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数的控制名称。
|
||||
/// <remarks>
|
||||
/// 对应RecipeFormat.xml文件中的ControlName。
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
string ControlName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前参数所属的配方步骤。
|
||||
/// </summary>
|
||||
RecipeStep Parent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前参数在表格中的所属行。
|
||||
/// </summary>
|
||||
DataGridRow RowOwner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前参数在表格中的所属列。
|
||||
/// </summary>
|
||||
DataGridColumn ColumnOwner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回前序参数。
|
||||
/// </summary>
|
||||
IParam Previous { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回后序参数。
|
||||
/// </summary>
|
||||
IParam Next { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数所属步骤的访问权限。
|
||||
/// </summary>
|
||||
public MenuPermissionEnum StepPermission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数所属列的访问权限。
|
||||
/// </summary>
|
||||
public MenuPermissionEnum ColumnPermission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数的访问权限。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 访问权限由当前参数所在的列和步骤共同决定。权限数值越小优先级越高。
|
||||
/// </remarks>
|
||||
public MenuPermissionEnum Permission { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回是否在编辑器中隐藏参数值。
|
||||
/// </summary>
|
||||
public bool IsHideValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回参数值隐藏时的替代符号。
|
||||
/// </summary>
|
||||
public string HiddenValueMasking { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数是否被禁用。
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前参数是否已保存。
|
||||
/// </summary>
|
||||
bool IsSaved { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数的数值是否和前序参数的数值相等。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 该属性用于渲染DataGrid单元格文本颜色,当不等于前序参数数值时,当前参数显示为绿色。
|
||||
/// </remarks>
|
||||
bool IsEqualsToPrevious { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前参数是否校验成功。
|
||||
/// </summary>
|
||||
bool IsValid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前参数校验错误信息。
|
||||
/// </summary>
|
||||
string ValidationError { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回计算器是否校验成功。
|
||||
/// </summary>
|
||||
bool IsCalculatorError { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回是否高亮显示当前参数。
|
||||
/// </summary>
|
||||
bool IsHighlighted { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// 将参数链表转换为数组。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<IParam> Flatten();
|
||||
|
||||
/// <summary>
|
||||
/// 校验用户输入值。
|
||||
/// </summary>
|
||||
void Validate();
|
||||
|
||||
/// <summary>
|
||||
/// 设置为已保存状态。
|
||||
/// </summary>
|
||||
void Save();
|
||||
|
||||
/// <summary>
|
||||
/// 高亮显示当前参数。
|
||||
/// </summary>
|
||||
void Highlight();
|
||||
|
||||
/// <summary>
|
||||
/// 取消高亮显示。
|
||||
/// </summary>
|
||||
void ResetHighlight();
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前参数错误
|
||||
/// </summary>
|
||||
void SetCalculatorError();
|
||||
|
||||
/// <summary>
|
||||
/// 取消当前参数错误
|
||||
/// </summary>
|
||||
void ResetCalculatorError();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
||||
|
||||
public interface IValueParam
|
||||
{
|
||||
event EventHandler<object> OnValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前参数的数值。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
object GetValue();
|
||||
|
||||
/// <summary>
|
||||
/// 设置新参数。
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
void SetValue(object value);
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
||||
{
|
||||
public abstract class NumParamBase<TValue> : ParamBaseWithGenericValue<TValue>
|
||||
{
|
||||
#region Variables
|
||||
|
||||
protected TValue _minimun;
|
||||
protected TValue _maximun;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected NumParamBase()
|
||||
{
|
||||
}
|
||||
|
||||
protected NumParamBase(TValue initValue) : base(initValue)
|
||||
{
|
||||
}
|
||||
|
||||
protected NumParamBase(TValue initValue, TValue minimum, TValue maximum) : base(initValue)
|
||||
{
|
||||
if (minimum.GetType() != typeof(TValue))
|
||||
minimum = default;
|
||||
|
||||
if (maximum.GetType() != typeof(TValue))
|
||||
maximum = default;
|
||||
|
||||
_minimun = minimum;
|
||||
_maximun = maximum;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public TValue Minimun
|
||||
{
|
||||
get => _minimun;
|
||||
set => Set(ref _minimun, value);
|
||||
}
|
||||
|
||||
|
||||
public TValue Maximun
|
||||
{
|
||||
get => _maximun;
|
||||
set => Set(ref _maximun, value);
|
||||
}
|
||||
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Validate()
|
||||
{
|
||||
var ret = Comparer<TValue>.Default.Compare(_minimun, _maximun);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
IsValid = false;
|
||||
ValidationError = "Config error: minimum value is greater than maximum value";
|
||||
return;
|
||||
}
|
||||
|
||||
if (double.TryParse(Value.ToString(), out var dblValue))
|
||||
{
|
||||
var retV2Min = Comparer<TValue>.Default.Compare(Value, _minimun);
|
||||
var retV2Max = Comparer<TValue>.Default.Compare(Value, _maximun);
|
||||
|
||||
if (retV2Min < 0 || retV2Max > 0)
|
||||
{
|
||||
IsValid = false;
|
||||
ValidationError = $"actual value ({_value}) is outside the range of {_minimun} to {_maximun}";
|
||||
}
|
||||
else
|
||||
{
|
||||
IsValid = true;
|
||||
ValidationError = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsValid = false;
|
||||
ValidationError = "Format error: not a number";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using ExtendedGrid.Microsoft.Windows.Controls;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
using Sicentury.Core;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
||||
{
|
||||
public abstract class Param : BindableBase, IParam
|
||||
{
|
||||
#region Variables
|
||||
|
||||
protected string _controlName;
|
||||
protected string _displayName;
|
||||
protected string _unitName;
|
||||
protected MenuPermissionEnum _permStep;
|
||||
protected MenuPermissionEnum _permColumn;
|
||||
protected bool _isEnabled;
|
||||
protected bool _isHideValue;
|
||||
protected string _hiddenValueMasking;
|
||||
protected bool _isSaved;
|
||||
protected bool _isColumnSelected;
|
||||
protected Visibility _visibility;
|
||||
protected bool _isValid;
|
||||
protected string _validationError;
|
||||
protected bool _isEqualsToPrevious;
|
||||
protected bool _isHighlighted;
|
||||
protected bool _isCalculatorError;
|
||||
protected bool _isCompareDifferent;
|
||||
protected SolidColorBrush _stepColorBrush;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected Param()
|
||||
{
|
||||
_isSaved = true;
|
||||
IsEnabled = true;
|
||||
_isValid = true;
|
||||
_validationError = null;
|
||||
_isEqualsToPrevious = true;
|
||||
_visibility = Visibility.Visible;
|
||||
_isHighlighted = false;
|
||||
_hiddenValueMasking = "-";
|
||||
StepDoneCallback = (value) =>
|
||||
{
|
||||
IsEnabled = !value;
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数所在的列的访问权限变更时,执行的回调函数。
|
||||
/// </summary>
|
||||
public Action<Param> ColumnPermChangedCallback { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当step的执行状态变更时,执行的回调函数。
|
||||
/// </summary>
|
||||
public Action<bool> StepDoneCallback { get; set; }
|
||||
|
||||
public Func<Param, bool> Check { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RecipeStep Parent { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DataGridRow RowOwner { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DataGridColumn ColumnOwner { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IParam Previous { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IParam Next { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ControlName
|
||||
{
|
||||
get => _controlName;
|
||||
set => Set(ref _controlName, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DisplayName
|
||||
{
|
||||
get => _displayName;
|
||||
set => Set(ref _displayName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前参数的单位。
|
||||
/// </summary>
|
||||
public string UnitName
|
||||
{
|
||||
get => _unitName;
|
||||
set => Set(ref _unitName, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public MenuPermissionEnum StepPermission
|
||||
{
|
||||
get => _permStep;
|
||||
set => Set(ref _permStep, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public MenuPermissionEnum ColumnPermission
|
||||
{
|
||||
get => _permColumn;
|
||||
set => Set(ref _permColumn, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual MenuPermissionEnum Permission => (MenuPermissionEnum)Math.Min((int)StepPermission, (int)ColumnPermission);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsHideValue
|
||||
{
|
||||
get => _isHideValue;
|
||||
set => Set(ref _isHideValue, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string HiddenValueMasking
|
||||
{
|
||||
get => _hiddenValueMasking;
|
||||
set => Set(ref _hiddenValueMasking, value);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set => Set(ref _isEnabled, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual bool IsSaved
|
||||
{
|
||||
get => _isSaved;
|
||||
set => Set(ref _isSaved, value);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsEqualsToPrevious
|
||||
{
|
||||
get => _isEqualsToPrevious;
|
||||
set => Set(ref _isEqualsToPrevious, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsValid
|
||||
{
|
||||
get => _isValid;
|
||||
internal set => Set(ref _isValid, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ValidationError
|
||||
{
|
||||
get => _validationError;
|
||||
protected set => Set(ref _validationError, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsHighlighted
|
||||
{
|
||||
get => _isHighlighted;
|
||||
private set => Set(ref _isHighlighted, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsCalculatorError
|
||||
{
|
||||
get => _isCalculatorError;
|
||||
private set => Set(ref _isCalculatorError, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recipe对比的不同参数部分属性标志,未添加到IParam接口中
|
||||
/// </summary>
|
||||
public bool IsCompareDifferent
|
||||
{
|
||||
get => _isCompareDifferent;
|
||||
private set
|
||||
{
|
||||
_isCompareDifferent = value;
|
||||
StepBackgroundColorBrush =
|
||||
value ? new SolidColorBrush(Colors.LightSalmon) : new SolidColorBrush(Colors.Transparent);
|
||||
|
||||
Set(ref _isCompareDifferent, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsColumnSelected
|
||||
{
|
||||
get => _isColumnSelected;
|
||||
set => Set(ref _isColumnSelected, value);
|
||||
}
|
||||
|
||||
public Visibility Visible
|
||||
{
|
||||
get => _visibility;
|
||||
set => Set(ref _visibility, value);
|
||||
}
|
||||
|
||||
public bool EnableConfig { get; set; }
|
||||
|
||||
public bool EnableTolerance { get; set; }
|
||||
|
||||
public Visibility StepCheckVisibility { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 差异对比时单个参数栏的背景
|
||||
/// </summary>
|
||||
public SolidColorBrush StepBackgroundColorBrush
|
||||
{
|
||||
get => _stepColorBrush;
|
||||
set => Set(ref _stepColorBrush, value);
|
||||
}
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// 高亮显示当前参数。
|
||||
/// </summary>
|
||||
public void Highlight()
|
||||
{
|
||||
IsHighlighted = true;
|
||||
}
|
||||
|
||||
public void SetCalculatorError()
|
||||
{
|
||||
StepBackgroundColorBrush = new SolidColorBrush(Colors.Red);
|
||||
IsCalculatorError = true;
|
||||
}
|
||||
|
||||
public void ResetCalculatorError()
|
||||
{
|
||||
StepBackgroundColorBrush = new SolidColorBrush(Colors.Transparent);
|
||||
IsCalculatorError = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 高亮背景色显示,Recipe对比的不同参数部分。未添加到IParam接口中,IsCompareDifferent属性是参数对比标志位
|
||||
/// </summary>
|
||||
public void CompareDifferent()
|
||||
{
|
||||
IsCompareDifferent = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消高亮显示。
|
||||
/// </summary>
|
||||
public void ResetHighlight()
|
||||
{
|
||||
IsHighlighted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将当前参数所对应的前序、后续参数链表转换为数组。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual List<IParam> Flatten()
|
||||
{
|
||||
if (Previous != null)
|
||||
return Previous.Flatten();
|
||||
|
||||
var list = new List<IParam>();
|
||||
IParam p = this;
|
||||
while (p != null)
|
||||
{
|
||||
list.Add(p);
|
||||
p = p.Next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验当前参数的数值。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual void Validate()
|
||||
{
|
||||
IsValid = true;
|
||||
ValidationError = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复位当前参数数值
|
||||
/// </summary>
|
||||
public virtual void Reset()
|
||||
{
|
||||
IsSaved = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将当前参数标记为已保存状态。
|
||||
/// </summary>
|
||||
public virtual void Save()
|
||||
{
|
||||
IsSaved = true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{DisplayName}, ControlName={ControlName}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
||||
{
|
||||
public abstract class ParamBaseWithGenericValue<TValue> : Param, IValueParam
|
||||
{
|
||||
#region Variables
|
||||
|
||||
public event EventHandler<object> OnValueChanged;
|
||||
|
||||
protected TValue _value;
|
||||
protected TValue _valueSnapshot;
|
||||
protected IParam _previous;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected ParamBaseWithGenericValue()
|
||||
{
|
||||
}
|
||||
|
||||
protected ParamBaseWithGenericValue(TValue initValue) : this()
|
||||
{
|
||||
if (initValue.GetType() != typeof(TValue))
|
||||
initValue = default;
|
||||
|
||||
_value = initValue;
|
||||
_valueSnapshot = initValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
|
||||
public virtual TValue Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
Set(ref _value, value);
|
||||
|
||||
ColumnPermChangedCallback?.Invoke(this);
|
||||
|
||||
_isSaved = _value.Equals(_valueSnapshot);
|
||||
OnPropertyChanged(nameof(IsSaved));
|
||||
|
||||
// 当Value发生变化时,要办一下事项,以及时刷新UI状态。
|
||||
CheckValueEqualityWithPrevious();
|
||||
Validate();
|
||||
}
|
||||
}
|
||||
|
||||
public override IParam Previous
|
||||
{
|
||||
get => _previous;
|
||||
set
|
||||
{
|
||||
//! 如果前序参数的Value发生了变化,则需要通知我进行比较,以确定我的Value是否和前序参数的Value相等。
|
||||
|
||||
// 注销之前注册的事件。
|
||||
if (_previous is Param preParam)
|
||||
preParam.PropertyChanged -= OnPreviousParamValueChanged;
|
||||
|
||||
_previous = value;
|
||||
|
||||
// 注册事件.
|
||||
if (_previous is Param p)
|
||||
{
|
||||
p.PropertyChanged += OnPreviousParamValueChanged;
|
||||
|
||||
// 立即执行一次比较
|
||||
CheckValueEqualityWithPrevious();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override IParam Next { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// 判断Value属性是否相等。
|
||||
/// </summary>
|
||||
/// <param name="v1"></param>
|
||||
/// <param name="v2"></param>
|
||||
/// <returns></returns>
|
||||
protected static bool IsTValueEqual(TValue v1, TValue v2)
|
||||
{
|
||||
return Comparer<TValue>.Default.Compare(v1, v2) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查我的Value是否和前序参数的Value相等。
|
||||
/// </summary>
|
||||
private void CheckValueEqualityWithPrevious()
|
||||
{
|
||||
if (_previous is ParamBaseWithGenericValue<TValue> valuedParam)
|
||||
{
|
||||
IsEqualsToPrevious = IsTValueEqual(_value, valuedParam.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前序参数的Value发生变化时,判断其是否和我的Value属性相等。
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnPreviousParamValueChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Value) && _previous is ParamBaseWithGenericValue<TValue> valuedParam)
|
||||
{
|
||||
IsEqualsToPrevious = IsTValueEqual(_value, valuedParam.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复位当前数据
|
||||
/// </summary>
|
||||
public override void Reset()
|
||||
{
|
||||
Value = _valueSnapshot;
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据。
|
||||
/// </summary>
|
||||
public override void Save()
|
||||
{
|
||||
_valueSnapshot = _value;
|
||||
base.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual object GetValue()
|
||||
{
|
||||
if (Permission == MenuPermissionEnum.MP_NONE)
|
||||
//throw new PermissionException(Permission);
|
||||
return null;
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
public void SetValue(object value)
|
||||
{
|
||||
if (Permission != MenuPermissionEnum.MP_READ_WRITE)
|
||||
//throw new PermissionException(Permission);
|
||||
return;
|
||||
|
||||
HandleSetValue(value);
|
||||
OnValueChanged?.Invoke(this, value);
|
||||
}
|
||||
|
||||
protected virtual void HandleSetValue(object value)
|
||||
{
|
||||
Debug.Assert(value.GetType() == typeof(TValue), "The type of value does not match to my type.");
|
||||
Value = (TValue)value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()}, Value={_value}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user