Uctl_OContro3.cs 6.5 KB

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