RecipeSkipWaitCommandViewModel.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 RecipeSkipWaitCommandViewModel : FurnaceUIViewModelBase
  21. {
  22. private bool _isStepSkipIsChecked = false;
  23. public bool IsStepSkipIsChecked
  24. {
  25. get => _isStepSkipIsChecked;
  26. set
  27. {
  28. _isStepSkipIsChecked = value;
  29. NotifyOfPropertyChange("IsStepSkipIsChecked");
  30. }
  31. }
  32. private bool _isStepWaitIsChecked = false;
  33. public bool IsStepWaitIsChecked
  34. {
  35. get => _isStepWaitIsChecked;
  36. set
  37. {
  38. _isStepWaitIsChecked = value;
  39. NotifyOfPropertyChange("IsStepWaitIsChecked");
  40. }
  41. }
  42. public string SkipWait { get; set; }
  43. private Visibility _isStepSkipVisibility = Visibility.Visible;
  44. public Visibility IsStepSkipVisibility
  45. {
  46. get => _isStepSkipVisibility;
  47. set
  48. {
  49. _isStepSkipVisibility = value;
  50. NotifyOfPropertyChange("IsStepSkipVisibility");
  51. }
  52. }
  53. private Visibility _isStepWaitVisibility = Visibility.Visible;
  54. public Visibility IsStepWaitVisibility
  55. {
  56. get => _isStepWaitVisibility;
  57. set
  58. {
  59. _isStepWaitVisibility = value;
  60. NotifyOfPropertyChange("IsStepWaitVisibility");
  61. }
  62. }
  63. private int _stepSkipValue=0;
  64. public int StepSkipValue
  65. {
  66. get => _stepSkipValue;
  67. set
  68. {
  69. _stepSkipValue = value;
  70. NotifyOfPropertyChange("StepSkipValue");
  71. }
  72. }
  73. private int _stepWaitValue=0;
  74. public int StepWaitValue
  75. {
  76. get => _stepWaitValue;
  77. set
  78. {
  79. _stepWaitValue = value;
  80. NotifyOfPropertyChange("StepWaitValue");
  81. }
  82. }
  83. public bool IsSave { get; set; }
  84. public RecipeSkipWaitCommandViewModel()
  85. {
  86. }
  87. public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式
  88. public string RecipeType { get; set; }
  89. protected override void OnViewLoaded(object view)
  90. {
  91. base.OnViewLoaded(view);
  92. LoadData();
  93. }
  94. public void StepClick(string cmd)
  95. {
  96. switch (cmd)
  97. {
  98. case "Skip":
  99. IsStepSkipIsChecked = !IsStepSkipIsChecked;
  100. break;
  101. case "Wait":
  102. IsStepWaitIsChecked = !IsStepWaitIsChecked;
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. public string RtnString
  109. {
  110. get
  111. {
  112. StringBuilder stringBuilder = new StringBuilder();
  113. if (IsStepSkipIsChecked)
  114. {
  115. stringBuilder.Append($"Skip:{StepSkipValue}");
  116. }
  117. if (IsStepWaitIsChecked)
  118. {
  119. if (stringBuilder.Length == 0)
  120. {
  121. stringBuilder.Append($"Wait:{StepWaitValue}");
  122. }
  123. else
  124. {
  125. stringBuilder.Append($";Wait:{StepWaitValue}");
  126. }
  127. }
  128. return stringBuilder.ToString();
  129. }
  130. }
  131. private void LoadData()
  132. {
  133. if (!string.IsNullOrEmpty(SkipWait))
  134. {
  135. string[] temps = SkipWait.Split(';');
  136. foreach (var item in temps)
  137. {
  138. if (item.Contains("Skip"))
  139. {
  140. var subTemps = item.Split(':');
  141. if (subTemps.Length == 2)
  142. {
  143. IsStepSkipIsChecked = true;
  144. StepSkipValue =int.Parse(subTemps[1]);
  145. }
  146. }
  147. if (item.Contains("Wait"))
  148. {
  149. var subTemps = item.Split(':');
  150. if (subTemps.Length == 2)
  151. {
  152. IsStepWaitIsChecked = true;
  153. StepWaitValue = int.Parse(subTemps[1]);
  154. }
  155. }
  156. }
  157. }
  158. }
  159. public void TempSetSave()
  160. {
  161. IsSave = true;
  162. ((Window)GetView()).DialogResult = true;
  163. }
  164. public void TempSetCancel()
  165. {
  166. IsSave = false;
  167. ((Window)GetView()).DialogResult = false;
  168. }
  169. }
  170. }