123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- 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 MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
- using FurnaceUI.Models;
- namespace FurnaceUI.Views.Editors
- {
- public class TempAllZoneValueSetViewModel : FurnaceUIViewModelBase
- {
- public bool IsSave { get; set; } = false;
- public List<ConfigItem> CurrentNodeItems { get; set; } = new List<ConfigItem>();
- private ConfigNode _currentNode;
- public ConfigNode CurrentNode
- {
- get { return _currentNode; }
- set { _currentNode = value; this.NotifyOfPropertyChange(nameof(CurrentNode)); }
- }
- public ConfigNode SelectedNode { get; set; }
- public string RecipeType { get; set; }
- public Visibility IsVisibilityContinue { get; set; } = Visibility.Visible;
- protected override void OnInitialize()
- {
- base.OnInitialize();
- //if (RecipeType == "Sub" || RecipeType == "Abort Sub" || RecipeType == "Abort")
- // IsVisibilityContinue = Visibility.Visible;
- GetDataOfConfigItems();
- }
- //private bool isValueButtonEnable;
- //public bool IsValueButtonEnable
- //{
- // get
- // {
- // isValueButtonEnable = true;
- // for (int i = 0; i < 5; i++)
- // {
- // if (string.IsNullOrEmpty((((TempAllZoneValueSetView)(((Window)GetView()).Content)).FindName($"Txt{i + 1}") as TextBox).Text))
- // {
- // isValueButtonEnable = false;
- // break;
- // }
- // }
- // return isValueButtonEnable;
- // }
- // set { isValueButtonEnable = value; this.NotifyOfPropertyChange(nameof(IsValueButtonEnable)); }
- //}
- private bool _isValueButtonEnable;
- public bool IsValueButtonEnable
- {
- get => _isValueButtonEnable;
- set
- {
- _isValueButtonEnable = value;
- NotifyOfPropertyChange("IsValueButtonEnable");
- }
- }
- private string _TempModel;
- public string TempModel
- {
- get { return _TempModel; }
- set
- {
- _TempModel = value;
- NotifyOfPropertyChange("TempModel");
- }
- }
- public bool IsEnable => false;// CGlobal.RecipeProcessEditViewEnable;//是否是View模式
- public void ValueTextChanged()
- {
- //this.NotifyOfPropertyChange(nameof(IsValueButtonEnable));
- }
- private void GetDataOfConfigItems()
- {
- ConfigNode rootNode = SystemConfigProvider.Instance.GetConfig(true);
- CurrentNode = FindNodeByName(rootNode, "PM1.RecipeEditParameter.TempSetting");
- foreach (var node in CurrentNode.SubNodes)
- {
- List<string> temperature = new List<string>();
- CurrentNodeItems = node.Items;
- foreach (var item in node.Items)
- {
- string strPath = $"PM1.RecipeEditParameter.TempSetting.{node.Name}.{item.Name}";
- item.CurrentValue = SystemConfigProvider.Instance.GetValueByName(strPath);
- item.Path = strPath;
- }
- }
- }
- 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 + ".", ""));
- }
- public void SetTempValue(object obj)
- {
- if (obj is ConfigNode)
- {
- IsValueButtonEnable = false;
- TempModel = "Temp";
- SelectedNode = obj as ConfigNode;
- for (int i = 0; i < SelectedNode.Items.Count; i++)
- {
- (((TempAllZoneValueSetView)(((Window)GetView()).Content)).FindName($"Txt{i + 1}") as TextBox).Text = SelectedNode.Items[i].CurrentValue;
- }
- }
- else if (obj.ToString() == "Continue")
- {
- ConfigNode node = new ConfigNode();
- node.Items = new List<ConfigItem>();
- for (int i = 0; i < 5; i++)
- {
- node.Items.Add(new ConfigItem() { CurrentValue = obj.ToString() });
- }
- SelectedNode = node;
- }
- else
- {
- IsValueButtonEnable = true;
- TempModel = "Value";
- for (int i = 0; i < 5; i++)
- {
- (((TempAllZoneValueSetView)(((Window)GetView()).Content)).FindName($"Txt{i + 1}") as TextBox).Text = "";
- }
- }
- }
- public void SaveCmd()
- {
- if (TempModel == "Value")
- {
- ConfigNode node = new ConfigNode();
- node.Items = new List<ConfigItem>();
- node.Items.Add(new ConfigItem() { CurrentValue = (((TempAllZoneValueSetView)(((Window)GetView()).Content)).FindName($"Txt6") as TextBox).Text });
- SelectedNode = node;
- }
- IsSave = true;
- ((Window)GetView()).DialogResult = true;
- }
- public void CloseCmd()
- {
- IsSave = false;
- ((Window)GetView()).DialogResult = false;
- }
- }
- }
|