Uctl_OControl.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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.Componen
  12. {
  13. public partial class Uctl_OContro : UserControl
  14. {
  15. public DeviceStateDefaultList deviceStateDefaultList { get; set; } = new DeviceStateDefaultList();
  16. Uctl_OComponen1 uctl_OComponen1 = new Uctl_OComponen1();
  17. public Uctl_OContro()
  18. {
  19. InitializeComponent();
  20. this.Load += (s, e) =>
  21. {
  22. lb_Name.TextAlign = ContentAlignment.MiddleLeft;
  23. lb_ConnectionMes.TextAlign = ContentAlignment.MiddleCenter;
  24. lb_OnLine.TextAlign = ContentAlignment.MiddleCenter;
  25. lb_Runing.TextAlign = ContentAlignment.MiddleCenter;
  26. deviceStateDefaultList.PropertyChanged += DeviceStateDefaultList_PropertyChanged;
  27. //dComponen.Dock = DockStyle.Bottom;
  28. //dComponen.Show();
  29. //dComponen.Visible = false;
  30. //this.Controls.Add(dComponen);
  31. //uctrl_first.Location = new Point(101, 120);
  32. //this.Controls.Add(uctrl_first);
  33. //uctrl_two.Location = new Point(3, 264);
  34. //this.Controls.Add(uctrl_two);
  35. //uctrl_third.Location = new Point(212, 264);
  36. //this.Controls.Add(uctrl_third);
  37. this.MouseDown += (t, k) => {
  38. if (k.Button.Equals(MouseButtons.Right))
  39. {
  40. this.popupMenu1.ShowPopup(Control.MousePosition);
  41. }
  42. };
  43. };
  44. }
  45. private void DeviceStateDefaultList_PropertyChanged(object sender, PropertyChangedEventArgs e)
  46. {
  47. DeviceStateDefaultList dl = sender as DeviceStateDefaultList;
  48. switch (e.PropertyName)
  49. {
  50. case "Device_OnLine":
  51. this.lb_OnLine.BeginInvoke(new Action(() =>
  52. {
  53. if (dl.Device_OnLine)
  54. {
  55. this.lb_OnLine.Text = "在线";
  56. this.lb_OnLine.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  57. }
  58. else
  59. {
  60. this.lb_OnLine.Text = "离线";
  61. lb_OnLine.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  62. }
  63. }));
  64. break;
  65. case "Device_ConnectionMes":
  66. this.lb_ConnectionMes.BeginInvoke(new Action(() =>
  67. {
  68. if (dl.Device_ConnectionMes)
  69. {
  70. this.lb_ConnectionMes.Text = "系统监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  71. }
  72. else
  73. {
  74. this.lb_ConnectionMes.Text = "不受监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  75. }
  76. }));
  77. break;
  78. case "Device_Name":
  79. this.lb_Name.BeginInvoke(new Action(() =>
  80. {
  81. this.lb_Name.Text = dl.Device_Name;
  82. }));
  83. break;
  84. case "Device_Pan":
  85. this.lb_OnLine.BeginInvoke(new Action(() =>
  86. {
  87. if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Third))
  88. {
  89. //this.uctrl_first.Visible = true;
  90. //this.uctrl_third.Visible = true;
  91. //this.uctrl_two.Visible = true;
  92. }
  93. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Two))
  94. {
  95. //dComponen.Visible = true;
  96. }
  97. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_One))
  98. {
  99. this.pan_left_top.Visible = true;
  100. this.pan_left_cen.Visible = true;
  101. this.pan_left_bottom.Visible = true;
  102. this.pan_left_top.BackColor = System.Drawing.Color.FromArgb(0, 204, 255);
  103. this.pan_left_cen.BackColor = System.Drawing.Color.FromArgb(0, 51, 255);
  104. this.pan_left_bottom.BackColor = System.Drawing.Color.FromArgb(0, 51, 255);
  105. }
  106. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Zero))
  107. {
  108. this.pan_left_bottom.Visible = false;
  109. this.pan_left_top.Visible = false;
  110. this.pan_left_cen.Visible = false;
  111. this.pan_left.BackColor = System.Drawing.Color.FromArgb(223, 223, 223);
  112. }
  113. }));
  114. break;
  115. case "Device_Runing":
  116. this.lb_Runing.BeginInvoke(new Action(() =>
  117. {
  118. if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Run))
  119. {
  120. lb_Runing.Text = "运行中"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  121. }
  122. else if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Err))
  123. {
  124. lb_Runing.Text = "故障中"; this.lb_Runing.BackColor = System.Drawing.Color.Red;
  125. }
  126. else
  127. {
  128. lb_Runing.Text = "空闲"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  129. }
  130. }));
  131. break;
  132. }
  133. }
  134. }
  135. }