|
@@ -3,24 +3,41 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
+using Aitex.Core.RT.SCCore;
|
|
|
+using ControlzEx.Standard;
|
|
|
+using FabConnect.SecsGemInterface.Application.Objects.ObjectService;
|
|
|
using MECF.Framework.Common.DataCenter;
|
|
|
using MECF.Framework.Common.Equipment;
|
|
|
using MECF.Framework.Common.OperationCenter;
|
|
|
+using MECF.Framework.Common.Schedulers;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using Venus_MainPages.Unity;
|
|
|
+using Venus_MainPages.Views;
|
|
|
//using Venus_MainPages.Unity.SystemConfig;
|
|
|
|
|
|
namespace Venus_MainPages.ViewModels
|
|
|
{
|
|
|
- public class SystemConfigViewModel:BindableBase
|
|
|
+ public class SystemConfigViewModel : BindableBase
|
|
|
{
|
|
|
#region 私有字段
|
|
|
private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();
|
|
|
private List<ConfigItem> _configItems = null;
|
|
|
+ private List<String> _SearchResultCollection = null;
|
|
|
string _CurrentNodeName = string.Empty;
|
|
|
+ private Visibility _Visibility = new Visibility();
|
|
|
+ private string[] _InstalledModules = null;
|
|
|
+ private string _SearchText;
|
|
|
+ List<string> searchResultListHistory = new List<string>();
|
|
|
|
|
|
+ public string SearchText
|
|
|
+ {
|
|
|
+ get { return _SearchText; }
|
|
|
+ set { _SearchText = value; RaisePropertyChanged("SearchText"); }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
@@ -29,11 +46,21 @@ namespace Venus_MainPages.ViewModels
|
|
|
get { return _ConfigNodes; }
|
|
|
set { _ConfigNodes = value; RaisePropertyChanged("ConfigNodes"); }
|
|
|
}
|
|
|
+ public List<String> SearchResultCollection
|
|
|
+ {
|
|
|
+ get { return _SearchResultCollection; }
|
|
|
+ set { _SearchResultCollection = value; RaisePropertyChanged("SearchResultCollection"); }
|
|
|
+ }
|
|
|
public List<ConfigItem> ConfigItems
|
|
|
{
|
|
|
get { return _configItems; }
|
|
|
set { _configItems = value; RaisePropertyChanged("ConfigItems"); }
|
|
|
}
|
|
|
+ public Visibility SearchListBoxShow
|
|
|
+ {
|
|
|
+ get { return _Visibility; }
|
|
|
+ set { _Visibility = value; RaisePropertyChanged("SearchListBoxShow"); }
|
|
|
+ }
|
|
|
|
|
|
#region 命令
|
|
|
|
|
@@ -50,10 +77,21 @@ namespace Venus_MainPages.ViewModels
|
|
|
private DelegateCommand<object> _SetValueCommand;
|
|
|
public DelegateCommand<object> SetValueCommand =>
|
|
|
_SetValueCommand ?? (_SetValueCommand = new DelegateCommand<object>(SetValue));
|
|
|
-
|
|
|
+ private DelegateCommand<object> _SearchTextChangedCommand;
|
|
|
+ public DelegateCommand<object> SearchTextChangedCommand =>
|
|
|
+ _SearchTextChangedCommand ?? (_SearchTextChangedCommand = new DelegateCommand<object>(SearchTextChanged));
|
|
|
+
|
|
|
+ private DelegateCommand<object> _ListBoxSelectSearchResultCommand;
|
|
|
+ public DelegateCommand<object> ListBoxSelectSearchResultCommand =>
|
|
|
+ _ListBoxSelectSearchResultCommand ?? (_ListBoxSelectSearchResultCommand = new DelegateCommand<object>(SelectSearchResult));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
public SystemConfigViewModel()
|
|
|
{
|
|
|
+ SearchListBoxShow = Visibility.Hidden;
|
|
|
ConfigNodes = SystemConfigProvider.Instance.GetConfigTree().SubNodes;
|
|
|
|
|
|
}
|
|
@@ -65,12 +103,162 @@ namespace Venus_MainPages.ViewModels
|
|
|
// ConfigNodes = SystemConfigProvider.Instance.GetConfigTree().SubNodes;
|
|
|
//}
|
|
|
|
|
|
+ //输入关键字
|
|
|
+ private void SearchTextChanged(object searchConfigItem)
|
|
|
+ {
|
|
|
+ List<string> searchResultList = new List<string>();
|
|
|
+ //如果输入框为空,不显示提示词,并展开左侧栏
|
|
|
+ if (string.IsNullOrEmpty((string)searchConfigItem))
|
|
|
+ {
|
|
|
+ ConfigNodes = SystemConfigProvider.Instance.GetConfigTree().SubNodes;
|
|
|
+ SearchListBoxShow = Visibility.Hidden;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ConfigNodes = SystemConfigProvider.Instance.GetConfigTree().SubNodes;
|
|
|
+ var itemslist = ConfigNodes.SelectMany(m => m.Items).ToList();
|
|
|
+ if (SearchText != null)
|
|
|
+ {
|
|
|
+ SearchListBoxShow = Visibility.Visible;
|
|
|
+ //根节点
|
|
|
+ string searchResult = null;
|
|
|
+ _InstalledModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
|
|
|
+ foreach (var ConfigNodesItems in ConfigNodes)
|
|
|
+ {
|
|
|
+ if (!_InstalledModules.Contains(ConfigNodesItems.Name) && ConfigNodesItems.Name != "System" && ConfigNodesItems.Name != "Recipe" && ConfigNodesItems.Name != "Scheduler")
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //根节点搜索
|
|
|
+ if (ConfigNodesItems.Name.Contains(SearchText))
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = true;//展开根节点
|
|
|
+ _CurrentNodeName = SearchText;//TreeView节点
|
|
|
+ searchResult = _CurrentNodeName;
|
|
|
+ GetDataOfConfigItems();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = false;
|
|
|
+ //二级节点搜索
|
|
|
+ foreach (var SubNodesItems in ConfigNodesItems.SubNodes)
|
|
|
+ {
|
|
|
+ if (SubNodesItems.Name.ToLower().Contains(SearchText.ToLower()))
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = true;
|
|
|
+ SubNodesItems.IsShow = true;
|
|
|
+ _CurrentNodeName = String.Format("{0}{1}{2}", ConfigNodesItems.Name, ".", SubNodesItems.Name);
|
|
|
+ searchResult = _CurrentNodeName;
|
|
|
+ GetDataOfConfigItems();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SubNodesItems.IsShow = false;
|
|
|
+
|
|
|
+ //叶子节点搜索
|
|
|
+ foreach (var Items in SubNodesItems.Items)
|
|
|
+ {
|
|
|
+ var searchResult1 = SubNodesItems.Items.FindAll(e => e.Name.ToLower().Contains(SearchText.ToLower()));
|
|
|
+ if (Items.Name.ToLower().Contains(SearchText.ToLower()))
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = true;
|
|
|
+ SubNodesItems.IsShow = true;
|
|
|
+ _CurrentNodeName = String.Format("{0}{1}{2}{3}{4}", ConfigNodesItems.Name, ".", SubNodesItems.Name, ".", Items.Name);
|
|
|
+ searchResult = _CurrentNodeName;
|
|
|
+ GetDataOfConfigItems();
|
|
|
+ searchResultList.Add(_CurrentNodeName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var searchResult2 = ConfigNodesItems.Items.FindAll(e => e.Name.ToLower().Contains(SearchText.ToLower()));
|
|
|
+ if (searchResult2.Count != 0)
|
|
|
+ {
|
|
|
+ ConfigNodesItems.IsShow = true;
|
|
|
+ _CurrentNodeName = SearchText;//TreeView节点
|
|
|
+ searchResultList.Add(ConfigNodesItems.Name + "." + searchResult2[0].Name);
|
|
|
+ searchResult = _CurrentNodeName;
|
|
|
+ GetDataOfConfigItems();
|
|
|
+ }
|
|
|
+ //查询为空
|
|
|
+ if (searchResult == null)
|
|
|
+ {
|
|
|
+ ConfigItems = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SearchResultCollection = searchResultList;
|
|
|
+ if (searchResultList.Count > 0)
|
|
|
+ {
|
|
|
+ searchResultListHistory = searchResultList;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //选择选中项
|
|
|
+ private void SelectSearchResult(object slectItem)
|
|
|
+ {
|
|
|
+ SearchResultCollection = searchResultListHistory;
|
|
|
+ ConfigNodes = SystemConfigProvider.Instance.GetConfigTree().SubNodes;
|
|
|
+ if (slectItem != null)
|
|
|
+ {
|
|
|
+ SearchText = slectItem.ToString();
|
|
|
+ string[] searchResult = SearchText.Split('.');
|
|
|
+ List<ConfigItem> ConfigItem = new List<ConfigItem>();
|
|
|
+ //根节点下ConfigItems
|
|
|
+ if (searchResult.Length == 2)
|
|
|
+ {
|
|
|
+ ConfigNodes.ForEach(e => e.IsShow = false);
|
|
|
+ ConfigNode targetmodule = ConfigNodes.Find(e => e.Name.ToLower() == searchResult[0].ToLower());
|
|
|
+ targetmodule.IsShow = true;
|
|
|
+ targetmodule.SubNodes.ForEach(e => e.IsShow = false);
|
|
|
+ _CurrentNodeName = string.IsNullOrEmpty(targetmodule.Path) ? targetmodule.Name : $"{targetmodule.Path}.{targetmodule.Name}";
|
|
|
+ ConfigItems = targetmodule.Items.FindAll(e => e.Name.ToLower() == searchResult[1].ToLower());
|
|
|
+ GetDataOfConfigItems();
|
|
|
+
|
|
|
+ }
|
|
|
+ //二级节点下ConfigItems
|
|
|
+ if (searchResult.Length == 3)
|
|
|
+ {
|
|
|
+ ConfigNodes.ForEach(e => e.IsShow = false);
|
|
|
+ ConfigNode targetmodule = ConfigNodes.Find(e => e.Name.ToLower() == searchResult[0].ToLower());
|
|
|
+ targetmodule.IsShow = true;
|
|
|
+ targetmodule.SubNodes.ForEach(e => e.IsShow = false);
|
|
|
+ ConfigNode submodule = targetmodule.SubNodes.Find(e => e.Name.ToLower() == searchResult[1].ToLower());
|
|
|
+ submodule.IsShow = true;
|
|
|
+ _CurrentNodeName = string.IsNullOrEmpty(submodule.Path) ? submodule.Name : $"{submodule.Path}.{submodule.Name}";
|
|
|
+ ConfigItems = submodule.Items.FindAll(e => e.Name.ToLower() == searchResult[2].ToLower());
|
|
|
+ submodule.Items.FindAll(e => e.Name.ToLower() != searchResult[2].ToLower()).ForEach(e => e.Visible = false);
|
|
|
+ GetDataOfConfigItems();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
private void TreeViewSelectedItemChanged(object node)
|
|
|
{
|
|
|
- var node2 = (ConfigNode)node;
|
|
|
+ var node2 = (ConfigNode)node;
|
|
|
_CurrentNodeName = string.IsNullOrEmpty(node2.Path) ? node2.Name : $"{node2.Path}.{node2.Name}";
|
|
|
- ConfigItems = node2.Items;
|
|
|
-
|
|
|
+ string[] searchResult = null;
|
|
|
+ if (SearchText == "" || SearchText == null)
|
|
|
+ {
|
|
|
+ ConfigItems = node2.Items;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ searchResult = SearchText.Split('.');
|
|
|
+ if (searchResult.Length == 2)
|
|
|
+ {
|
|
|
+ ConfigItems = node2.Items.FindAll(e => e.Name.ToLower() == searchResult[1].ToLower());
|
|
|
+ }
|
|
|
+ if (searchResult.Length == 3)
|
|
|
+ {
|
|
|
+ ConfigItems = node2.Items.FindAll(e => e.Name.ToLower() == searchResult[2].ToLower());
|
|
|
+ }
|
|
|
+ }
|
|
|
GetDataOfConfigItems();
|
|
|
}
|
|
|
|
|
@@ -178,6 +366,6 @@ namespace Venus_MainPages.ViewModels
|
|
|
|
|
|
ConfigItems.ForEach(item => SetValue(item));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|