2023-05-10 16:21:45 +08:00
|
|
|
|
using System;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows;
|
2023-05-10 16:21:45 +08:00
|
|
|
|
using Caliburn.Micro.Core;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using ExtendedGrid.Microsoft.Windows.Controls;
|
2023-09-05 00:12:08 +08:00
|
|
|
|
using MECF.Framework.Common.Account;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-05-10 16:21:45 +08:00
|
|
|
|
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
public abstract class Param : PropertyChangedBase, IParam
|
|
|
|
|
{
|
|
|
|
|
#region Variables
|
|
|
|
|
|
|
|
|
|
protected string _name;
|
|
|
|
|
protected string _displayName;
|
|
|
|
|
protected string _unitName;
|
2023-06-16 15:48:27 +08:00
|
|
|
|
protected MenuPermissionEnum _perm;
|
|
|
|
|
protected MenuPermissionEnum _permStep;
|
|
|
|
|
protected MenuPermissionEnum _permColumn;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
protected bool _isEnabled;
|
|
|
|
|
protected bool _isSaved;
|
|
|
|
|
protected bool _isColumnSelected;
|
|
|
|
|
protected Visibility _visibility;
|
2023-06-16 09:51:51 +08:00
|
|
|
|
protected bool _isValid;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
protected string _validationError;
|
|
|
|
|
protected bool _isEqualsToPrevious;
|
|
|
|
|
protected bool _isHighlighted;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
protected Param()
|
|
|
|
|
{
|
|
|
|
|
_isSaved = true;
|
|
|
|
|
_isEnabled = true;
|
2023-06-16 09:51:51 +08:00
|
|
|
|
_isValid = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
_validationError = null;
|
|
|
|
|
_isEqualsToPrevious = true;
|
|
|
|
|
_visibility = Visibility.Visible;
|
|
|
|
|
_isHighlighted = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置或返回当前参数所在的列的访问权限变更时,执行的回调函数。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Action<Param> ColumnPermChangedCallback { get; set; }
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
public Func<Param, bool> Check { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public RecipeStep Parent { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public DataGridRow RowOwner { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public DataGridColumn ColumnOwner { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public virtual IParam Previous { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public virtual IParam Next { get; set; }
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get => _name;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_name = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public string DisplayName
|
|
|
|
|
{
|
|
|
|
|
get => _displayName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_displayName = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 19:19:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置或返回当前参数的单位。
|
|
|
|
|
/// </summary>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public string UnitName
|
|
|
|
|
{
|
|
|
|
|
get => _unitName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_unitName = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-06-16 15:48:27 +08:00
|
|
|
|
public MenuPermissionEnum StepPermission
|
2023-06-16 13:43:26 +08:00
|
|
|
|
{
|
2023-06-16 15:48:27 +08:00
|
|
|
|
get => _permStep;
|
2023-06-16 13:43:26 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-06-16 15:48:27 +08:00
|
|
|
|
_permStep = value;
|
|
|
|
|
NotifyOfPropertyChange(nameof(Permission));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public MenuPermissionEnum ColumnPermission
|
|
|
|
|
{
|
|
|
|
|
get => _permColumn;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_permColumn = value;
|
|
|
|
|
NotifyOfPropertyChange(nameof(Permission));
|
2023-06-16 13:43:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-16 15:48:27 +08:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public virtual MenuPermissionEnum Permission => (MenuPermissionEnum)Math.Min((int)StepPermission, (int)ColumnPermission);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _isEnabled;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isEnabled = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public virtual bool IsSaved
|
|
|
|
|
{
|
|
|
|
|
get => _isSaved;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isSaved = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool IsEqualsToPrevious
|
|
|
|
|
{
|
|
|
|
|
get => _isEqualsToPrevious;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isEqualsToPrevious = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-06-16 09:51:51 +08:00
|
|
|
|
public bool IsValid
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
get => _isValid;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
internal set
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
_isValid = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public string ValidationError
|
|
|
|
|
{
|
|
|
|
|
get => _validationError;
|
|
|
|
|
protected set
|
|
|
|
|
{
|
|
|
|
|
_validationError = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 13:43:26 +08:00
|
|
|
|
/// <inheritdoc />
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool IsHighlighted
|
|
|
|
|
{
|
|
|
|
|
get => _isHighlighted;
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
_isHighlighted = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsColumnSelected
|
|
|
|
|
{
|
|
|
|
|
get => _isColumnSelected;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isColumnSelected = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Visibility Visible
|
|
|
|
|
{
|
|
|
|
|
get => _visibility;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_visibility = value;
|
2023-06-15 14:53:21 +08:00
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool EnableConfig { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool EnableTolerance { get; set; }
|
|
|
|
|
|
|
|
|
|
public Visibility StepCheckVisibility { get; set; }
|
2023-06-15 19:19:41 +08:00
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 高亮显示当前参数。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Highlight()
|
|
|
|
|
{
|
|
|
|
|
IsHighlighted = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消高亮显示。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void ResetHighlight()
|
|
|
|
|
{
|
|
|
|
|
IsHighlighted = false;
|
|
|
|
|
}
|
2023-06-16 15:48:27 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <summary>
|
2023-06-15 19:19:41 +08:00
|
|
|
|
/// 将当前参数所对应的前序、后续参数链表转换为数组。
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// </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>
|
2023-06-15 19:19:41 +08:00
|
|
|
|
/// 校验当前参数的数值。
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public virtual void Validate()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
IsValid = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
ValidationError = "";
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 19:19:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将当前参数标记为已保存状态。
|
|
|
|
|
/// </summary>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public virtual void Save()
|
|
|
|
|
{
|
|
|
|
|
IsSaved = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{DisplayName}, ControlName={Name}";
|
|
|
|
|
}
|
2023-06-16 16:32:39 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
#endregion
|
2023-06-15 19:19:41 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|