RecipeLoadDose.xaml.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using CyberX8_Core;
  2. using MECF.Framework.Common.CommonData.Reservoir;
  3. using MECF.Framework.Common.OperationCenter;
  4. using MECF.Framework.Common.RecipeCenter;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.Windows.Data;
  15. using System.Windows.Documents;
  16. using System.Windows.Input;
  17. using System.Windows.Media;
  18. using System.Windows.Media.Imaging;
  19. using System.Windows.Navigation;
  20. using System.Windows.Shapes;
  21. namespace CyberX8_Themes.UserControls
  22. {
  23. /// <summary>
  24. /// RecipeLoadDose.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class RecipeLoadDose : UserControl
  27. {
  28. public RecipeLoadDose()
  29. {
  30. InitializeComponent();
  31. }
  32. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  33. "ModuleName", typeof(string), typeof(RecipeLoadDose), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  34. /// <summary>
  35. /// 模块名称
  36. /// </summary>
  37. public string ModuleName
  38. {
  39. get
  40. {
  41. return (string)this.GetValue(ModuleNameProperty);
  42. }
  43. set
  44. {
  45. this.SetValue(ModuleNameProperty, value);
  46. }
  47. }
  48. public static readonly DependencyProperty ReplenNumProperty = DependencyProperty.Register(
  49. "ReplenNum", typeof(int), typeof(RecipeLoadDose), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  50. /// <summary>
  51. /// Replen数量
  52. /// </summary>
  53. public int ReplenNum
  54. {
  55. get
  56. {
  57. return (int)this.GetValue(ReplenNumProperty);
  58. }
  59. set
  60. {
  61. this.SetValue(ReplenNumProperty, value);
  62. }
  63. }
  64. public static readonly DependencyProperty RecipeTypeProperty = DependencyProperty.Register("RecipeType", typeof(string), typeof(RecipeLoadDose));
  65. /// <summary>
  66. /// Recipe类型
  67. /// </summary>
  68. public string RecipeType
  69. {
  70. get
  71. {
  72. return (string)this.GetValue(RecipeTypeProperty);
  73. }
  74. set
  75. {
  76. this.SetValue(RecipeTypeProperty, value);
  77. }
  78. }
  79. public static readonly DependencyProperty RecipeNodesProperty = DependencyProperty.Register("RecipeNodes", typeof(ObservableCollection<RecipeNode>), typeof(RecipeLoadDose));
  80. /// <summary>
  81. /// Reicpe节点
  82. /// </summary>
  83. public ObservableCollection<RecipeNode> RecipeNodes
  84. {
  85. get
  86. {
  87. return (ObservableCollection<RecipeNode>)this.GetValue(RecipeNodesProperty);
  88. }
  89. set
  90. {
  91. this.SetValue(RecipeNodesProperty, value);
  92. }
  93. }
  94. public static readonly DependencyProperty RecipeLstProperty = DependencyProperty.Register(
  95. "RecipeLst", typeof(ObservableCollection<string>), typeof(RecipeLoadDose), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  96. /// <summary>
  97. /// Recipe列表
  98. /// </summary>
  99. public ObservableCollection<string> RecipeLst
  100. {
  101. get
  102. {
  103. return (ObservableCollection<string>)this.GetValue(RecipeLstProperty);
  104. }
  105. set
  106. {
  107. this.SetValue(RecipeLstProperty, value);
  108. }
  109. }
  110. public static readonly DependencyProperty ReplenDatasProperty = DependencyProperty.Register(
  111. "ReplenDatas", typeof(ObservableCollection<ReplenData>), typeof(RecipeLoadDose), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  112. /// <summary>
  113. /// ReplenDatas
  114. /// </summary>
  115. public ObservableCollection<ReplenData> ReplenDatas
  116. {
  117. get
  118. {
  119. return (ObservableCollection<ReplenData>)this.GetValue(ReplenDatasProperty);
  120. }
  121. set
  122. {
  123. this.SetValue(ReplenDatasProperty, value);
  124. }
  125. }
  126. /// <summary>
  127. /// 加载Recipe列表
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void Self_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  132. {
  133. if (e.NewValue != null)
  134. {
  135. bool result = (bool)e.NewValue;
  136. if (result)
  137. {
  138. if (!string.IsNullOrEmpty(RecipeType))
  139. {
  140. RecipeNodes = RecipeClient.Instance.Service.GetRecipesByType(RecipeType);
  141. UpdateRecipeList();
  142. }
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// DosingRecipe选择
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. private void SelectRecipe1_Click(object sender, RoutedEventArgs e)
  152. {
  153. RecipeNode recipeNode = (RecipeNode)comboBox1.SelectedItem;
  154. if (recipeNode != null)
  155. {
  156. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.LoadDosingRecipe", recipeNode.RecipeFullFileName, "Replen1", recipeNode.FileName);
  157. }
  158. }
  159. private void SelectRecipe2_Click(object sender, RoutedEventArgs e)
  160. {
  161. RecipeNode recipeNode = (RecipeNode)comboBox2.SelectedItem;
  162. if(recipeNode != null)
  163. {
  164. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.LoadDosingRecipe", recipeNode.RecipeFullFileName, "Replen2", recipeNode.FileName);
  165. }
  166. }
  167. private void SelectRecipe3_Click(object sender, RoutedEventArgs e)
  168. {
  169. RecipeNode recipeNode = (RecipeNode)comboBox3.SelectedItem;
  170. if (recipeNode != null)
  171. {
  172. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.LoadDosingRecipe", recipeNode.RecipeFullFileName, "Replen3", recipeNode.FileName);
  173. }
  174. }
  175. private void SelectRecipe4_Click(object sender, RoutedEventArgs e)
  176. {
  177. RecipeNode recipeNode = (RecipeNode)comboBox4.SelectedItem;
  178. if (recipeNode != null)
  179. {
  180. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.LoadDosingRecipe", recipeNode.RecipeFullFileName, "Replen4", recipeNode.FileName);
  181. }
  182. }
  183. /// <summary>
  184. /// 更新recipe下拉列表
  185. /// </summary>
  186. private void UpdateRecipeList()
  187. {
  188. if (RecipeLst == null) RecipeLst = new ObservableCollection<string>();
  189. RecipeLst.Clear();
  190. foreach(var item in RecipeNodes[0].Children)
  191. {
  192. RecipeLst.Add(item.Name);
  193. }
  194. }
  195. }
  196. }