AITScBoolRow.xaml.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. using Brush = System.Drawing.Brush;
  16. namespace Aitex.Sorter.UI.Controls
  17. {
  18. /// <summary>
  19. /// AITScBoolRow.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class AITScBoolRow : UserControl
  22. {
  23. public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
  24. "Command", typeof(ICommand), typeof(AITScBoolRow),
  25. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  26. public ICommand Command
  27. {
  28. get
  29. {
  30. return (ICommand)this.GetValue(CommandProperty);
  31. }
  32. set
  33. {
  34. this.SetValue(CommandProperty, value);
  35. }
  36. }
  37. public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
  38. "NameWidth", typeof(int), typeof(AITScBoolRow),
  39. new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
  40. public int NameWidth
  41. {
  42. get
  43. {
  44. return (int)this.GetValue(NameWidthProperty);
  45. }
  46. set
  47. {
  48. this.SetValue(NameWidthProperty, value);
  49. }
  50. }
  51. public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
  52. "FeedbackWidth", typeof(int), typeof(AITScBoolRow),
  53. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  54. public int FeedbackWidth
  55. {
  56. get
  57. {
  58. return (int)this.GetValue(FeedbackWidthProperty);
  59. }
  60. set
  61. {
  62. this.SetValue(FeedbackWidthProperty, value);
  63. }
  64. }
  65. public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
  66. "SetPointWidth", typeof(int), typeof(AITScBoolRow),
  67. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  68. public int SetPointWidth
  69. {
  70. get
  71. {
  72. return (int)this.GetValue(SetPointWidthProperty);
  73. }
  74. set
  75. {
  76. this.SetValue(SetPointWidthProperty, value);
  77. }
  78. }
  79. public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
  80. "CommandWidth", typeof(int), typeof(AITScBoolRow),
  81. new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
  82. public int CommandWidth
  83. {
  84. get
  85. {
  86. return (int)this.GetValue(CommandWidthProperty);
  87. }
  88. set
  89. {
  90. this.SetValue(CommandWidthProperty, value);
  91. }
  92. }
  93. public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
  94. "ScId", typeof(string), typeof(AITScBoolRow),
  95. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  96. public string ScId
  97. {
  98. get
  99. {
  100. return (string)this.GetValue(ScIdProperty);
  101. }
  102. set
  103. {
  104. this.SetValue(ScIdProperty, value);
  105. }
  106. }
  107. public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
  108. "ScName", typeof(string), typeof(AITScBoolRow),
  109. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  110. public string ScName
  111. {
  112. get
  113. {
  114. return (string)this.GetValue(ScNameProperty);
  115. }
  116. set
  117. {
  118. this.SetValue(ScNameProperty, value);
  119. }
  120. }
  121. public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
  122. "ScFeedback", typeof(bool), typeof(AITScBoolRow),
  123. new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  124. public bool ScFeedback
  125. {
  126. get
  127. {
  128. return (bool)this.GetValue(ScFeedbackProperty);
  129. }
  130. set
  131. {
  132. this.SetValue(ScFeedbackProperty, value);
  133. }
  134. }
  135. public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
  136. "ScSetPoint", typeof(bool), typeof(AITScBoolRow),
  137. new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  138. public bool ScSetPoint
  139. {
  140. get
  141. {
  142. return (bool)this.GetValue(ScSetPointProperty);
  143. }
  144. set
  145. {
  146. this.SetValue(ScSetPointProperty, value);
  147. }
  148. }
  149. public AITScBoolRow()
  150. {
  151. InitializeComponent();
  152. }
  153. protected override void OnRender(DrawingContext drawingContext)
  154. {
  155. base.OnRender(drawingContext);
  156. RectangleSetPoint.Fill = ScSetPoint == ScFeedback
  157. ? new SolidColorBrush(Color.FromRgb(0x95, 0xB3, 0xD7))
  158. : new SolidColorBrush(Colors.Yellow);
  159. }
  160. private void Button_Click(object sender, RoutedEventArgs e)
  161. {
  162. Command.Execute(new object[] { ScId, ScSetPoint.ToString() });
  163. }
  164. }
  165. }