Photovoltaic.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. using IntelligentControlForsx.Code;
  11. namespace IntelligentControlForsx.MyControls
  12. {
  13. public partial class Photovoltaic : UserControl
  14. {
  15. public Photovoltaic()
  16. {
  17. InitializeComponent();
  18. }
  19. private int state;
  20. public int State
  21. {
  22. get { return state; }
  23. set
  24. {
  25. if (!this.DesignMode)
  26. {
  27. state = value;
  28. string path = UserTools.Path;
  29. string str = path + @"\images\图标光伏-待机.png";
  30. switch (value)
  31. {
  32. case 0:
  33. str = path + @"\images\图标光伏-待机.png";
  34. break;
  35. case 1:
  36. str = path + @"\images\图标光伏-运行.png";
  37. break;
  38. case 2:
  39. str = path + @"\images\图标光伏-故障.png";
  40. break;
  41. case 3:
  42. str = path + @"\images\图标光伏-离线.png";
  43. break;
  44. case 4:
  45. str = path + @"\images\图标光伏-维护.png";
  46. break;
  47. case 5:
  48. str = path + @"\images\图标光伏-限电.png";
  49. break;
  50. case 6:
  51. str = path + @"\images\图标光伏-限电.png";
  52. break;
  53. default:
  54. str = path + @"\images\图标光伏-待机.png";
  55. break;
  56. }
  57. this.BackgroundImage = Image.FromFile(str);
  58. }
  59. }
  60. }
  61. private void Photovoltaic_MouseEnter(object sender, EventArgs e)
  62. {
  63. if (!this.DesignMode)
  64. {
  65. string path = UserTools.Path;
  66. string str = path + @"\images\图标光伏-待机1.png";
  67. switch (state)
  68. {
  69. case 0:
  70. str = path + @"\images\图标光伏-待机1.png";
  71. break;
  72. case 1:
  73. str = path + @"\images\图标光伏-运行1.png";
  74. break;
  75. case 2:
  76. str = path + @"\images\图标光伏-故障1.png";
  77. break;
  78. case 3:
  79. str = path + @"\images\图标光伏-离线1.png";
  80. break;
  81. case 4:
  82. str = path + @"\images\图标光伏-维护1.png";
  83. break;
  84. case 5:
  85. str = path + @"\images\图标光伏-限电1.png";
  86. break;
  87. case 6:
  88. str = path + @"\images\图标光伏-限电1.png";
  89. break;
  90. default:
  91. str = path + @"\images\图标光伏-待机1.png";
  92. break;
  93. }
  94. this.BackgroundImage = Image.FromFile(str);
  95. }
  96. }
  97. private void Photovoltaic_MouseLeave(object sender, EventArgs e)
  98. {
  99. if (!this.DesignMode)
  100. {
  101. string path = UserTools.Path;
  102. string str = path + @"\images\图标光伏-待机.png";
  103. switch (state)
  104. {
  105. case 0:
  106. str = path + @"\images\图标光伏-待机.png";
  107. break;
  108. case 1:
  109. str = path + @"\images\图标光伏-运行.png";
  110. break;
  111. case 2:
  112. str = path + @"\images\图标光伏-故障.png";
  113. break;
  114. case 3:
  115. str = path + @"\images\图标光伏-离线.png";
  116. break;
  117. case 4:
  118. str = path + @"\images\图标光伏-维护.png";
  119. break;
  120. case 5:
  121. str = path + @"\images\图标光伏-限电.png";
  122. break;
  123. case 6:
  124. str = path + @"\images\图标光伏-限电.png";
  125. break;
  126. default:
  127. str = path + @"\images\图标光伏-待机.png";
  128. break;
  129. }
  130. this.BackgroundImage = Image.FromFile(str);
  131. }
  132. }
  133. public event EventHandler MyClick;
  134. private void Photovoltaic_Click(object sender, EventArgs e)
  135. {
  136. if (MyClick != null)
  137. {
  138. MyClick(this, e);
  139. }
  140. MessageBox.Show(state.ToString());
  141. }
  142. }
  143. }