Uctrl_CTContol.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 Uctrl_CTContol : UserControlBase
  15. {
  16. public DeviceStateDefaultList deviceStateDefaultList { get; set; } = new DeviceStateDefaultList();
  17. Uctl_OComponen1 uctl_OComponen1 = new Uctl_OComponen1();
  18. public bool uctrl_Tu1 { set { { this.panel1.Visible = value; } } }
  19. public bool uctrl_Tu2 { set { this.panel2.Visible = value; } }
  20. public Uctrl_CTContol()
  21. {
  22. InitializeComponent();
  23. this.Load += (s, e) =>
  24. {
  25. uctrl_Tu1 = false;
  26. uctrl_Tu2 = false;
  27. lb_Name.TextAlign = ContentAlignment.MiddleLeft;
  28. lb_ConnectionMes.TextAlign = ContentAlignment.MiddleCenter;
  29. lb_OnLine.TextAlign = ContentAlignment.MiddleCenter;
  30. lb_Runing.TextAlign = ContentAlignment.MiddleCenter;
  31. deviceStateDefaultList.PropertyChanged += DeviceStateDefaultList_PropertyChanged;
  32. };
  33. }
  34. private void Pan_left_bottom_DragDrop(object sender, DragEventArgs e)
  35. {
  36. EventMoudeDrag(UserTag);
  37. }
  38. private void Pan_left_bottom_Click(object sender, EventArgs e)
  39. {
  40. EventMoudeDown(UserTag);
  41. }
  42. private void DeviceStateDefaultList_PropertyChanged(object sender, PropertyChangedEventArgs e)
  43. {
  44. DeviceStateDefaultList dl = sender as DeviceStateDefaultList;
  45. switch (e.PropertyName)
  46. {
  47. case "Device_OnLine":
  48. this.lb_OnLine.BeginInvoke(new Action(() =>
  49. {
  50. if (dl.Device_OnLine)
  51. {
  52. this.lb_OnLine.Text = "在线";
  53. this.lb_OnLine.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  54. }
  55. else
  56. {
  57. this.lb_OnLine.Text = "离线";
  58. lb_OnLine.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  59. }
  60. }));
  61. break;
  62. case "Device_ConnectionMes":
  63. this.lb_ConnectionMes.BeginInvoke(new Action(() =>
  64. {
  65. if (dl.Device_ConnectionMes)
  66. {
  67. this.lb_ConnectionMes.Text = "系统监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  68. }
  69. else
  70. {
  71. this.lb_ConnectionMes.Text = "不受监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  72. }
  73. }));
  74. break;
  75. case "Device_Name":
  76. this.lb_Name.BeginInvoke(new Action(() =>
  77. {
  78. this.lb_Name.Text = dl.Device_Name;
  79. }));
  80. break;
  81. case "Device_Pan":
  82. this.lb_OnLine.BeginInvoke(new Action(() =>
  83. {
  84. if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Third))
  85. {
  86. //this.uctrl_first.Visible = true;
  87. //this.uctrl_third.Visible = true;
  88. //this.uctrl_two.Visible = true;
  89. }
  90. else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Two))
  91. {
  92. //dComponen.Visible = true;
  93. }
  94. }));
  95. break;
  96. case "Device_Runing":
  97. this.lb_Runing.BeginInvoke(new Action(() =>
  98. {
  99. if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Run))
  100. {
  101. lb_Runing.Text = "运行中"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(0, 178, 89);
  102. }
  103. else if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Err))
  104. {
  105. lb_Runing.Text = "故障中"; this.lb_Runing.BackColor = System.Drawing.Color.Red;
  106. }
  107. else
  108. {
  109. lb_Runing.Text = "空闲"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(201, 201, 201);
  110. }
  111. }));
  112. break;
  113. }
  114. }
  115. }
  116. }