using Aitex.Core.RT.SCCore; using Caliburn.Micro; using Caliburn.Micro.Core; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.RecipeCenter; using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using FurnaceUI.Models; using FurnaceUI.Views.Parameter; using FurnaceUI.Views.Recipes; using MECF.Framework.Common.Utilities; namespace FurnaceUI.Views.Editors { public class RecipeAUXSetViewModel : FurnaceUIViewModelBase { private ObservableCollection _aUXDatas=new ObservableCollection(); public ObservableCollection AUXDataList { get => _aUXDatas; set { _aUXDatas = value; NotifyOfPropertyChange("AUXDataList"); } } private ObservableCollection oldAUXDatas = new ObservableCollection(); public bool IsSave { get; set; } public RecipeAUXSetViewModel() { } public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式 public string RecipeType { get; set; } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); LoadData(); ((RecipeAUXSetView)view).UpdateLayout(); } private void LoadData() { oldAUXDatas.Clear(); AUXDataList.ToList().ForEach(x => oldAUXDatas.Add((AUXData)CloneUtil.CloneObject(x))); } public void CheckChangedCmd(object senderName, object sender, object typeName) { var controlName = (string)senderName; var auxDataSelect = AUXDataList.FirstOrDefault(x => x.ControlName == controlName); if (auxDataSelect != null) { auxDataSelect.IsCheck.SetValue(!auxDataSelect.IsCheck.Value); } } public void SetSave() { IsSave = true; ((Window)GetView()).DialogResult = true; } public void SetCancel() { IsSave = false; foreach (var item in AUXDataList) { var findAux = oldAUXDatas.FirstOrDefault(x => x.DisplayName == item.DisplayName); if (findAux != null) { item.UndoChanges(findAux); } else { item.UndoChanges(); } } ((Window)GetView()).DialogResult = false; } } }