From 98b5eebfdd45306fbcec1de23175a2d93b38372f Mon Sep 17 00:00:00 2001 From: "DESKTOP-GPE37UV\\THINKAPD" Date: Sat, 1 Apr 2023 12:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Sequence=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=AD=E6=96=B0=E5=A2=9ESequence=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E7=9A=84Sequence=E6=B2=A1=E6=9C=89=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=B7=A6=E4=BE=A7=E6=96=87=E4=BB=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editors/ProcessTypeFileItem.cs | 12 ++-- .../Editors/RecipeSequenceTreeBuilder.cs | 64 +++++++++++++++++-- .../Editors/Sequence/SequenceViewModel.cs | 5 +- .../RecipeEditors/RecipeEditorView.xaml | 63 +++++++++--------- .../RecipeEditors/RecipeEditorViewModel.cs | 2 +- 5 files changed, 100 insertions(+), 46 deletions(-) diff --git a/FrameworkLocal/UIClient/CenterViews/Editors/ProcessTypeFileItem.cs b/FrameworkLocal/UIClient/CenterViews/Editors/ProcessTypeFileItem.cs index 2d436ea..211c15c 100644 --- a/FrameworkLocal/UIClient/CenterViews/Editors/ProcessTypeFileItem.cs +++ b/FrameworkLocal/UIClient/CenterViews/Editors/ProcessTypeFileItem.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Collections.ObjectModel; using MECF.Framework.Common.CommonData; using MECF.Framework.UI.Client.CenterViews.Editors.Sequence; @@ -20,7 +20,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors #region Variablers - private List _filterFileListByProcessType; + private ObservableCollection _filterFileListByProcessType; #endregion @@ -28,8 +28,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors public ProcessTypeFileItem() { - FileListByProcessType = new List(); - FilterFileListByProcessType = new List(); + FileListByProcessType = new ObservableCollection(); + FilterFileListByProcessType = new ObservableCollection(); } public ProcessTypeFileItem(ProcessFileTypes processType) : this() @@ -43,9 +43,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors public string ProcessType { get; set; } - public List FileListByProcessType { get; set; } + public ObservableCollection FileListByProcessType { get; set; } - public List FilterFileListByProcessType + public ObservableCollection FilterFileListByProcessType { get => _filterFileListByProcessType; set diff --git a/FrameworkLocal/UIClient/CenterViews/Editors/RecipeSequenceTreeBuilder.cs b/FrameworkLocal/UIClient/CenterViews/Editors/RecipeSequenceTreeBuilder.cs index 2879d1b..e2f7c96 100644 --- a/FrameworkLocal/UIClient/CenterViews/Editors/RecipeSequenceTreeBuilder.cs +++ b/FrameworkLocal/UIClient/CenterViews/Editors/RecipeSequenceTreeBuilder.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Windows.Controls; using System.Xml; using Aitex.Core.UI.View.Common; @@ -9,27 +10,78 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence { public class FileNode : PropertyChangedBase { + #region Variables + + private string _name = string.Empty; + + #endregion + + #region Constructors public FileNode() { - this.Files = new List(); + this.Files = new ObservableCollection(); this.IsFile = false; } - private string name = string.Empty; + #endregion + + #region Properties + public string Name { - get { return name; } - set { name = value; NotifyOfPropertyChange("Name"); } + get { return _name; } + set { _name = value; NotifyOfPropertyChange("Name"); } } public string FullPath { get; set; } + public FileNode Parent { get; set; } - public List Files { get; set; } + + public ObservableCollection Files { get; set; } + public bool IsFile { get; set; } + public string PrefixPath { get; set; } + public bool IsSelected { get; set; } + public bool IsExpanded { get; set; } + + #endregion + + #region Methods + + /// + /// 将数中的节点转换为节点数组。 + /// + /// 是否仅枚举最末端节点。 + /// 更新子节点的Selected属性时,需要同时更新中间节点的属性;更新父节点时,只评估终端节点的Selected属性。 + /// + private List Flatten(bool terminalOnly) + { + if (Files == null || Files.Count <= 0) + return new List(new[] { this }); + + var lst = Files.SelectMany(x => x.Flatten(terminalOnly)).ToList(); + if (!terminalOnly) + lst.Add(this); + + return lst; + } + + /// + /// 选择指定的节点。 + /// + /// + public void Select(string fullPath) + { + var flattenList = Flatten(true); + flattenList.ForEach(x => { x.IsSelected = x.FullPath == fullPath; }); + Refresh(); + } + + #endregion } - + public class RecipeSequenceTreeBuilder { public static List GetFiles(string prefixPath, List filenames) diff --git a/FrameworkLocal/UIClient/CenterViews/Editors/Sequence/SequenceViewModel.cs b/FrameworkLocal/UIClient/CenterViews/Editors/Sequence/SequenceViewModel.cs index c99d28b..04ffba5 100644 --- a/FrameworkLocal/UIClient/CenterViews/Editors/Sequence/SequenceViewModel.cs +++ b/FrameworkLocal/UIClient/CenterViews/Editors/Sequence/SequenceViewModel.cs @@ -274,7 +274,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence } } - public int findInsertPosition(List files) + public int findInsertPosition(ObservableCollection files) { var pos = -1; if (files.Count == 0) @@ -464,6 +464,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence CurrentFileNode.Files.Insert(findInsertPosition(CurrentFileNode.Files), file); editMode = EditMode.Normal; UpdateView(); + + // 自动选中新增节点 + Files[0].Select(file.FullPath); } } } diff --git a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml index 06774fa..d75e566 100644 --- a/SicUI/Models/RecipeEditors/RecipeEditorView.xaml +++ b/SicUI/Models/RecipeEditors/RecipeEditorView.xaml @@ -1431,42 +1431,41 @@ IsEnabled="{Binding EnableStep}" /> - + Width="100" + Height="30" + IsEnabled="{Binding EnableCellPermButton}" + Content="{Binding IsCellAccessPermissionEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}" + Margin="0,0,0,0" + ToolTip="Cell-Access-Perm Edit Mode" + micro:Message.Attach="SwitchCellAccessPermEditMode()"/> diff --git a/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs b/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs index c25d85e..a494643 100644 --- a/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs +++ b/SicUI/Models/RecipeEditors/RecipeEditorViewModel.cs @@ -2432,7 +2432,7 @@ namespace SicUI.Models.RecipeEditors private void ApplyFilter() { ProcessTypeFileList[ProcessTypeIndexSelection].FilterFileListByProcessType = - new List(ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType + new ObservableCollection(ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType .Where(d => d.Name.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0)); }