AITScBoolRow.xaml.cs 5.4 KB

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