AITScStringRow.xaml.cs 5.8 KB

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