修正Sequence编辑界面中新增Sequence后,新的Sequence没有出现在左侧文件列表中的问题。

This commit is contained in:
DESKTOP-GPE37UV\THINKAPD 2023-04-01 12:51:53 +08:00
parent 025ff141f5
commit 98b5eebfdd
5 changed files with 100 additions and 46 deletions

View File

@ -1,5 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.ObjectModel;
using MECF.Framework.Common.CommonData; using MECF.Framework.Common.CommonData;
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence; using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
@ -20,7 +20,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors
#region Variablers #region Variablers
private List<FileNode> _filterFileListByProcessType; private ObservableCollection<FileNode> _filterFileListByProcessType;
#endregion #endregion
@ -28,8 +28,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors
public ProcessTypeFileItem() public ProcessTypeFileItem()
{ {
FileListByProcessType = new List<FileNode>(); FileListByProcessType = new ObservableCollection<FileNode>();
FilterFileListByProcessType = new List<FileNode>(); FilterFileListByProcessType = new ObservableCollection<FileNode>();
} }
public ProcessTypeFileItem(ProcessFileTypes processType) : this() public ProcessTypeFileItem(ProcessFileTypes processType) : this()
@ -43,9 +43,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors
public string ProcessType { get; set; } public string ProcessType { get; set; }
public List<FileNode> FileListByProcessType { get; set; } public ObservableCollection<FileNode> FileListByProcessType { get; set; }
public List<FileNode> FilterFileListByProcessType public ObservableCollection<FileNode> FilterFileListByProcessType
{ {
get => _filterFileListByProcessType; get => _filterFileListByProcessType;
set set

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using System.Xml; using System.Xml;
using Aitex.Core.UI.View.Common; using Aitex.Core.UI.View.Common;
@ -9,27 +10,78 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
{ {
public class FileNode : PropertyChangedBase public class FileNode : PropertyChangedBase
{ {
#region Variables
private string _name = string.Empty;
#endregion
#region Constructors
public FileNode() public FileNode()
{ {
this.Files = new List<FileNode>(); this.Files = new ObservableCollection<FileNode>();
this.IsFile = false; this.IsFile = false;
} }
private string name = string.Empty; #endregion
#region Properties
public string Name public string Name
{ {
get { return name; } get { return _name; }
set { name = value; NotifyOfPropertyChange("Name"); } set { _name = value; NotifyOfPropertyChange("Name"); }
} }
public string FullPath { get; set; } public string FullPath { get; set; }
public FileNode Parent { get; set; } public FileNode Parent { get; set; }
public List<FileNode> Files { get; set; }
public ObservableCollection<FileNode> Files { get; set; }
public bool IsFile { get; set; } public bool IsFile { get; set; }
public string PrefixPath { get; set; } public string PrefixPath { get; set; }
public bool IsSelected { get; set; } public bool IsSelected { get; set; }
public bool IsExpanded { get; set; } public bool IsExpanded { get; set; }
#endregion
#region Methods
/// <summary>
/// 将数中的节点转换为节点数组。
/// </summary>
/// <param name="terminalOnly">是否仅枚举最末端节点。</param>
/// <para>更新子节点的Selected属性时需要同时更新中间节点的属性更新父节点时只评估终端节点的Selected属性。</para>
/// <returns></returns>
private List<FileNode> Flatten(bool terminalOnly)
{
if (Files == null || Files.Count <= 0)
return new List<FileNode>(new[] { this });
var lst = Files.SelectMany(x => x.Flatten(terminalOnly)).ToList();
if (!terminalOnly)
lst.Add(this);
return lst;
}
/// <summary>
/// 选择指定的节点。
/// </summary>
/// <param name="fullPath"></param>
public void Select(string fullPath)
{
var flattenList = Flatten(true);
flattenList.ForEach(x => { x.IsSelected = x.FullPath == fullPath; });
Refresh();
}
#endregion
} }
public class RecipeSequenceTreeBuilder public class RecipeSequenceTreeBuilder
{ {
public static List<FileNode> GetFiles(string prefixPath, List<string> filenames) public static List<FileNode> GetFiles(string prefixPath, List<string> filenames)

View File

@ -274,7 +274,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
} }
} }
public int findInsertPosition(List<FileNode> files) public int findInsertPosition(ObservableCollection<FileNode> files)
{ {
var pos = -1; var pos = -1;
if (files.Count == 0) if (files.Count == 0)
@ -464,6 +464,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
CurrentFileNode.Files.Insert(findInsertPosition(CurrentFileNode.Files), file); CurrentFileNode.Files.Insert(findInsertPosition(CurrentFileNode.Files), file);
editMode = EditMode.Normal; editMode = EditMode.Normal;
UpdateView(); UpdateView();
// 自动选中新增节点
Files[0].Select(file.FullPath);
} }
} }
} }

View File

@ -1431,42 +1431,41 @@
IsEnabled="{Binding EnableStep}" /> IsEnabled="{Binding EnableStep}" />
<materialDesign:Badged <materialDesign:Badged
x:Name="txtErrorCount" x:Name="txtErrorCount"
BadgeColorZoneMode="Standard" BadgeColorZoneMode="Standard"
BadgeBackground="Red" BadgeBackground="Red"
BadgeForeground="White" BadgeForeground="White"
Margin="30,0,0,0" Margin="30,0,0,0"
BadgePlacementMode="TopLeft" BadgePlacementMode="TopLeft"
CornerRadius="5,5,5,5" CornerRadius="5,5,5,5"
materialDesign:BadgedAssist.IsMiniBadge="True" VerticalAlignment="Center"> materialDesign:BadgedAssist.IsMiniBadge="True" VerticalAlignment="Center">
<Button <Button
Width="90" Width="90"
Height="30" Height="30"
Content="Validate" Content="Validate"
IsEnabled="{Binding EnableStep}" IsEnabled="{Binding EnableStep}"
micro:Message.Attach="ShowValidationDetailWindow()"/> micro:Message.Attach="ShowValidationDetailWindow()"/>
</materialDesign:Badged> </materialDesign:Badged>
<materialDesign:Badged <materialDesign:Badged
x:Name="txtCellAccessPremCount" x:Name="txtCellAccessPremCount"
BadgeColorZoneMode="Standard" BadgeColorZoneMode="Standard"
BadgeBackground="LimeGreen" BadgeBackground="LimeGreen"
BadgeForeground="White" BadgeForeground="White"
Margin="15,0,0,0" Margin="15,0,0,0"
BadgePlacementMode="TopLeft" BadgePlacementMode="TopLeft"
CornerRadius="5,5,5,5" CornerRadius="5,5,5,5"
materialDesign:BadgedAssist.IsMiniBadge="True" materialDesign:BadgedAssist.IsMiniBadge="True"
VerticalAlignment="Center" VerticalAlignment="Center"
Visibility="{Binding IsShowCellAccessPermEditButton, Converter={StaticResource bool2VisibilityConverter}}"> Visibility="{Binding IsShowCellAccessPermEditButton, Converter={StaticResource bool2VisibilityConverter}}">
<Button <Button
Width="100" Width="100"
Height="30" Height="30"
IsEnabled="{Binding EnableCellPermButton}" IsEnabled="{Binding EnableCellPermButton}"
Content="{Binding IsCellAccessPermissionEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}" Content="{Binding IsCellAccessPermissionEditMode, Mode=OneWay, Converter={StaticResource CellPermButtonContent}}"
Margin="0,0,0,0" Margin="0,0,0,0"
ToolTip="Cell-Access-Perm Edit Mode" ToolTip="Cell-Access-Perm Edit Mode"
micro:Message.Attach="SwitchCellAccessPermEditMode()"> micro:Message.Attach="SwitchCellAccessPermEditMode()"/>
</Button>
</materialDesign:Badged> </materialDesign:Badged>
</StackPanel> </StackPanel>

View File

@ -2432,7 +2432,7 @@ namespace SicUI.Models.RecipeEditors
private void ApplyFilter() private void ApplyFilter()
{ {
ProcessTypeFileList[ProcessTypeIndexSelection].FilterFileListByProcessType = ProcessTypeFileList[ProcessTypeIndexSelection].FilterFileListByProcessType =
new List<FileNode>(ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType new ObservableCollection<FileNode>(ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType
.Where(d => d.Name.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0)); .Where(d => d.Name.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
} }