WpfWindturbine.xaml.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  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 IntelligentControlForsx.MyControls
  16. {
  17. /// <summary>
  18. /// WpfWindturbine.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class WpfWindturbine : UserControl
  21. {
  22. public WpfWindturbine()
  23. {
  24. InitializeComponent();
  25. this.State = 1;
  26. }
  27. public static readonly DependencyProperty StateProperty =
  28. DependencyProperty.Register("State", typeof(int), typeof(WpfWindturbine));
  29. public int State
  30. {
  31. get { return (int)GetValue(StateProperty); }
  32. set
  33. {
  34. //this.Dispatcher.Invoke(new Action(delegate {
  35. // //这里写代码
  36. SetValue(StateProperty, value);
  37. //}));
  38. switch (value)
  39. {
  40. case 0:
  41. VisualStateManager.GoToState(this, "standby", false);
  42. break;
  43. case 1:
  44. VisualStateManager.GoToState(this, "run", true);
  45. break;
  46. case 2:
  47. VisualStateManager.GoToState(this, "stop", false);
  48. break;
  49. case 3:
  50. VisualStateManager.GoToState(this, "interrupt", false);
  51. break;
  52. case 4:
  53. VisualStateManager.GoToState(this, "repair", false);
  54. break;
  55. case 5:
  56. VisualStateManager.GoToState(this, "powercuts", false);
  57. break;
  58. case 6:
  59. VisualStateManager.GoToState(this, "powercuts2", false);
  60. break;
  61. default:
  62. VisualStateManager.GoToState(this, "staticrun", false);
  63. break;
  64. }
  65. // set
  66. //{
  67. // this.Dispatcher.Invoke(new Action(delegate {
  68. // //这里写代码
  69. // SetValue(StateProperty, value);
  70. // }));
  71. // switch (value)
  72. // {
  73. // case 0:
  74. // {
  75. // this.Dispatcher.Invoke(new Action(delegate
  76. // {
  77. // VisualStateManager.GoToState(this, "standby", false);
  78. // }));
  79. // break;
  80. // }
  81. // case 1:
  82. // {
  83. // this.Dispatcher.Invoke(new Action(delegate
  84. // {
  85. // VisualStateManager.GoToState(this, "run", false);
  86. // }));
  87. // break;
  88. // }
  89. // case 2:
  90. // {
  91. // this.Dispatcher.Invoke(new Action(delegate
  92. // {
  93. // VisualStateManager.GoToState(this, "stop", false);
  94. // }));
  95. // break;
  96. // }
  97. // case 3:
  98. // {
  99. // this.Dispatcher.Invoke(new Action(delegate
  100. // {
  101. // VisualStateManager.GoToState(this, "interrupt", false);
  102. // }));
  103. // break;
  104. // }
  105. // case 4:
  106. // {
  107. // this.Dispatcher.Invoke(new Action(delegate
  108. // {
  109. // VisualStateManager.GoToState(this, "repair", false);
  110. // }));
  111. // break;
  112. // }
  113. // case 5:
  114. // {
  115. // this.Dispatcher.Invoke(new Action(delegate
  116. // {
  117. // VisualStateManager.GoToState(this, "powercuts", false);
  118. // }));
  119. // break;
  120. // }
  121. // case 6:
  122. // {
  123. // this.Dispatcher.Invoke(new Action(delegate
  124. // {
  125. // VisualStateManager.GoToState(this, "powercuts2", false);
  126. // }));
  127. // break;
  128. // }
  129. // default:
  130. // {
  131. // this.Dispatcher.Invoke(new Action(delegate
  132. // {
  133. // VisualStateManager.GoToState(this, "staticrun", false);
  134. // }));
  135. // break;
  136. // }
  137. // }
  138. }
  139. }
  140. /// <summary>
  141. /// 测点编码
  142. /// </summary>
  143. [Browsable(true), Category("Appearance")]
  144. public string TestPointId
  145. {
  146. get;
  147. set;
  148. }
  149. /// <summary>
  150. /// 统一编码
  151. /// </summary>
  152. [Browsable(true), Category("Appearance")]
  153. public string UniformCode
  154. {
  155. get;
  156. set;
  157. }
  158. /// <summary>
  159. /// 风机编码
  160. /// </summary>
  161. [Browsable(true), Category("Appearance")]
  162. public string WindTurbineId
  163. {
  164. get;
  165. set;
  166. }
  167. /// <summary>
  168. /// 风场编码
  169. /// </summary>
  170. [Browsable(true), Category("Appearance")]
  171. public string WindPowerId
  172. {
  173. get;
  174. set;
  175. }
  176. public event EventHandler MyClick;
  177. public event EventHandler MyMouseEnter;
  178. public event EventHandler MyMouseLeave;
  179. private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
  180. {
  181. if (MyClick != null)
  182. {
  183. MyClick(this, e);
  184. }
  185. }
  186. private void Grid_MouseEnter_1(object sender, MouseEventArgs e)
  187. {
  188. if (MyMouseEnter != null)
  189. {
  190. MyMouseEnter(this, e);
  191. }
  192. }
  193. private void Grid_MouseLeave_1(object sender, MouseEventArgs e)
  194. {
  195. if (MyMouseLeave != null)
  196. {
  197. MyMouseLeave(this, e);
  198. }
  199. }
  200. }
  201. }