From b7a1a2a19590d73391f9fc597221468d3da99792 Mon Sep 17 00:00:00 2001
From: HCL <1625932291@qq.com>
Date: Fri, 24 May 2024 11:27:33 +0800
Subject: [PATCH] =?UTF-8?q?1.RecipeEditorView=E5=92=8CRecipeSelectView?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Editors/Recipe/RecipeEditorView.xaml | 1 +
.../Editors/Recipe/RecipeEditorViewModel.cs | 5 +-
.../Recipe/RecipeSelectDialogView.xaml | 55 ++++++++++++++++++-
.../Recipe/RecipeSelectDialogViewModel.cs | 24 ++++++++
.../Editors/RecipeSequenceTreeBuilder.cs | 41 ++++++++++++++
5 files changed, 122 insertions(+), 4 deletions(-)
diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml
index 66db5ad..270528a 100644
--- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml
+++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml
@@ -296,6 +296,7 @@
diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs
index 1b1703e..60996a6 100644
--- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs
+++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs
@@ -1893,9 +1893,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
private void ApplyFilter()
{
- ProcessTypeFileList[ProcessTypeIndexSelection].FilterFileListByProcessType =
- new ObservableCollection(ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType
- .Where(d => d.Name.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
+ foreach (var node in ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType)
+ node.ApplyCriteria(CurrentCriteria, new Stack());
}
public void ClearFilter()
diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogView.xaml b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogView.xaml
index b2786e5..bb74f4d 100644
--- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogView.xaml
+++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogView.xaml
@@ -62,10 +62,61 @@
BorderThickness="0,1,0,0">
+
+
+
+
+
+
+
+
@@ -98,6 +149,7 @@
@@ -120,8 +172,9 @@
+
diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogViewModel.cs
index 3e1058c..87e1f87 100644
--- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogViewModel.cs
+++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeSelectDialogViewModel.cs
@@ -142,5 +142,29 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
}
#endregion
+
+ private string _currentCriteria = string.Empty;
+
+ public string CurrentCriteria
+ {
+ get => _currentCriteria;
+ set
+ {
+ if (value == _currentCriteria)
+ return;
+
+ _currentCriteria = value;
+ NotifyOfPropertyChange(nameof(CurrentCriteria));
+
+ ApplyFilter();
+ }
+ }
+
+
+ private void ApplyFilter()
+ {
+ foreach (var node in ProcessTypeFileList[ProcessTypeIndexSelection].FileListByProcessType)
+ node.ApplyCriteria(CurrentCriteria, new Stack());
+ }
}
}
diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/RecipeSequenceTreeBuilder.cs b/MECF.Framework.UI.Client/CenterViews/Editors/RecipeSequenceTreeBuilder.cs
index e2f7c96..5b6ffc7 100644
--- a/MECF.Framework.UI.Client/CenterViews/Editors/RecipeSequenceTreeBuilder.cs
+++ b/MECF.Framework.UI.Client/CenterViews/Editors/RecipeSequenceTreeBuilder.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Windows;
using System.Windows.Controls;
using System.Xml;
using Aitex.Core.UI.View.Common;
@@ -46,6 +47,14 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
public bool IsExpanded { get; set; }
+
+ private Visibility isMatch;
+ public Visibility IsMatch
+ {
+ get { return isMatch; }
+ set { isMatch = value; NotifyOfPropertyChange("IsMatch"); }
+ }
+
#endregion
#region Methods
@@ -79,6 +88,38 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
Refresh();
}
+ private bool IsCriteriaMatched(string criteria)
+ {
+ bool matched = string.IsNullOrEmpty(criteria) || _name.ToLower().Contains(criteria.ToLower());
+
+ if (matched)
+ return true;
+
+ return false;
+ }
+
+ public void ApplyCriteria(string criteria, Stack ancestors)
+ {
+ if (IsCriteriaMatched(criteria))
+ {
+ IsMatch = Visibility.Visible;
+ foreach (var ancestor in ancestors)
+ {
+ ancestor.IsMatch = Visibility.Visible;
+ ancestor.IsExpanded = !string.IsNullOrEmpty(criteria);
+ }
+ IsExpanded = true;
+ }
+ else
+ IsMatch = Visibility.Collapsed;
+
+ ancestors.Push(this);
+ foreach (var child in Files)
+ child.ApplyCriteria(criteria, ancestors);
+
+ ancestors.Pop();
+ }
+
#endregion
}