RecipeLoaderCommandViewModel.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 System.Windows.Controls;
  18. namespace FurnaceUI.Views.Editors
  19. {
  20. public class RecipeLoaderCommandViewModel : FurnaceUIViewModelBase
  21. {
  22. public ObservableCollection<BoatCommand> NameList { get; set; } = new ObservableCollection<BoatCommand>();
  23. private Dictionary<string, string> boatCmd = new Dictionary<string, string>();
  24. public bool IsSave { get; set; }
  25. private string _description = "";
  26. public string Description
  27. {
  28. get => _description;
  29. set
  30. {
  31. _description = value;
  32. NotifyOfPropertyChange(nameof(Description));
  33. }
  34. }
  35. public string SelectedCmd { get; set; }
  36. public string ReturnString { get; set; } = "";
  37. public bool SetRecipeProcessEditViewEnable { get; set; } = true;
  38. public RecipeLoaderCommandViewModel()
  39. {
  40. CreateRadioButton();
  41. }
  42. private void CreateRadioButton()
  43. {
  44. boatCmd.Clear();
  45. boatCmd.Add("None", "");
  46. boatCmd.Add("Boat Load", "The boat is loaded in the furnace.(Speed set avai lable)");
  47. boatCmd.Add("Boat Unload", "The boat is unloaded f rom the furnace.(Speed set available)");
  48. boatCmd.Add("Boat Loader Home", "Boat Loader ismoved to the home position.");
  49. boatCmd.Add("Boat Rotate", "The boat is rotated.");
  50. boatCmd.Add("Boat Rotate Stop", "The rotat ion of the boat is stopped and R-axis is moved to the home position.");
  51. boatCmd.Add("Boat CAP2", "Boat Loader is moved to CAP2 position.(CAP2 : CAP position in condition to not seal the reactor)");
  52. boatCmd.Add("Stop(Include R-axis)", "Boat Loader is stopped. (Include R-axis.");
  53. NameList.Clear();
  54. foreach (var item in boatCmd.Keys)
  55. {
  56. if (item != "None")
  57. {
  58. NameList.Add(new BoatCommand()
  59. {
  60. Name = item,
  61. Description = boatCmd[item]
  62. });
  63. }
  64. }
  65. }
  66. public void RdoChecked(object sender)
  67. {
  68. Description = boatCmd[(string)((RadioButton)sender).Content];
  69. if ((bool)((RadioButton)sender).IsChecked)
  70. {
  71. ReturnString = (string)((RadioButton)sender).Content;
  72. }
  73. }
  74. public bool IsEnable
  75. {
  76. get
  77. {
  78. if (SetRecipeProcessEditViewEnable)
  79. {
  80. return CGlobal.RecipeProcessEditViewEnable;//是否是View模式
  81. }
  82. else
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. public string RecipeType { get; set; }
  89. protected override void OnViewLoaded(object view)
  90. {
  91. base.OnViewLoaded(view);
  92. LoadData();
  93. }
  94. private void LoadData()
  95. {
  96. if (!string.IsNullOrEmpty(SelectedCmd) && NameList.Count > 0)
  97. {
  98. var item = NameList.Where(x => x.Name == SelectedCmd).FirstOrDefault();
  99. if (item != null)
  100. {
  101. item.IsChecked = true;
  102. }
  103. ReturnString = SelectedCmd;
  104. }
  105. }
  106. public void TempSetSave()
  107. {
  108. IsSave = true;
  109. ((Window)GetView()).DialogResult = true;
  110. }
  111. public void TempSetCancel()
  112. {
  113. IsSave = false;
  114. ((Window)GetView()).DialogResult = false;
  115. }
  116. }
  117. public class BoatCommand : PropertyChangedBase
  118. {
  119. private string _name;
  120. public string Name
  121. {
  122. get => _name;
  123. set
  124. {
  125. _name = value;
  126. NotifyOfPropertyChange(nameof(Name));
  127. }
  128. }
  129. private string _description;
  130. public string Description
  131. {
  132. get => _description;
  133. set
  134. {
  135. _description = value;
  136. NotifyOfPropertyChange(nameof(Description));
  137. }
  138. }
  139. private bool _isChecked;
  140. public bool IsChecked
  141. {
  142. get => _isChecked;
  143. set
  144. {
  145. _isChecked = value;
  146. NotifyOfPropertyChange(nameof(IsChecked));
  147. }
  148. }
  149. }
  150. }