From 652e9f9ae48f3996784747d5c7f77909fb3e80f4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GPE37UV\\THINKAPD" Date: Thu, 1 Dec 2022 16:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Cell-Perm=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=BE=BD=E6=A0=87=E7=9A=84=E5=B8=83=E5=B1=80=E5=92=8C=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E3=80=82=20=E5=AE=8C=E5=96=84Cell-Perm=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecipeModel/RecipeStepCollection.cs | 12 +++++- .../RecipeEditors/RecipeEditorView.xaml | 6 +-- .../RecipeEditors/RecipeEditorView.xaml.cs | 2 + .../RecipeEditors/RecipeEditorViewModel.cs | 42 ++++++------------- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/FrameworkLocal/UIClient/RecipeEditorLib/RecipeModel/RecipeStepCollection.cs b/FrameworkLocal/UIClient/RecipeEditorLib/RecipeModel/RecipeStepCollection.cs index 39cb36f..0a0cd09 100644 --- a/FrameworkLocal/UIClient/RecipeEditorLib/RecipeModel/RecipeStepCollection.cs +++ b/FrameworkLocal/UIClient/RecipeEditorLib/RecipeModel/RecipeStepCollection.cs @@ -140,7 +140,17 @@ namespace RecipeEditorLib.RecipeModel.Params { this.ToList().ForEach(x => x.ResetHighlight()); } - + + /// + /// 计算被赋予访问权限的配方参数。 + /// + /// + public int GetParamsCountWhoHaveAccessPerm() + { + var total = this.ToList().Sum(x => x.GetHighlightedParams().Count); + return total; + } + #endregion #region Overrided Methods diff --git a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml index 6ab3c79..b06b01c 100644 --- a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml +++ b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml @@ -1498,9 +1498,9 @@ @@ -1509,7 +1509,7 @@ Width="100" Height="30" Content="{Binding CellAccessPermButtonContent, Mode=OneWay}" - Margin="5,0,0,0" + Margin="0,0,0,0" ToolTip="Show/Hide Param Values" Click="BtnCellAccessPermissionEditMode_OnClick"> diff --git a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml.cs b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml.cs index fdfdb65..01d94de 100644 --- a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml.cs +++ b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml.cs @@ -166,6 +166,8 @@ namespace SicUI.Models.RecipeEditors else param.Highlight(); } + + vm.CountHaveAccessPermParams(); //vm.SelectedGridCellCollection = e.AddedCells; //vm.ToggleCellAccessPermissionWhitelistMark(); } diff --git a/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs b/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs index 83eb901..50ce04d 100644 --- a/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs +++ b/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs @@ -2028,37 +2028,15 @@ namespace SicUI.Models.RecipeEditors #endregion - #region Cell访问权限编辑 + #region Cell访问权限编辑 /// - /// 高亮标出允许访问白名单的Cell。 + /// 计算具有访问权限白名单的参数的总数。 /// - public void ToggleCellAccessPermissionWhitelistMark() + public void CountHaveAccessPermParams() { - if (SelectedGridCellCollection != null) - { - foreach (var dataGridCellInfo in SelectedGridCellCollection) - { - if (dataGridCellInfo.Column is EditorDataGridTemplateColumnBase col && - dataGridCellInfo.Item is RecipeStep step) - { - var controlName = col.ControlName; - var stepUid = step.StepUid; - - if(string.IsNullOrEmpty(controlName)) - continue; - - var param = step.FirstOrDefault(x => x.Name == controlName); - if(param == null) - continue; - - if (param.IsHighlighted) - param.ResetHighlight(); - else - param.Highlight(); - } - } - } + var total = CurrentRecipe.Steps.GetParamsCountWhoHaveAccessPerm(); + CellAccessPermCount = total; } /// @@ -2089,6 +2067,8 @@ namespace SicUI.Models.RecipeEditors UpdateView(); + CountHaveAccessPermParams(); + return true; } @@ -2117,6 +2097,8 @@ namespace SicUI.Models.RecipeEditors UpdateView(); + CellAccessPermCount = 0; + } /// @@ -2212,7 +2194,6 @@ namespace SicUI.Models.RecipeEditors #endregion - private void ClearData() { _editMode = EditMode.None; @@ -2353,7 +2334,10 @@ namespace SicUI.Models.RecipeEditors NotifyOfPropertyChange(nameof(EnableStep)); NotifyOfPropertyChange(nameof(EnableSaveTo)); NotifyOfPropertyChange(nameof(EnableSaveToAll)); - NotifyOfPropertyChange(nameof(EnableReload)); + NotifyOfPropertyChange(nameof(EnableLeftTabPanel)); + NotifyOfPropertyChange(nameof(EnableFilterTreeList)); + NotifyOfPropertyChange(nameof(EnableRefreshRecipeList)); + NotifyOfPropertyChange(nameof(CellAccessPermButtonContent)); NotifyOfPropertyChange(nameof(CurrentRecipe)); }