AITDisplayWaferModeRow.xaml.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace Aitex.Sorter.UI.Controls
  16. {
  17. /// <summary>
  18. /// AITDisplayWaferModeRow.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class AITDisplayWaferModeRow : UserControl
  21. {
  22. public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
  23. "Command", typeof(ICommand), typeof(AITDisplayWaferModeRow),
  24. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  25. public ICommand Command
  26. {
  27. get
  28. {
  29. return (ICommand)this.GetValue(CommandProperty);
  30. }
  31. set
  32. {
  33. this.SetValue(CommandProperty, value);
  34. }
  35. }
  36. public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
  37. "NameWidth", typeof(int), typeof(AITDisplayWaferModeRow),
  38. new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
  39. public int NameWidth
  40. {
  41. get
  42. {
  43. return (int)this.GetValue(NameWidthProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(NameWidthProperty, value);
  48. }
  49. }
  50. public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
  51. "FeedbackWidth", typeof(int), typeof(AITDisplayWaferModeRow),
  52. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  53. public int FeedbackWidth
  54. {
  55. get
  56. {
  57. return (int)this.GetValue(FeedbackWidthProperty);
  58. }
  59. set
  60. {
  61. this.SetValue(FeedbackWidthProperty, value);
  62. }
  63. }
  64. public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
  65. "SetPointWidth", typeof(int), typeof(AITDisplayWaferModeRow),
  66. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  67. public int SetPointWidth
  68. {
  69. get
  70. {
  71. return (int)this.GetValue(SetPointWidthProperty);
  72. }
  73. set
  74. {
  75. this.SetValue(SetPointWidthProperty, value);
  76. }
  77. }
  78. public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
  79. "CommandWidth", typeof(int), typeof(AITDisplayWaferModeRow),
  80. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  81. public int CommandWidth
  82. {
  83. get
  84. {
  85. return (int)this.GetValue(CommandWidthProperty);
  86. }
  87. set
  88. {
  89. this.SetValue(CommandWidthProperty, value);
  90. }
  91. }
  92. public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
  93. "ScId", typeof(string), typeof(AITDisplayWaferModeRow),
  94. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  95. public string ScId
  96. {
  97. get
  98. {
  99. return (string)this.GetValue(ScIdProperty);
  100. }
  101. set
  102. {
  103. this.SetValue(ScIdProperty, value);
  104. }
  105. }
  106. public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
  107. "ScName", typeof(string), typeof(AITDisplayWaferModeRow),
  108. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  109. public string ScName
  110. {
  111. get
  112. {
  113. return (string)this.GetValue(ScNameProperty);
  114. }
  115. set
  116. {
  117. this.SetValue(ScNameProperty, value);
  118. }
  119. }
  120. public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
  121. "ScFeedback", typeof(double), typeof(AITDisplayWaferModeRow),
  122. new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
  123. public double ScFeedback
  124. {
  125. get
  126. {
  127. return (double)this.GetValue(ScFeedbackProperty);
  128. }
  129. set
  130. {
  131. this.SetValue(ScFeedbackProperty, value);
  132. }
  133. }
  134. public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
  135. "ScSetPoint", typeof(double), typeof(AITDisplayWaferModeRow),
  136. new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
  137. public double ScSetPoint
  138. {
  139. get
  140. {
  141. return (double)this.GetValue(ScSetPointProperty);
  142. }
  143. set
  144. {
  145. this.SetValue(ScSetPointProperty, value);
  146. }
  147. }
  148. public AITDisplayWaferModeRow()
  149. {
  150. InitializeComponent();
  151. }
  152. private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
  153. {
  154. e.Handled = !IsTextAllowed(e.Text);
  155. }
  156. private static bool IsTextAllowed(string text)
  157. {
  158. Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
  159. return !regex.IsMatch(text);
  160. }
  161. private void Button_Click(object sender, RoutedEventArgs e)
  162. {
  163. Command.Execute(new object[] { ScId, ScSetPoint.ToString() });
  164. }
  165. }
  166. }