UserControl4.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using IMCS.DefaultList;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace IMCS.UControl
  12. {
  13. public partial class UserControl4 : UserControl
  14. {
  15. public DeviceStateDefaultList deviceStateDefaultList { get; set; } = new DeviceStateDefaultList();
  16. IMCS.Componen.Uctl_DComponen1 dComponen = new Componen.Uctl_DComponen1();
  17. IMCS.Componen.Uctl_DComponen2 uctrl_first = new Componen.Uctl_DComponen2();
  18. IMCS.Componen.Uctl_DComponen2 uctrl_two = new Componen.Uctl_DComponen2();
  19. IMCS.Componen.Uctl_DComponen2 uctrl_third = new Componen.Uctl_DComponen2();
  20. public UserControl4()
  21. {
  22. InitializeComponent();
  23. this.Load += (s, e) =>
  24. {
  25. this.lb_Name.BackColor = System.Drawing.Color.Green;
  26. lb_Name.TextAlign = ContentAlignment.MiddleCenter;
  27. lb_ConnectionMes.TextAlign = ContentAlignment.MiddleCenter;
  28. lb_OnLine.TextAlign = ContentAlignment.MiddleCenter;
  29. lb_Runing.TextAlign = ContentAlignment.MiddleCenter;
  30. deviceStateDefaultList.PropertyChanged += DeviceStateDefaultList_PropertyChanged;
  31. dComponen.Dock = DockStyle.Bottom;
  32. dComponen.Show();
  33. dComponen.Visible = false;
  34. this.Controls.Add(dComponen);
  35. uctrl_first.Location = new Point(101, 120);
  36. this.Controls.Add(uctrl_first);
  37. uctrl_two.Location = new Point(3, 264);
  38. this.Controls.Add(uctrl_two);
  39. uctrl_third.Location = new Point(212, 264);
  40. this.Controls.Add(uctrl_third);
  41. };
  42. }
  43. private void DeviceStateDefaultList_PropertyChanged(object sender, PropertyChangedEventArgs e)
  44. {
  45. DeviceStateDefaultList dl = sender as DeviceStateDefaultList;
  46. switch (e.PropertyName)
  47. {
  48. case "Device_OnLine":
  49. this.lb_OnLine.BeginInvoke(new Action(() =>
  50. {
  51. if (dl.Device_OnLine)
  52. {
  53. this.lb_OnLine.Text = "在线";
  54. this.lb_OnLine.BackColor = System.Drawing.Color.Green;
  55. }
  56. else
  57. {
  58. this.lb_OnLine.Text = "离线";
  59. lb_OnLine.BackColor = System.Drawing.SystemColors.GrayText;
  60. }
  61. }));
  62. break;
  63. case "Device_ConnectionMes":
  64. this.lb_ConnectionMes.BeginInvoke(new Action(() =>
  65. {
  66. if (dl.Device_ConnectionMes)
  67. {
  68. this.lb_ConnectionMes.Text = "系统监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.Green;
  69. }
  70. else
  71. {
  72. this.lb_ConnectionMes.Text = "不受监管"; this.lb_ConnectionMes.BackColor = System.Drawing.SystemColors.GrayText;
  73. }
  74. }));
  75. break;
  76. case "Device_Name":
  77. this.lb_Name.BeginInvoke(new Action(() =>
  78. {
  79. this.lb_Name.Text = dl.Device_Name;
  80. }));
  81. break;
  82. case "Device_Pan":
  83. this.lb_OnLine.BeginInvoke(new Action(() =>
  84. {
  85. this.uctrl_first.Visible = false;
  86. this.uctrl_third.Visible = false;
  87. this.uctrl_two.Visible = false;
  88. this.dComponen.Visible = false;
  89. if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Third))
  90. {
  91. this.uctrl_first.Visible = true;
  92. this.uctrl_third.Visible = true;
  93. this.uctrl_two.Visible = true;
  94. }
  95. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Two))
  96. {
  97. dComponen.Visible = true;
  98. }
  99. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_One))
  100. {
  101. this.uctrl_first.Location = new Point(93, 170);
  102. this.uctrl_first.Visible = true;
  103. }
  104. }));
  105. break;
  106. case "Device_Runing":
  107. this.lb_Runing.BeginInvoke(new Action(() =>
  108. {
  109. if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Run))
  110. {
  111. lb_Runing.Text = "运行中"; this.lb_Runing.BackColor = System.Drawing.Color.Green;
  112. }
  113. else if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Err))
  114. {
  115. lb_Runing.Text = "故障中"; this.lb_Runing.BackColor = System.Drawing.SystemColors.GrayText;
  116. }
  117. else
  118. {
  119. lb_Runing.Text = "空闲";
  120. }
  121. }));
  122. break;
  123. }
  124. }
  125. private void button1_Click(object sender, EventArgs e)
  126. {
  127. this.deviceStateDefaultList.Device_OnLine = false;
  128. this.deviceStateDefaultList.Device_ConnectionMes = false;
  129. this.deviceStateDefaultList.Device_Runing = EnumDeviceRunState.RunState_Run;
  130. this.deviceStateDefaultList.Device_Pan = EnumPlateNum.Plate_One;
  131. }
  132. private void button2_Click(object sender, EventArgs e)
  133. {
  134. this.deviceStateDefaultList.Device_OnLine = true;
  135. this.deviceStateDefaultList.Device_ConnectionMes = true;
  136. this.deviceStateDefaultList.Device_Runing = EnumDeviceRunState.RunState_Err;
  137. this.deviceStateDefaultList.Device_Pan = EnumPlateNum.Plate_Two;
  138. }
  139. }
  140. }