RecipeLoad.xaml.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using MECF.Framework.Common.Equipment;
  2. using MECF.Framework.Common.OperationCenter;
  3. using MECF.Framework.Common.RecipeCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace CyberX8_Themes.UserControls
  20. {
  21. /// <summary>
  22. /// RecipeLoad.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class RecipeLoad : UserControl
  25. {
  26. public RecipeLoad()
  27. {
  28. InitializeComponent();
  29. }
  30. public static readonly DependencyProperty SelectedRecipeNodeProperty = DependencyProperty.Register("SelectedRecipeNode", typeof(RecipeNode), typeof(RecipeLoad),
  31. new FrameworkPropertyMetadata(null, new PropertyChangedCallback(SelectedRecipeNodeChanged)));
  32. /// <summary>
  33. /// 当前选中recipe节点
  34. /// </summary>
  35. public RecipeNode SelectedRecipeNode
  36. {
  37. get
  38. {
  39. return (RecipeNode)this.GetValue(SelectedRecipeNodeProperty);
  40. }
  41. set
  42. {
  43. this.SetValue(SelectedRecipeNodeProperty, value);
  44. }
  45. }
  46. public static readonly DependencyProperty RecipeTypeProperty = DependencyProperty.Register("RecipeType", typeof(string), typeof(RecipeLoad));
  47. /// <summary>
  48. /// Recipe类型
  49. /// </summary>
  50. public string RecipeType
  51. {
  52. get
  53. {
  54. return (string)this.GetValue(RecipeTypeProperty);
  55. }
  56. set
  57. {
  58. this.SetValue(RecipeTypeProperty, value);
  59. }
  60. }
  61. public static readonly DependencyProperty ModuleProperty = DependencyProperty.Register("Module", typeof(string), typeof(RecipeLoad));
  62. /// <summary>
  63. /// Module
  64. /// </summary>
  65. public string Module
  66. {
  67. get
  68. {
  69. return (string)this.GetValue(ModuleProperty);
  70. }
  71. set
  72. {
  73. this.SetValue(ModuleProperty, value);
  74. }
  75. }
  76. public static readonly DependencyProperty LoadEnabledProperty = DependencyProperty.Register("LoadEnabled", typeof(bool), typeof(RecipeLoad),
  77. new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  78. /// <summary>
  79. /// Load按钮可用性
  80. /// </summary>
  81. public bool LoadEnabled
  82. {
  83. get
  84. {
  85. return (bool)this.GetValue(LoadEnabledProperty);
  86. }
  87. set
  88. {
  89. this.SetValue(SelectedRecipeNodeProperty, value);
  90. }
  91. }
  92. public static readonly DependencyProperty HeadNameProperty = DependencyProperty.Register("HeadName", typeof(string), typeof(RecipeLoad));
  93. /// <summary>
  94. /// HeadName
  95. /// </summary>
  96. public string HeadName
  97. {
  98. get
  99. {
  100. return (string)this.GetValue(HeadNameProperty);
  101. }
  102. set
  103. {
  104. this.SetValue(HeadNameProperty, value);
  105. }
  106. }
  107. public static readonly DependencyProperty ReplenNameProperty = DependencyProperty.Register("ReplenName", typeof(string), typeof(RecipeLoad));
  108. /// <summary>
  109. /// ReplenName
  110. /// </summary>
  111. public string ReplenName
  112. {
  113. get
  114. {
  115. return (string)this.GetValue(ReplenNameProperty);
  116. }
  117. set
  118. {
  119. this.SetValue(ReplenNameProperty, value);
  120. }
  121. }
  122. public static readonly DependencyProperty RecipeModeValueProperty = DependencyProperty.Register(
  123. "RecipeModeValue", typeof(string), typeof(RecipeLoad));
  124. /// <summary>
  125. /// OpertationModeValue
  126. /// </summary>
  127. public string RecipeModeValue
  128. {
  129. get
  130. {
  131. return (string)this.GetValue(RecipeModeValueProperty);
  132. }
  133. set
  134. {
  135. this.SetValue(RecipeModeValueProperty, value);
  136. }
  137. }
  138. private static void SelectedRecipeNodeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  139. {
  140. if(e.NewValue!=null)
  141. {
  142. d.SetValue(LoadEnabledProperty, true);
  143. }
  144. else
  145. {
  146. d.SetValue(LoadEnabledProperty, false);
  147. }
  148. }
  149. private void LoadRecipe_Click(object sender, RoutedEventArgs e)
  150. {
  151. if (RecipeType == "rds")
  152. {
  153. InvokeClient.Instance.Service.DoOperation($"{Module}.LoadRecipe", SelectedRecipeNode.RecipeFullFileName, ReplenName);
  154. }
  155. else
  156. {
  157. InvokeClient.Instance.Service.DoOperation($"{Module}.LoadRecipe", SelectedRecipeNode.RecipeFullFileName);
  158. }
  159. }
  160. }
  161. }