| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 | 
							- using System.Collections.Generic;
 
- using System.Linq;
 
- using Caliburn.Micro.Core;
 
- using RecipeEditorLib.RecipeModel.Params;
 
- using SciChart.Core.Extensions;
 
- namespace MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig
 
- {
 
-     public enum DataType
 
-     {
 
-         Unknown,
 
-         Int,
 
-         Double,
 
-         Bool,
 
-         String
 
-     };
 
-     public class ConfigNode : PropertyChangedBase
 
-     {
 
-         private string name = string.Empty;
 
-         public string Name
 
-         {
 
-             get { return name; }
 
-             set { name = value; NotifyOfPropertyChange("Name"); }
 
-         }
 
-         private string path = string.Empty;
 
-         public string Path
 
-         {
 
-             get { return path; }
 
-             set { path = value; NotifyOfPropertyChange("Path"); }
 
-         }
 
-         private string _display = string.Empty;
 
-         public string Display
 
-         {
 
-             get { return _display; }
 
-             set { _display = value; NotifyOfPropertyChange("Display"); }
 
-         }
 
-         private bool _isExpanded;
 
-         public bool IsExpanded
 
-         {
 
-             get { return _isExpanded; }
 
-             set { _isExpanded = value; NotifyOfPropertyChange("IsExpanded"); }
 
-         }
 
-         private bool _isVisible=true;
 
-         public bool IsVisible
 
-         {
 
-             get { return _isVisible; }
 
-             set { _isVisible = value; NotifyOfPropertyChange("IsVisible"); }
 
-         }
 
-         private bool _isMatch;
 
-         public bool IsMatch
 
-         {
 
-             get { return _isMatch; }
 
-             set { _isMatch = value; NotifyOfPropertyChange("IsMatch"); }
 
-         }
 
-         private bool _isSelected;
 
-         public bool IsSelected
 
-         {
 
-             get { return _isSelected; }
 
-             set { _isSelected = value; NotifyOfPropertyChange("IsSelected"); }
 
-         }
 
-         private bool _bvalue = false;
 
-         public bool ProfileBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("ProfileBoolValue"); }
 
-         }
 
-         public bool PIDBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("PIDBoolValue"); }
 
-         }
 
-         public bool StabilizeBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("StabilizeBoolValue"); }
 
-         }
 
-         public bool TempSttingBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("TempSttingBoolValue"); }
 
-         }
 
-         public bool PressureStabilizeBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("PressureStabilizeBoolValue"); }
 
-         }
 
-         public bool AlarmWatchBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("PressureStabilizeBoolValue"); }
 
-         }
 
-         public bool TempAlarmBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("TempAlarmBoolValue"); }
 
-         }
 
-         public bool FlowAlarmBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("FlowAlarmBoolValue"); }
 
-         }
 
-         public bool PressureAlarmBoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("PressureAlarmBoolValue"); }
 
-         }
 
-         private List<ConfigNode> _subNodes = null;
 
-         public List<ConfigNode> SubNodes
 
-         {
 
-             get { return _subNodes; }
 
-             set { _subNodes = value; NotifyOfPropertyChange("SubNodes"); }
 
-         }
 
-         private List<ConfigItem> _items = null;
 
-         public List<ConfigItem> Items
 
-         {
 
-             get { return _items; }
 
-             set { _items = value; NotifyOfPropertyChange("Items"); }
 
-         }
 
-         private bool IsCriteriaMatched(string criteria)
 
-         {
 
-             bool matched = string.IsNullOrEmpty(criteria) || name.Contains(criteria) || name.ToLower().Contains(criteria.ToLower());
 
-             if (matched)
 
-                 return true;
 
-             foreach (var configItem in Items)
 
-             {
 
-                 if (configItem.Name.Contains(criteria))
 
-                     return true;
 
-                 if (configItem.Name.ToLower().Contains(criteria.ToLower()))
 
-                     return true;
 
-             }
 
-             return false;
 
-         }
 
-         private void CheckChildren(string criteria, ConfigNode parent)
 
-         {
 
-             foreach (var child in parent.SubNodes)
 
-             {
 
-                 if (!child.IsCriteriaMatched(criteria))
 
-                 {
 
-                     child.IsMatch = false;
 
-                 }
 
-                 CheckChildren(criteria, child);
 
-             }
 
-         }
 
-         public void ApplyCriteria(string criteria, Stack<ConfigNode> ancestors)
 
-         {
 
-             if (IsCriteriaMatched(criteria))
 
-             {
 
-                 IsMatch = true;
 
-                 foreach (var ancestor in ancestors)
 
-                 {
 
-                     ancestor.IsMatch = true;
 
-                     ancestor.IsExpanded = !string.IsNullOrEmpty(criteria);
 
-                     //CheckChildren(criteria, ancestor);
 
-                 }
 
-                 IsExpanded = true;
 
-             }
 
-             else
 
-                 IsMatch = false;
 
-             ancestors.Push(this);
 
-             foreach (var child in SubNodes)
 
-                 child.ApplyCriteria(criteria, ancestors);
 
-             ancestors.Pop();
 
-         }
 
-     }
 
-     public class ConfigItem : PropertyChangedBase
 
-     {
 
-         private string name = string.Empty;
 
-         public string Name
 
-         {
 
-             get { return name; }
 
-             set { name = value; NotifyOfPropertyChange("Name"); }
 
-         }
 
-         private string description = string.Empty;
 
-         public string Description
 
-         {
 
-             get { return description; }
 
-             set { description = value; NotifyOfPropertyChange("Description"); }
 
-         }
 
-         private string _display = string.Empty;
 
-         public string Display
 
-         {
 
-             get { return _display; }
 
-             set { _display = value; NotifyOfPropertyChange("Display"); }
 
-         }
 
-         private DataType type = DataType.Unknown;
 
-         public DataType Type
 
-         {
 
-             get { return type; }
 
-             set { type = value; NotifyOfPropertyChange("Type"); }
 
-         }
 
-         private string defaultValue = string.Empty;
 
-         public string DefaultValue
 
-         {
 
-             get { return defaultValue; }
 
-             set { defaultValue = value; NotifyOfPropertyChange("DefaultValue"); }
 
-         }
 
-         private double max = double.NaN;
 
-         public double Max
 
-         {
 
-             get { return max; }
 
-             set { max = value; NotifyOfPropertyChange("Max"); }
 
-         }
 
-         private double min = double.NaN;
 
-         public double Min
 
-         {
 
-             get { return min; }
 
-             set { min = value; NotifyOfPropertyChange("Min"); }
 
-         }
 
-         private string parameter = string.Empty;
 
-         public string Parameter
 
-         {
 
-             get { return parameter; }
 
-             set { parameter = value; NotifyOfPropertyChange("Parameter"); }
 
-         }
 
-         private string tag = string.Empty;
 
-         public string Tag
 
-         {
 
-             get { return tag; }
 
-             set { tag = value; NotifyOfPropertyChange("Tag"); }
 
-         }
 
-         private string unit = string.Empty;
 
-         public string Unit
 
-         {
 
-             get { return unit; }
 
-             set { unit = value; NotifyOfPropertyChange("Unit"); }
 
-         }
 
-         private bool visible = true;
 
-         public bool Visible
 
-         {
 
-             get { return visible; }
 
-             set { visible = value; NotifyOfPropertyChange("Visible"); }
 
-         }
 
-         private bool _isExpanded;
 
-         public bool IsExpanded
 
-         {
 
-             get { return _isExpanded; }
 
-             set { _isExpanded = value; NotifyOfPropertyChange("IsExpanded"); }
 
-         }
 
-         private string cvalue = string.Empty;
 
-         public string CurrentValue
 
-         {
 
-             get { return cvalue; }
 
-             set { cvalue = value; NotifyOfPropertyChange("CurrentValue"); }
 
-         }
 
-         private StringParam cvalueParam = new StringParam() { Name = "CurrentValue", Value = "" };
 
-         public StringParam CurrentValueParam
 
-         {
 
-             get { return cvalueParam; }
 
-             set { cvalueParam = value; NotifyOfPropertyChange("CurrentValueParam"); }
 
-         }
 
-         private bool _bvalue = false;
 
-         public bool BoolValue
 
-         {
 
-             get { return _bvalue; }
 
-             set { _bvalue = value; NotifyOfPropertyChange("BoolValue"); }
 
-         }
 
-         private string _sValue = string.Empty;
 
-         public string StringValue
 
-         {
 
-             get { return _sValue; }
 
-             set { _sValue = value; NotifyOfPropertyChange("StringValue"); }
 
-         }
 
-         private bool _textSaved = true;
 
-         public bool TextSaved
 
-         {
 
-             get { return _textSaved; }
 
-             set { _textSaved = value; NotifyOfPropertyChange("TextSaved"); }
 
-         }
 
-         private string _path = string.Empty;
 
-         public string Path
 
-         {
 
-             get { return _path; }
 
-             set { _path = value; NotifyOfPropertyChange("Path"); }
 
-         }
 
-         public List<Option> Options
 
-         {
 
-             get
 
-             {
 
-                 List<Option> options = new List<Option>();
 
-                 foreach (var item in Parameter.Split(';').ToList())
 
-                 {
 
-                     Option o = new Option();
 
-                     o.Name = item;
 
-                     o.IsChecked = CurrentValue == item;
 
-                     options.Add(o);
 
-                 }
 
-                 return options;
 
-             }
 
-         }
 
-     }
 
-     public class Option: PropertyChangedBase
 
-     {
 
-         private string _Name;
 
-         public string Name
 
-         {
 
-             get { return _Name; }
 
-             set { _Name = value; this.NotifyOfPropertyChange(nameof(Name)); }
 
-         }
 
-         private string _Thick;
 
-         public string Thick
 
-         {
 
-             get { return _Thick; }
 
-             set { _Thick = value; this.NotifyOfPropertyChange(nameof(Thick)); }
 
-         }
 
-         private bool _IsChecked;
 
-         public bool IsChecked 
 
-         {
 
-             get { return _IsChecked; }
 
-             set { _IsChecked = value; this.NotifyOfPropertyChange(nameof(IsChecked)); } 
 
-         }
 
-         private bool _IsEnable=true;
 
-         public bool IsEnable
 
-         {
 
-             get { return _IsEnable; }
 
-             set { _IsEnable = value; this.NotifyOfPropertyChange(nameof(IsEnable)); }
 
-         }
 
-         private int _Index;
 
-         public int Index
 
-         {
 
-             get { return _Index; }
 
-             set { _Index = value; this.NotifyOfPropertyChange(nameof(Index)); }
 
-         }
 
-     }
 
- }
 
 
  |