[UI.Client]

RecipeEditor的EditMode枚举增加EditWhitelist项目。
修正RecipeEditor中,当某步骤权限设置为None时,DataGrid中没有隐藏相应步骤的问题。
移除NumParam.cs。
优化一些列对象,在10号机测试可运行。

已知问题:
RecipeEditor的Expander不能折叠。
当某步骤权限配置为None时,应该隐藏数值;隐藏列可能造成用户识别困难。
This commit is contained in:
Liang Su 2023-06-15 19:19:41 +08:00
parent b22c3f3fba
commit 69044332e6
18 changed files with 755 additions and 694 deletions

View File

@ -6,6 +6,7 @@
New,
ReName,
Edit,
Normal
Normal,
EditWhitelist
}
}

View File

@ -960,7 +960,7 @@
Width="100"
Height="30"
IsEnabled="{Binding EnableCellPermButton}"
Content="{Binding IsCellAccessPermissionEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}"
Content="{Binding CurrentRecipe.IsAccessibleWhitelistEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}"
Margin="0,0,0,0"
ToolTip="Cell-Access-Perm Edit Mode"
micro:Message.Attach="SwitchCellAccessPermEditMode()"/>

View File

@ -9,16 +9,13 @@ using OpenSEMI.ClientBase.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Action = System.Action;
using System.IO;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
@ -200,8 +197,6 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
private bool IsChanged => _editMode == EditMode.Edit || CurrentRecipe.IsChanged;
public List<EditorDataGridTemplateColumnBase> Columns { get; set; }
public Dictionary<string, List<EditorDataGridTemplateColumnBase>> DicColunms { get; set; }
public bool EnableNew { get; set; }
@ -354,17 +349,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
roleManager.Initialize();
//得到当前登录的RoleItem
var roleItem = roleManager.GetRoleByName(BaseApp.Instance.UserContext.RoleName);
var menuPermission = new MenuPermission();
menuPermission.ParsePermission(roleItem.Role.MenuPermission);
foreach (var col in Columns)
{
if (col.ControlName == "StepNo")
continue;
RecipeFormatBuilder.SetPermission(col, menuPermission);
}
var role = roleManager.GetRoleByName(BaseApp.Instance.UserContext.RoleName);
CurrentRecipe.UpdatePermission(role);
UpdateView();
@ -412,17 +399,6 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
View = view;
base.OnViewLoaded(view);
//RecipeFormatBuilder.ApplyTemplate((UserControl)view, Columns);
var u = (RecipeEditorView)view;
u.dgCustom.ClearColumns();
foreach (var col in Columns)
{
col.Header = col;
u.dgCustom.AddColumn(col);
}
}
public void TabSelectionChanged()
@ -462,22 +438,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
}
SelectedChamber = Chambers[0];
if (DicColunms.Keys.Contains(CurrentProcessType))
{
Columns = DicColunms[CurrentProcessType];
}
else
{
Columns = _columnBuilder.Build($"{CurrentChamberType}\\{CurrentProcessType}", SelectedChamber, true,
BaseApp.Instance.UserContext.RoleName);
DicColunms[CurrentProcessType] = Columns;
}
CurrentRecipe = new RecipeData(_recipeGasFlowCalculator);
CurrentRecipe.RecipeChamberType = _columnBuilder.RecipeChamberType;
CurrentRecipe.RecipeVersion = _columnBuilder.RecipeVersion;
CurrentRecipe.BuildFormat($"{CurrentChamberType}\\{CurrentProcessType}", SelectedChamber, BaseApp.Instance.UserContext.RoleName);
CurrentRecipe.OnValidated += (sender, args) =>
{
ErrorsCount = CurrentRecipe.ValidationErrorCount;
@ -515,7 +478,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
IsLoading = true;
await CurrentRecipe.ChangeChamber(Columns
await CurrentRecipe.ChangeChamber(CurrentRecipe.Columns
, _columnBuilder.Configs, SelectedChamber, GetLoadingDispatcher());
IsLoading = false;
@ -545,7 +508,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
if (node != null && node.IsFile)
{
await LoadData(node.PrefixPath, node.FullPath);
await LoadRecipe(node.PrefixPath, node.FullPath);
}
else
{
@ -1164,7 +1127,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
return;
}
await LoadData(CurrentRecipe.PrefixPath, CurrentRecipe.Name);
await LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name);
CurrentRecipe.Validate();
UpdateView();
@ -1368,30 +1331,6 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
#region Steps
/// <summary>
/// 展开DataGrid列组。
/// </summary>
/// <param name="col"></param>
public void ExpandColumnsGroup(ExpanderColumn col)
{
foreach (var subCol in col.ChildColumns)
{
subCol.UpdateVisibility();
}
}
/// <summary>
/// 折叠DataGrid列组。
/// </summary>
/// <param name="col"></param>
public void CollapseColumnsGroup(ExpanderColumn col)
{
foreach (var subCol in col.ChildColumns)
{
subCol.Visibility = Visibility.Collapsed;
}
}
public void SaveRecipe()
{
/*if (Save(CurrentRecipe, false))
@ -1481,10 +1420,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
if (result)
{
recipe.DataSaved();
recipe.MarkAsSaved();
_editMode = EditMode.Normal;
UpdateView();
}
else
@ -1497,84 +1434,54 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
public void AddStep()
{
Columns.Clear();
//add时重新从配方中加载数据
Columns = _columnBuilder.Build($"{CurrentChamberType}\\{CurrentProcessType}", SelectedChamber, true,BaseApp.Instance.UserContext.RoleName);
CurrentRecipe.Steps.Add(CurrentRecipe.CreateStep(Columns));
CurrentRecipe.AddStep();
if (_editMode != EditMode.New && _editMode != EditMode.ReName)
_editMode = EditMode.Edit;
CurrentRecipe.Validate();
UpdateView();
}
public void InsertStepToLeft()
{
if (SelectedRecipeSteps.Count != 1)
if (CurrentRecipe == null)
return;
var stepNo = SelectedRecipeSteps[0]?.StepNo;
if (RecipeStep.ValidateStepNo(stepNo, out var vStepNo) == false)
if (CurrentRecipe.Steps.SelectedSteps.Count != 1)
return;
var index = vStepNo - RecipeStep.START_INDEX;
var step = CurrentRecipe.Steps.SelectedSteps[0];
CurrentRecipe.InsertToLeft(step);
if (_editMode != EditMode.New && _editMode != EditMode.ReName)
_editMode = EditMode.Edit;
CurrentRecipe.Steps.Insert(index, CurrentRecipe.CreateStep(Columns));
UpdateView();
}
public void InsertStepToRight()
{
if (SelectedRecipeSteps.Count != 1)
if (CurrentRecipe == null)
return;
var stepNo = SelectedRecipeSteps[0]?.StepNo;
if (RecipeStep.ValidateStepNo(stepNo, out var vStepNo) == false)
if(CurrentRecipe.Steps.SelectedSteps.Count != 1)
return;
var index = vStepNo - RecipeStep.START_INDEX;
var step = CurrentRecipe.Steps.SelectedSteps[0];
CurrentRecipe.InsertToRight(step);
if (_editMode != EditMode.New && _editMode != EditMode.ReName)
_editMode = EditMode.Edit;
if (index < _currentRecipe.Steps.Count - 1)
CurrentRecipe.Steps.Insert(index + 1, CurrentRecipe.CreateStep(Columns));
else
CurrentRecipe.Steps.Add(CurrentRecipe.CreateStep(Columns));
UpdateView();
}
private readonly RecipeStepCollection _copySteps =
new RecipeStepCollection();
private readonly Dictionary<string, ObservableCollection<RecipeStep>> _popCopySteps =
new Dictionary<string, ObservableCollection<RecipeStep>>();
/// <summary>
/// <summary>
/// 拷贝所有选中的Steps。
/// </summary>
/// <param name="steps"></param>
public void CopyStep()
{
_copySteps.Clear();
_popCopySteps.Clear();
if (SelectedRecipeSteps == null || SelectedRecipeSteps.Count <= 0)
return;
foreach (var step in SelectedRecipeSteps)
_copySteps.Add(_currentRecipe.CloneStep(Columns, step));
CurrentRecipe.ValidLoopData();
CurrentRecipe?.CopySteps();
}
/// <summary>
@ -1601,31 +1508,14 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
/// <returns></returns>
private async Task Paste(bool isToLeft)
{
if (SelectedRecipeSteps == null || SelectedRecipeSteps.Count != 1)
if (CurrentRecipe == null)
return;
if (_copySteps.Count <= 0)
return;
await CurrentRecipe.Paste(isToLeft);
if (_editMode != EditMode.New && _editMode != EditMode.ReName)
_editMode = EditMode.Edit;
var stepNo = SelectedRecipeSteps[0].StepNo;
if (RecipeStep.ValidateStepNo(stepNo, out var vStepNo) == false)
return;
foreach (var t in _copySteps)
{
var cloned = CurrentRecipe.CloneStep(Columns, t);
var pos = isToLeft ? vStepNo - RecipeStep.START_INDEX : vStepNo;
await Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
(Action)(() => { CurrentRecipe.Steps.Insert(pos, cloned); }));
}
CurrentRecipe.ValidLoopData();
CurrentRecipe.Validate();
UpdateView();
}
@ -1663,16 +1553,15 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
/// </summary>
public void DeleteStep()
{
if (CurrentRecipe == null)
return;
CurrentRecipe.DeleteSteps();
if (_editMode != EditMode.New && _editMode != EditMode.ReName)
_editMode = EditMode.Edit;
for (var i = SelectedRecipeSteps.Count - 1; i >= 0; i--)
{
_currentRecipe.Steps.Remove(SelectedRecipeSteps[i]);
}
CurrentRecipe.Validate();
UpdateView();
}
private void CreateValidationDetailWindow()
@ -1745,13 +1634,18 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
var mode = CurrentRecipe.IsAccessibleWhitelistEditMode;
if (mode)
{
CurrentRecipe.LeaveAccessibleWhitelistEditMode();
_editMode = EditMode.Normal;
}
else
{
if (!CurrentRecipe.EnterAccessibleWhitelistEditMode(out var reason))
{
DialogBox.ShowError($"Unable to enter cell accessible whitelist edit mode, {reason}");
}
_editMode = EditMode.EditWhitelist;
}
UpdateView();
@ -1781,7 +1675,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
}
private async Task LoadData(string prefixPath, string recipeName)
private async Task LoadRecipe(string prefixPath, string recipeName)
{
IsLoading = true;
@ -1799,14 +1693,10 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
return;
}
CurrentRecipe.RecipeChamberType = _columnBuilder.RecipeChamberType;
CurrentRecipe.RecipeVersion = _columnBuilder.RecipeVersion;
await CurrentRecipe.InitData(prefixPath, recipeName, recipeContent, Columns,
_columnBuilder.Configs, SelectedChamber, GetLoadingDispatcher());
await CurrentRecipe.LoadFile(prefixPath, recipeName, recipeContent, SelectedChamber,
GetLoadingDispatcher());
_editMode = EditMode.Normal;
IsLoading = false;
}
@ -1843,7 +1733,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
EnableReload = true;
}
else if (CurrentRecipe.IsAccessibleWhitelistEditMode)
//else if (CurrentRecipe.IsAccessibleWhitelistEditMode)
else if (_editMode == EditMode.EditWhitelist)
{
EnableNew = false;
EnableReName = false;

View File

@ -105,7 +105,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
});
}
param.IsSaved = true;
param.Save();
param.Parent = Params;
Params.Add(param);

View File

@ -593,7 +593,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
foreach (var parameters in seq.Steps)
{
parameters.Apply(param => param.IsSaved = true);
parameters.Apply(param => param.Save());
}
editMode = EditMode.Normal;
IsSavedDesc = true;
@ -766,8 +766,6 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{
param.FileName = path;
}
param.IsSaved = false;
}
}

View File

@ -765,7 +765,6 @@
<Compile Include="RecipeEditorLib\RecipeModel\Params\ExpanderParam.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\IntParam.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\MultipleSelectParam.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\NumParam.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\NumParamBase.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\ParamBaseWithGenericValue.cs" />
<Compile Include="RecipeEditorLib\RecipeModel\Params\PopSettingParam.cs" />

View File

@ -18,13 +18,14 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
public string ControlName { get; set; }
public string DisplayName { get; set; }
public string RelatedParameters { get; set; }
public bool IsChecked
{
get { return this.isChecked; }
set
{
this.isChecked = value;
if (this.parent!=null)
if (this.parent != null)
this.parent.IsSaved = false;
}
}

View File

@ -10,12 +10,14 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<!-- #region Converters -->
<converters:BoolCollapsedConverter x:Key="BoolCollapsedConverter"/>
<cv:ParamToCellTooltipConverter x:Key="CellTooltipConverter"/>
<cv:IsHighlightedToBorderThickness x:Key="IsHighlightedToBorderThickness"/>
<cv:IsHighlightedToBorderBrush x:Key="IsHighlightedToBorderBrush"/>
@ -513,19 +515,9 @@
VerticalContentAlignment="Stretch"
FontSize="14"
Header="{Binding DisplayName}"
IsExpanded="{Binding IsExpanded}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Expanded">
<micro:ActionMessage MethodName="ExpandColumnsGroup">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
<i:EventTrigger EventName="Collapsed">
<micro:ActionMessage MethodName="CollapseColumnsGroup">
<micro:Parameter Value="{Binding}" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
IsExpanded="{Binding IsExpanded}"
Expanded="Expander_OnExpanded"
Collapsed="Expander_OnCollapsed">
</Expander>
<Border.LayoutTransform>
<TransformGroup>
@ -590,6 +582,10 @@
<Setter Property="RowStyle">
<Setter.Value>
<Style TargetType="controls:DataGridRow">
<Setter
Property="Visibility"
Value="{Binding IsVisible,
Converter={StaticResource BoolCollapsedConverter}}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Background" Value="{StaticResource DataGrid_BG_Selected}"/>

View File

@ -57,6 +57,11 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
}
};
// 创建DataGrid列
dg.ClearColumns();
foreach (var col in recipe.Columns)
dg.AddColumn(col);
}
else
dg.dgCustom.ItemsSource = null;
@ -100,37 +105,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
}
#endregion
#region IsCellAccessPermissionEditMode
/*
public static readonly DependencyProperty IsAccessibleWhitelistEditModeProperty = DependencyProperty.Register(
nameof(IsAccessibleWhitelistEditMode), typeof(bool), typeof(DataGridRecipe), new PropertyMetadata(default(bool), IsAccessibleWhitelistEditModePropertyChangedCallback));
private static void IsAccessibleWhitelistEditModePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is DataGridRecipe dg)
{
if (e.NewValue is bool value)
dg.dgCustom.IsAccessibleWhitelistEditMode = value;
else
dg.dgCustom.IsAccessibleWhitelistEditMode = false;
}
}
/// <summary>
/// 设置或返回编辑器是否处于单元格访问权限编辑模式。
/// </summary>
public bool IsAccessibleWhitelistEditMode
{
get => (bool)GetValue(IsAccessibleWhitelistEditModeProperty);
private set => SetValue(IsAccessibleWhitelistEditModeProperty, value);
}
*/
#endregion
#endregion
#region Methods
@ -165,7 +140,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
}
}
public void ClearColumns()
private void ClearColumns()
{
dgCustom.Columns.Clear();
}
@ -173,7 +148,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
/// <summary>
/// 生成编辑器的列。
/// </summary>
public void AddColumn(EditorDataGridTemplateColumnBase col)
private void AddColumn(EditorDataGridTemplateColumnBase col)
{
// 设置ColumnHeaderTemplate和DataGridCellTemplate
if (string.IsNullOrEmpty(col.StringCellTemplate) == false)
@ -269,8 +244,31 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
}
}
private void Expander_OnExpanded(object sender, RoutedEventArgs e)
{
if (sender is Expander expander && expander.DataContext is ExpanderColumn col)
{
foreach (var subCol in col.ChildColumns)
{
subCol.UpdateVisibility();
}
}
}
private void Expander_OnCollapsed(object sender, RoutedEventArgs e)
{
if (sender is Expander expander && expander.DataContext is ExpanderColumn col)
{
foreach (var subCol in col.ChildColumns)
{
subCol.Visibility = Visibility.Collapsed;
}
}
}
#endregion
}
}

View File

@ -1,6 +1,6 @@
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
{
public class ExpanderParam : ParamBaseWithGenericValue<object>
public class ExpanderParam : Param
{
}

View File

@ -9,7 +9,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
{
this.Options = new ObservableCollection<MultipleSelectColumn.Option>();
col.CloneOptions(this).ForEach(opt => this.Options.Add(opt));
this.IsSaved = true;
IsSaved = true;
}
public ObservableCollection<MultipleSelectColumn.Option> Options { get; set; }

View File

@ -1,40 +0,0 @@
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
{
public class NumParam : Param
{
private int _value;
public int Value
{
get { return this._value; }
set
{
this._value = value;
if (this.Feedback != null)
this.Feedback(this);
this.NotifyOfPropertyChange("Value");
}
}
private double _minimun;
public double Minimun
{
get { return this._minimun; }
set
{
this._minimun = value;
this.NotifyOfPropertyChange("Minimun");
}
}
private double _maximun;
public double Maximun
{
get { return this._maximun; }
set
{
this._maximun = value;
this.NotifyOfPropertyChange("Maximun");
}
}
}
}

View File

@ -59,7 +59,12 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
public virtual IParam Next { get; set; }
/// <summary>
/// 设置或返回当前参数的控制名称。
/// <remarks>
/// 对应RecipeFormat.xml文件中的ControlName。
/// </remarks>
/// </summary>
public string Name
{
get => _name;
@ -70,7 +75,9 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
}
/// <summary>
/// 设置或返回当前参数的显示名称。
/// </summary>
public string DisplayName
{
get => _displayName;
@ -81,7 +88,9 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
}
/// <summary>
/// 设置或返回当前参数的单位。
/// </summary>
public string UnitName
{
get => _unitName;
@ -103,6 +112,9 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
}
/// <summary>
/// 设置或返回当前参数是否为已保存状态。
/// </summary>
public virtual bool IsSaved
{
get => _isSaved;
@ -115,8 +127,11 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
/// <summary>
/// 是否和前序值相等。
/// 设置或返回当前参数的数值是否和前序参数的数值相等。
/// </summary>
/// <remarks>
/// 该属性用于渲染DataGrid单元格文本颜色当不等于前序参数数值时当前参数显示为绿色。
/// </remarks>
public bool IsEqualsToPrevious
{
get => _isEqualsToPrevious;
@ -128,7 +143,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
/// <summary>
/// 是否通过验证。
/// 返回当前参数是否通过验证。
/// </summary>
public bool IsValidated
{
@ -141,7 +156,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
/// <summary>
/// 校验错误原因。
/// 返回当前参数校验错误原因。
/// </summary>
public string ValidationError
{
@ -179,7 +194,6 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
}
public bool IsColumnSelected
{
get => _isColumnSelected;
@ -205,7 +219,9 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
public bool EnableTolerance { get; set; }
public Visibility StepCheckVisibility { get; set; }
#region Methods
/// <summary>
/// 高亮显示当前参数。
/// </summary>
@ -227,7 +243,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
#region Methods
/// <summary>
/// 将参数链表转换为数组。
/// 将当前参数所对应的前序、后续参数链表转换为数组。
/// </summary>
/// <returns></returns>
public virtual List<IParam> Flatten()
@ -247,7 +263,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
/// <summary>
/// 校验数据
/// 校验当前参数的数值
/// </summary>
/// <returns></returns>
public virtual void Validate()
@ -256,14 +272,21 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
ValidationError = "";
}
/// <summary>
/// 将当前参数标记为已保存状态。
/// </summary>
public virtual void Save()
{
IsSaved = true;
}
/// <summary>
/// 获取当前参数的数值。
/// </summary>
/// <returns></returns>
public virtual object GetValue()
{
return "Not Support";
return default;
}
public void SetValue(object value)
@ -283,5 +306,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
}
#endregion
#endregion
}
}

View File

@ -40,7 +40,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
set
{
_value = value;
NotifyOfPropertyChange(nameof(Value));
NotifyOfPropertyChange();
Feedback?.Invoke(this);

View File

@ -18,6 +18,12 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
{
public class RecipeFormatBuilder
{
/// <summary>
/// 步骤起始编号。
/// </summary>
public const int STEP_INDEX_BASE = 1;
public const string SPEC_COL_STEPNO = "StepNo";
public const string SPEC_COL_STEPUID = "StepUid";
@ -249,6 +255,14 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
return ContentInfos;
}
/// <summary>
/// 从指定的RecipeFormat.xml文件创建Recipe格式。
/// </summary>
/// <param name="path"></param>
/// <param name="module"></param>
/// <param name="defaultCellEnable"></param>
/// <param name="roleName"></param>
/// <returns></returns>
public List<EditorDataGridTemplateColumnBase> Build(string path, string module = "PM1", bool defaultCellEnable = true, string roleName = "管理员")
{
//XML文档读取格式由 $"PM.{module}.RecipeConfig 改为 $"RecipeConfig RecipeConfig参数放在Sic层级下和PM同级别
@ -637,6 +651,9 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
}
}
// Header属性指向列对象使用HeaderTemplate模板渲染Header
col.Header = col;
// 单元格是否可编辑?
var isCellEditable = step.Attributes["IsColumnEditable"]?.Value;
if (string.IsNullOrEmpty(isCellEditable) == false && isCellEditable.ToLower() == "false")
@ -645,10 +662,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
col.IsReadOnly = true;
col.StringCellEditingTemplate = "";
}
if(col.ControlName != "StepUid") // 如果当前列是StepUid列则不受权限控制默认不显示此列
SetPermission(col, menuPermission); // 设置本列权限
colExpander.ChildColumns.Add(col); // 将本列追加到Expander中
columns.Add(col);
}
@ -786,6 +800,11 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
/// <returns></returns>
public static void SetPermission(EditorDataGridTemplateColumnBase column, MenuPermission permission)
{
// StepNo列和StepUid列不受权限控制
if (column.ControlName == SPEC_COL_STEPUID
|| column.ControlName == SPEC_COL_STEPNO)
return;
if (column == null)
throw new ArgumentNullException(nameof(column));

View File

@ -3,32 +3,39 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
{
public class RecipeStep : ObservableCollection<Param>
{
/// <summary>
/// 步骤起始编号。
/// </summary>
public const int START_INDEX = 1;
#region Variables
private bool _isHideValue;
private bool _isProcessed;
private bool _isVisible;
/// <summary>
/// 当配方步骤的IsSaved属性发生变化时发此事件。
/// 当步骤的任意参数的<see cref="Param.IsSaved"/>属性发生变化时,引发此事件。
/// </summary>
public event EventHandler<bool> SavedStateChanged;
/// <summary>
/// 当前步骤的选择状态发生变化时,引发此事件。
/// </summary>
public event EventHandler<bool> SelectionStateChanged;
/// <summary>
/// 当前步骤的任意参数高亮状态发生变化时,引发此事件。
/// </summary>
public event EventHandler HighlightStateChanged;
/// <summary>
/// 当前步骤的气体流量计算完成后,引发此事件。
/// </summary>
public event EventHandler GasFlowCalculated;
#endregion
@ -150,6 +157,19 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
}
}
/// <summary>
/// 设置或返回当前步骤是否在DataGrid中显示。
/// </summary>
public bool IsVisible
{
get => _isVisible;
set
{
_isVisible = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsVisible)));
}
}
#endregion
#region Methods
@ -251,6 +271,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
public void CalculateGasFlow()
{
Parent?.CalculateGasFlow(this);
GasFlowCalculated?.Invoke(this, EventArgs.Empty);
}
/// <summary>
@ -311,7 +332,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
public static bool ValidateStepNo(int? stepNo, out int validatedStepNo)
{
validatedStepNo = int.MinValue;
var isValid = stepNo >= START_INDEX;
var isValid = stepNo >= RecipeFormatBuilder.STEP_INDEX_BASE;
if (isValid)
validatedStepNo = stepNo.Value;

View File

@ -20,6 +20,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
public event EventHandler<bool> OnSavedStateChanged;
public event EventHandler HighlightStateChanged;
public event EventHandler GasFlowCalculated;
private bool? _isAllStepsSelected;
private bool _isSaved;
@ -170,7 +171,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
if (stepNo == null)
return;
var index = 1;
var index = RecipeFormatBuilder.STEP_INDEX_BASE;
while (true)
{
stepNo.Value = index;
@ -300,6 +301,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
step.SavedStateChanged += ItemOnSavedStateChanged;
step.SelectionStateChanged += StepOnSelectionStateChanged;
step.HighlightStateChanged += HighlightStateChanged;
step.GasFlowCalculated += GasFlowCalculated;
if (index > 0 && index < Count - 1)
@ -340,6 +342,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
this[index].SavedStateChanged -= ItemOnSavedStateChanged;
this[index].SelectionStateChanged -= StepOnSelectionStateChanged;
this[index].HighlightStateChanged -= HighlightStateChanged;
this[index].GasFlowCalculated -= GasFlowCalculated;
}
}
@ -366,6 +369,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
x.SavedStateChanged -= ItemOnSavedStateChanged;
x.SelectionStateChanged -= StepOnSelectionStateChanged;
x.HighlightStateChanged -= HighlightStateChanged;
x.GasFlowCalculated -= GasFlowCalculated;
});
IsSaved = false;
}