| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | 
							- using Caliburn.Micro.Core;
 
- using MECF.Framework.Common.RecipeCenter;
 
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
 
- using MECF.Framework.UI.Client.CenterViews.Dialogs;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using FurnaceUI.Models;
 
- namespace FurnaceUI.Views.Editors
 
- {
 
-     public class RecipeGASSettingMFCAlarmViewModel : FurnaceUIViewModelBase
 
-     {
 
-         ConfigNode currentNode = SystemConfigProvider.Instance.GetConfig(true);
 
-         public ConfigNode CurrentNode
 
-         {
 
-             get { return currentNode; }
 
-             set { currentNode = value; this.NotifyOfPropertyChange(nameof(CurrentNode)); }
 
-         }
 
-         private List<ConfigItem> currenItems;
 
-         public List<ConfigItem> CurrenItems
 
-         {
 
-             get { return currenItems; }
 
-             set { currenItems = value; this.NotifyOfPropertyChange(nameof(CurrenItems)); }
 
-         }
 
-         public string CurrentValue { get; set; }
 
-         public RecipeGASSettingMFCAlarmViewModel(string strCurrentValue)
 
-         {
 
-             CurrentValue = strCurrentValue;
 
-         }
 
-         private Visibility visibilityShow;
 
-         public Visibility VisibilityShow
 
-         {
 
-             get => visibilityShow;
 
-             set
 
-             {
 
-                 visibilityShow = value;
 
-                 NotifyOfPropertyChange(nameof(VisibilityShow));
 
-             }
 
-         }
 
-         protected override void OnInitialize()
 
-         {
 
-             base.OnInitialize();
 
-             CurrentNode = FindNodeByName(CurrentNode, "PM1.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch");
 
-             currentNode.SubNodes.Insert(0, new ConfigNode() { Name = "None", IsSelected = false }); ;//增加选项0
 
-             GetDataOfConfigItems(CurrentNode);
 
-             if (CurrentValue == "None")
 
-             {
 
-                 CurrenItems = CurrentNode.SubNodes[0].Items;
 
-                 CurrentNode.SubNodes[0].IsSelected = true;
 
-                 VisibilityShow = Visibility.Hidden;
 
-             }
 
-             else
 
-             {
 
-                 CurrenItems = CurrentNode.SubNodes[int.Parse(CurrentValue)].Items;
 
-                 CurrentNode.SubNodes[int.Parse(CurrentValue)].IsSelected = true;
 
-                 VisibilityShow = Visibility.Visible;
 
-             }
 
-         }
 
-         private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)
 
-         {
 
-             string strCates = strName.Split('.')[0];
 
-             ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);
 
-             if (node == null)
 
-             {
 
-                 return parentNode;
 
-             }
 
-             else
 
-                 return FindNodeByName(node, strName.Replace(strCates + ".", ""));
 
-         }
 
-         private void GetDataOfConfigItems(ConfigNode node)
 
-         {
 
-             if (node.Items == null && node.SubNodes == null) return;
 
-             if(node.Items.Count<=0)
 
-             {
 
-                 foreach (var item in node.SubNodes)
 
-                 {
 
-                     GetDataOfConfigItems(item);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 foreach (var item in node.Items)
 
-                 {
 
-                     string key = String.Format("{0}.{1}.{2}", node.Path,node.Name, item.Name);
 
-                     item.CurrentValue = SystemConfigProvider.Instance.GetValueByName(key);
 
-                     item.Path = key;
 
-                     if (item.Type == DataType.Bool)
 
-                     {
 
-                         bool value;
 
-                         if (bool.TryParse(item.CurrentValue, out value))
 
-                         {
 
-                             item.BoolValue = value;
 
-                             item.CurrentValue = value ? "Yes" : "No";
 
-                         }
 
-                     }
 
-                     else
 
-                         item.StringValue = item.CurrentValue;
 
-                 }
 
-             }
 
-         }
 
-         public void MenuCommand(object obj, object menuLevel)
 
-         {
 
-             RadioButton radioButton = obj as RadioButton;
 
-             CurrentValue = radioButton.Content.ToString();
 
-             if (CurrentValue == "None")
 
-             {
 
-                 CurrenItems = CurrentNode.SubNodes[0].Items;
 
-                 VisibilityShow = Visibility.Hidden;
 
-             }
 
-             else
 
-             {
 
-                 CurrenItems = CurrentNode.SubNodes[int.Parse(CurrentValue)].Items;
 
-                 VisibilityShow = Visibility.Visible;
 
-             }
 
-         }
 
-         public void Close()
 
-         {
 
-             ((Window)GetView()).DialogResult = false;
 
-         }
 
-         public void Save()
 
-         {
 
-             ((Window)GetView()).DialogResult = true;
 
-         }
 
-     }
 
- }
 
 
  |