RecipeAUXSetViewModel.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using Aitex.Core.RT.SCCore;
  2. using Caliburn.Micro;
  3. using Caliburn.Micro.Core;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using FurnaceUI.Models;
  15. using FurnaceUI.Views.Parameter;
  16. using FurnaceUI.Views.Recipes;
  17. using MECF.Framework.Common.Utilities;
  18. namespace FurnaceUI.Views.Editors
  19. {
  20. public class RecipeAUXSetViewModel : FurnaceUIViewModelBase
  21. {
  22. private ObservableCollection<AUXData> _aUXDatas=new ObservableCollection<AUXData>();
  23. public ObservableCollection<AUXData> AUXDataList
  24. {
  25. get => _aUXDatas;
  26. set
  27. {
  28. _aUXDatas = value;
  29. NotifyOfPropertyChange("AUXDataList");
  30. }
  31. }
  32. private ObservableCollection<AUXData> oldAUXDatas = new ObservableCollection<AUXData>();
  33. public bool IsSave { get; set; }
  34. public RecipeAUXSetViewModel()
  35. {
  36. }
  37. public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式
  38. public string RecipeType { get; set; }
  39. protected override void OnViewLoaded(object view)
  40. {
  41. base.OnViewLoaded(view);
  42. LoadData();
  43. ((RecipeAUXSetView)view).UpdateLayout();
  44. }
  45. private void LoadData()
  46. {
  47. oldAUXDatas.Clear();
  48. AUXDataList.ToList().ForEach(x => oldAUXDatas.Add((AUXData)CloneUtil.CloneObject(x)));
  49. }
  50. public void CheckChangedCmd(object senderName, object sender, object typeName)
  51. {
  52. var controlName = (string)senderName;
  53. var auxDataSelect = AUXDataList.FirstOrDefault(x => x.ControlName == controlName);
  54. if (auxDataSelect != null)
  55. {
  56. auxDataSelect.IsCheck.SetValue(!auxDataSelect.IsCheck.Value);
  57. }
  58. }
  59. public void SetSave()
  60. {
  61. IsSave = true;
  62. ((Window)GetView()).DialogResult = true;
  63. }
  64. public void SetCancel()
  65. {
  66. IsSave = false;
  67. foreach (var item in AUXDataList)
  68. {
  69. var findAux = oldAUXDatas.FirstOrDefault(x => x.DisplayName == item.DisplayName);
  70. if (findAux != null)
  71. {
  72. item.UndoChanges(findAux);
  73. }
  74. else
  75. {
  76. item.UndoChanges();
  77. }
  78. }
  79. ((Window)GetView()).DialogResult = false;
  80. }
  81. }
  82. }