From 69044332e6f96068315675b69a0e09d71c0e4c43 Mon Sep 17 00:00:00 2001 From: Liang Su Date: Thu, 15 Jun 2023 19:19:41 +0800 Subject: [PATCH] =?UTF-8?q?[UI.Client]=20RecipeEditor=E7=9A=84EditMode?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E5=A2=9E=E5=8A=A0EditWhitelist=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E3=80=82=20=E4=BF=AE=E6=AD=A3RecipeEditor=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E6=9F=90=E6=AD=A5=E9=AA=A4=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BANone=E6=97=B6=EF=BC=8CDataGrid?= =?UTF-8?q?=E4=B8=AD=E6=B2=A1=E6=9C=89=E9=9A=90=E8=97=8F=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4NumParam.cs=E3=80=82=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=88=97=E5=AF=B9=E8=B1=A1=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?10=E5=8F=B7=E6=9C=BA=E6=B5=8B=E8=AF=95=E5=8F=AF=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已知问题: RecipeEditor的Expander不能折叠。 当某步骤权限配置为None时,应该隐藏数值;隐藏列可能造成用户识别困难。 --- .../CenterViews/Editors/EditMode.cs | 3 +- .../Editors/Recipe/RecipeEditorView.xaml | 2 +- .../Editors/Recipe/RecipeEditorViewModel.cs | 187 +-- .../Editors/Sequence/SequenceData.cs | 2 +- .../Editors/Sequence/SequenceViewModel.cs | 4 +- .../MECF.Framework.UI.Client.csproj | 1 - .../CustomColumn/MultipleSelectColumn.cs | 3 +- .../DGExtension/DataGridRecipe.xaml | 22 +- .../DGExtension/DataGridRecipe.xaml.cs | 64 +- .../RecipeModel/Params/ExpanderParam.cs | 2 +- .../RecipeModel/Params/MultipleSelectParam.cs | 2 +- .../RecipeModel/Params/NumParam.cs | 40 - .../RecipeModel/Params/Param.cs | 47 +- .../Params/ParamBaseWithGenericValue.cs | 2 +- .../RecipeEditorLib/RecipeModel/RecipeData.cs | 1000 ++++++++++------- .../RecipeModel/RecipeFormatBuilder.cs | 27 +- .../RecipeEditorLib/RecipeModel/RecipeStep.cs | 35 +- .../RecipeModel/RecipeStepCollection.cs | 6 +- 18 files changed, 755 insertions(+), 694 deletions(-) delete mode 100644 MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/Params/NumParam.cs diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/EditMode.cs b/MECF.Framework.UI.Client/CenterViews/Editors/EditMode.cs index 76f65af..092042f 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/EditMode.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/EditMode.cs @@ -6,6 +6,7 @@ New, ReName, Edit, - Normal + Normal, + EditWhitelist } } diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml index d9672e9..5e45b37 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml @@ -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()"/> diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs index efd5524..0316b2b 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs @@ -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 Columns { get; set; } - public Dictionary> 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 - /// - /// 展开DataGrid列组。 - /// - /// - public void ExpandColumnsGroup(ExpanderColumn col) - { - foreach (var subCol in col.ChildColumns) - { - subCol.UpdateVisibility(); - } - } - - /// - /// 折叠DataGrid列组。 - /// - /// - 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> _popCopySteps = - new Dictionary>(); - - - /// + /// /// 拷贝所有选中的Steps。 /// - /// 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(); } /// @@ -1601,31 +1508,14 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe /// 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 /// 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; diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceData.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceData.cs index 23ec043..782ef9a 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceData.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceData.cs @@ -105,7 +105,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence }); } - param.IsSaved = true; + param.Save(); param.Parent = Params; Params.Add(param); diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceViewModel.cs index 14b5987..0a28000 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Sequence/SequenceViewModel.cs @@ -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; } } diff --git a/MECF.Framework.UI.Client/MECF.Framework.UI.Client.csproj b/MECF.Framework.UI.Client/MECF.Framework.UI.Client.csproj index 8ee3a73..a766e55 100644 --- a/MECF.Framework.UI.Client/MECF.Framework.UI.Client.csproj +++ b/MECF.Framework.UI.Client/MECF.Framework.UI.Client.csproj @@ -765,7 +765,6 @@ - diff --git a/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/CustomColumn/MultipleSelectColumn.cs b/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/CustomColumn/MultipleSelectColumn.cs index b24959a..9bb2e49 100644 --- a/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/CustomColumn/MultipleSelectColumn.cs +++ b/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/CustomColumn/MultipleSelectColumn.cs @@ -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; } } diff --git a/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/DataGridRecipe.xaml b/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/DataGridRecipe.xaml index 978641f..be15c82 100644 --- a/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/DataGridRecipe.xaml +++ b/MECF.Framework.UI.Client/RecipeEditorLib/DGExtension/DataGridRecipe.xaml @@ -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"> + @@ -513,19 +515,9 @@ VerticalContentAlignment="Stretch" FontSize="14" Header="{Binding DisplayName}" - IsExpanded="{Binding IsExpanded}"> - - - - - - - - - - - - + IsExpanded="{Binding IsExpanded}" + Expanded="Expander_OnExpanded" + Collapsed="Expander_OnCollapsed"> @@ -590,6 +582,10 @@