PopupDevice2.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace IntelligentControlForsx.MyControls
  11. {
  12. public partial class PopupDevice2 : UserControl
  13. {
  14. public PopupDevice2()
  15. {
  16. InitializeComponent();
  17. }
  18. string deviceId;
  19. double windSpeed;
  20. double power;
  21. double status;
  22. bool checked1;
  23. string rank;
  24. public MatrixPanel MatrixPanel1 { get; set; }
  25. [Browsable(true), Category("Data")]
  26. public string DeviceId
  27. {
  28. get
  29. {
  30. return deviceId;
  31. }
  32. set
  33. {
  34. deviceId = value;
  35. lblDeviceId.Text = value;
  36. }
  37. }
  38. [Browsable(true), Category("Data")]
  39. public double WindSpeed
  40. {
  41. get
  42. {
  43. return windSpeed;
  44. }
  45. set
  46. {
  47. windSpeed = value;
  48. lblWindSpeed.Text = Convert.ToDouble(value).ToString("0.00") + "m/s";
  49. }
  50. }
  51. [Browsable(true), Category("Data")]
  52. public double Power
  53. {
  54. get
  55. {
  56. return power;
  57. }
  58. set
  59. {
  60. power = value;
  61. lblPower.Text = Convert.ToDouble(value).ToString("0.00") + "KW";
  62. }
  63. }
  64. [Browsable(true), Category("Data")]
  65. public double Status
  66. {
  67. get
  68. {
  69. return status;
  70. }
  71. set
  72. {
  73. status = value;
  74. this.BackColor = getBackColor(value);
  75. }
  76. }
  77. [Browsable(true), Category("Data")]
  78. public bool Checked1
  79. {
  80. get
  81. {
  82. return checked1;
  83. }
  84. set
  85. {
  86. checked1 = value;
  87. this.chkSelect.Checked = value;
  88. }
  89. }
  90. public string Rank
  91. {
  92. get
  93. {
  94. return rank;
  95. }
  96. set
  97. {
  98. rank = value;
  99. lblRank.Text = value;
  100. }
  101. }
  102. private Color getBackColor(double status)
  103. {
  104. int st = Convert.ToInt32(status);
  105. switch(st)
  106. {
  107. //case 0: //启动状态
  108. //case 7: //低温启动状态
  109. // return Color.FromArgb(0, 51, 102);
  110. //case 1: //待机状态
  111. // return Color.FromArgb(51, 153, 51);
  112. //case 2: //上电状态
  113. // return Color.FromArgb(153, 0, 102);
  114. //case 3: //并网(发电)状态
  115. // return Color.FromArgb(0, 153, 204);
  116. //case 4: //正常停机状态
  117. // return Color.FromArgb(153, 153, 51);
  118. //case 5: //维护状态
  119. // return Color.FromArgb(255, 102, 0);
  120. //case 6: //故障停机状态
  121. // return Color.FromArgb(204, 51, 51);
  122. //case 8: //离线状态
  123. // return Color.FromArgb(153, 153, 153);
  124. //default:
  125. // return Color.Black;
  126. //风机六种状态: 限电5》运行1》待机0》维护4》故障2》离线3
  127. //case 5:
  128. //case 1:
  129. // return Color.FromArgb(0, 153, 204);
  130. //case 0:
  131. // return Color.FromArgb(51, 153, 51);
  132. //case 4:
  133. // return Color.FromArgb(255, 102, 0);
  134. //case 2:
  135. // return Color.FromArgb(204, 51, 51);
  136. //case 3:
  137. // return Color.FromArgb(153, 153, 153);
  138. //default:
  139. // return Color.FromArgb(153, 153, 153);
  140. case 0: //停机状态
  141. return Color.FromArgb(176, 151, 63);
  142. case 1: //上电状态
  143. return Color.FromArgb(177, 14, 126);
  144. case 2: //待机状态
  145. return Color.FromArgb(15, 141, 106);
  146. case 3: //启动状态
  147. return Color.FromArgb(14, 72, 91);
  148. case 4: //并网状态
  149. return Color.FromArgb(15, 135, 170);
  150. case 5: //故障状态
  151. return Color.FromArgb(170, 15, 59);
  152. case 6: //维护状态
  153. return Color.FromArgb(204, 83, 51);
  154. case 7: //离线状态
  155. return Color.FromArgb(134, 150, 165);
  156. default:
  157. return Color.Black;
  158. }
  159. }
  160. private void btnClose_MouseHover(object sender, EventArgs e)
  161. {
  162. Button btn = sender as Button;
  163. btn.FlatAppearance.BorderSize = 1;
  164. }
  165. private void btnClose_MouseLeave(object sender, EventArgs e)
  166. {
  167. Button btn = sender as Button;
  168. btn.FlatAppearance.BorderSize = 0;
  169. }
  170. private void btnClose_Click(object sender, EventArgs e)
  171. {
  172. this.MatrixPanel1.WtList.Remove(this.deviceId);
  173. this.MatrixPanel1.UpateWtList();
  174. this.Dispose();
  175. }
  176. private void chkSelect_CheckedChanged(object sender, EventArgs e)
  177. {
  178. checked1 = chkSelect.Checked;
  179. }
  180. }
  181. }