Uctl_OControl.cs 6.1 KB

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