PopupDevice.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 PopupDevice : UserControl
  13. {
  14. public PopupDevice()
  15. {
  16. InitializeComponent();
  17. }
  18. string deviceId;
  19. double windSpeed;
  20. double power;
  21. double status;
  22. string rank;
  23. [Browsable(true), Category("Data")]
  24. public string DeviceId
  25. {
  26. get
  27. {
  28. return deviceId;
  29. }
  30. set
  31. {
  32. deviceId = value;
  33. lblDeviceId.Text = value;
  34. }
  35. }
  36. [Browsable(true), Category("Data")]
  37. public double WindSpeed
  38. {
  39. get
  40. {
  41. return windSpeed;
  42. }
  43. set
  44. {
  45. windSpeed = value;
  46. lblWindSpeed.Text = Convert.ToDouble(value).ToString("0.00") + "m/s";
  47. }
  48. }
  49. [Browsable(true), Category("Data")]
  50. public double Power
  51. {
  52. get
  53. {
  54. return power;
  55. }
  56. set
  57. {
  58. power = value;
  59. lblPower.Text = Convert.ToDouble(value).ToString("0.00") + "KW";
  60. }
  61. }
  62. [Browsable(true), Category("Data")]
  63. public double Status
  64. {
  65. get
  66. {
  67. return status;
  68. }
  69. set
  70. {
  71. status = value;
  72. this.BackColor = getBackColor(value);
  73. }
  74. }
  75. [Browsable(true), Category("Data")]
  76. public string Rank
  77. {
  78. get
  79. {
  80. return rank;
  81. }
  82. set
  83. {
  84. rank = value;
  85. lblRank.Text = value;
  86. }
  87. }
  88. private Color getBackColor(double status)
  89. {
  90. int st = Convert.ToInt32(status);
  91. switch(st)
  92. {
  93. //case 0: //启动状态
  94. //case 7: //低温启动状态
  95. // return Color.FromArgb(0, 51, 102);
  96. //case 1: //待机状态
  97. // return Color.FromArgb(51, 153, 51);
  98. //case 2: //上电状态
  99. // return Color.FromArgb(153, 0, 102);
  100. //case 3: //并网(发电)状态
  101. // return Color.FromArgb(0, 153, 204);
  102. //case 4: //正常停机状态
  103. // return Color.FromArgb(153, 153, 51);
  104. //case 5: //维护状态
  105. // return Color.FromArgb(255, 102, 0);
  106. //case 6: //故障停机状态
  107. // return Color.FromArgb(204, 51, 51);
  108. //case 8: //离线状态
  109. // return Color.FromArgb(153, 153, 153);
  110. //default:
  111. // return Color.Black;
  112. case 0: //停机状态
  113. return Color.FromArgb(176, 151, 63);
  114. case 1: //上电状态
  115. return Color.FromArgb(177, 14, 126);
  116. case 2: //待机状态
  117. return Color.FromArgb(15, 141, 106);
  118. case 3: //启动状态
  119. return Color.FromArgb(14, 72, 91);
  120. case 4: //并网状态
  121. return Color.FromArgb(15, 135, 170);
  122. case 5: //故障状态
  123. return Color.FromArgb(170, 15, 59);
  124. case 6: //维护状态
  125. return Color.FromArgb(204, 83, 51);
  126. case 7: //离线状态
  127. return Color.FromArgb(134, 150, 165);
  128. default:
  129. return Color.Black;
  130. }
  131. }
  132. private void btnClose_MouseHover(object sender, EventArgs e)
  133. {
  134. Button btn = sender as Button;
  135. btn.FlatAppearance.BorderSize = 1;
  136. }
  137. private void btnClose_MouseLeave(object sender, EventArgs e)
  138. {
  139. Button btn = sender as Button;
  140. btn.FlatAppearance.BorderSize = 0;
  141. }
  142. private void btnClose_Click(object sender, EventArgs e)
  143. {
  144. this.Dispose();
  145. }
  146. }
  147. }