WaferPresenceControl.xaml.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.UI.MVVM;
  3. using Aitex.Core.Utilities;
  4. using MECF.Framework.Common.CommonData.PUF;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.OperationCenter;
  7. using MECF.Framework.Common.Persistent.SRD;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Runtime.InteropServices;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows;
  16. using System.Windows.Controls;
  17. using System.Windows.Data;
  18. using System.Windows.Documents;
  19. using System.Windows.Input;
  20. using System.Windows.Media;
  21. using System.Windows.Media.Imaging;
  22. using System.Windows.Navigation;
  23. using System.Windows.Shapes;
  24. namespace CyberX8_Themes.UserControls
  25. {
  26. /// <summary>
  27. /// WaferPresenceControl.xaml 的交互逻辑
  28. /// </summary>
  29. public partial class WaferPresenceControl : UserControl
  30. {
  31. /// <summary>
  32. /// 构造函数
  33. /// </summary>
  34. public WaferPresenceControl()
  35. {
  36. KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);
  37. InitializeComponent();
  38. }
  39. #region 属性
  40. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  41. "ModuleName", typeof(string), typeof(WaferPresenceControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  42. /// <summary>
  43. /// 模块名称
  44. /// </summary>
  45. public string ModuleName
  46. {
  47. get
  48. {
  49. return (string)this.GetValue(ModuleNameProperty);
  50. }
  51. set
  52. {
  53. this.SetValue(ModuleNameProperty, value);
  54. }
  55. }
  56. public static readonly DependencyProperty InputLowThresholdProperty = DependencyProperty.Register(
  57. "InputLowThreshold", typeof(double), typeof(WaferPresenceControl), new FrameworkPropertyMetadata(0.00, FrameworkPropertyMetadataOptions.AffectsRender));
  58. /// <summary>
  59. /// InputLowThreshold
  60. /// </summary>
  61. public double InputLowThreshold
  62. {
  63. get
  64. {
  65. return (double)this.GetValue(InputLowThresholdProperty);
  66. }
  67. set
  68. {
  69. this.SetValue(InputLowThresholdProperty, value);
  70. }
  71. }
  72. public static readonly DependencyProperty InputHighThresholdProperty = DependencyProperty.Register(
  73. "InputHighThreshold", typeof(double), typeof(WaferPresenceControl), new FrameworkPropertyMetadata(0.00, FrameworkPropertyMetadataOptions.AffectsRender));
  74. /// <summary>
  75. /// InputHighThreshold
  76. /// </summary>
  77. public double InputHighThreshold
  78. {
  79. get
  80. {
  81. return (double)this.GetValue(InputHighThresholdProperty);
  82. }
  83. set
  84. {
  85. this.SetValue(InputHighThresholdProperty, value);
  86. }
  87. }
  88. public static readonly DependencyProperty InputEmptyThresholdProperty = DependencyProperty.Register(
  89. "InputEmptyThreshold", typeof(double), typeof(WaferPresenceControl), new FrameworkPropertyMetadata(0.00, FrameworkPropertyMetadataOptions.AffectsRender));
  90. /// <summary>
  91. /// InputEmptyThreshold
  92. /// </summary>
  93. public double InputEmptyThreshold
  94. {
  95. get
  96. {
  97. return (double)this.GetValue(InputEmptyThresholdProperty);
  98. }
  99. set
  100. {
  101. this.SetValue(InputEmptyThresholdProperty, value);
  102. }
  103. }
  104. public static readonly DependencyProperty PersistentValueProperty = DependencyProperty.Register(
  105. "PersistentValue", typeof(SRDPersistentValue), typeof(WaferPresenceControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));
  106. /// <summary>
  107. /// PersistentValue
  108. /// </summary>
  109. public SRDPersistentValue PersistentValue
  110. {
  111. get
  112. {
  113. return (SRDPersistentValue)this.GetValue(PersistentValueProperty);
  114. }
  115. set
  116. {
  117. this.SetValue(PersistentValueProperty, value);
  118. }
  119. }
  120. public static readonly DependencyProperty IsWaferPresenceProperty = DependencyProperty.Register(
  121. "IsWaferPresence", typeof(bool), typeof(WaferPresenceControl), new FrameworkPropertyMetadata(true, new PropertyChangedCallback(OnIsWaferPresenceChanged)));
  122. /// <summary>
  123. /// IsWaferPresence
  124. /// </summary>
  125. public bool IsWaferPresence
  126. {
  127. get
  128. {
  129. return (bool)this.GetValue(IsWaferPresenceProperty);
  130. }
  131. set
  132. {
  133. this.SetValue(IsWaferPresenceProperty, value);
  134. }
  135. }
  136. private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  137. {
  138. if (e.NewValue != null)
  139. {
  140. SRDPersistentValue data = (SRDPersistentValue)e.NewValue;
  141. d.SetValue(InputHighThresholdProperty, data.WellPlacedHighThreshold);
  142. d.SetValue(InputLowThresholdProperty, data.WellPlacedLowThreshold);
  143. d.SetValue(InputEmptyThresholdProperty, data.EmptyThreshold);
  144. }
  145. }
  146. private static void OnIsWaferPresenceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  147. {
  148. WaferPresenceControl waferPresenceControl = (WaferPresenceControl)d;
  149. if (e.NewValue != null)
  150. {
  151. bool data = (bool)e.NewValue;
  152. waferPresenceControl.checkbox1.IsChecked = !data;
  153. }
  154. }
  155. //private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  156. //{
  157. // if (e.NewValue != null)
  158. // {
  159. // bool data = (bool)e.NewValue;
  160. // d.SetValue(IsWaferPresenceProperty, data);
  161. // }
  162. //}
  163. #endregion
  164. [IgnorePropertyChange]
  165. public ICommand KeyDownCommand
  166. {
  167. get;
  168. private set;
  169. }
  170. private void KeyDownAction(object[] param)
  171. {
  172. if (param.Length >= 2)
  173. {
  174. if (double.TryParse(param[1].ToString(), out double paramValue))
  175. {
  176. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.KeyDown", param[0].ToString(), paramValue);
  177. }
  178. }
  179. }
  180. private void CheckBox_Click(object sender, RoutedEventArgs e)
  181. {
  182. CheckBox checkBox = (sender as CheckBox);
  183. if (string.IsNullOrEmpty(ModuleName)) return;
  184. if ((bool)checkBox.IsChecked)
  185. {
  186. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.UpdateIsWaferPresenceAction", false);
  187. }
  188. else
  189. {
  190. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.UpdateIsWaferPresenceAction", true);
  191. }
  192. }
  193. }
  194. }