using IMCS.DefaultList; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace IMCS.Componen { public partial class Uctl_OContro : UserControl { public DeviceStateDefaultList deviceStateDefaultList { get; set; } = new DeviceStateDefaultList(); Uctl_OComponen1 uctl_OComponen1 = new Uctl_OComponen1(); public Uctl_OContro() { InitializeComponent(); this.Load += (s, e) => { lb_Name.TextAlign = ContentAlignment.MiddleLeft; lb_ConnectionMes.TextAlign = ContentAlignment.MiddleCenter; lb_OnLine.TextAlign = ContentAlignment.MiddleCenter; lb_Runing.TextAlign = ContentAlignment.MiddleCenter; deviceStateDefaultList.PropertyChanged += DeviceStateDefaultList_PropertyChanged; //dComponen.Dock = DockStyle.Bottom; //dComponen.Show(); //dComponen.Visible = false; //this.Controls.Add(dComponen); //uctrl_first.Location = new Point(101, 120); //this.Controls.Add(uctrl_first); //uctrl_two.Location = new Point(3, 264); //this.Controls.Add(uctrl_two); //uctrl_third.Location = new Point(212, 264); //this.Controls.Add(uctrl_third); this.MouseDown += (t, k) => { if (k.Button.Equals(MouseButtons.Right)) { this.popupMenu1.ShowPopup(Control.MousePosition); } }; }; } private void DeviceStateDefaultList_PropertyChanged(object sender, PropertyChangedEventArgs e) { DeviceStateDefaultList dl = sender as DeviceStateDefaultList; switch (e.PropertyName) { case "Device_OnLine": this.lb_OnLine.BeginInvoke(new Action(() => { if (dl.Device_OnLine) { this.lb_OnLine.Text = "在线"; this.lb_OnLine.BackColor = System.Drawing.Color.FromArgb(0, 178, 89); } else { this.lb_OnLine.Text = "离线"; lb_OnLine.BackColor = System.Drawing.Color.FromArgb(201, 201, 201); } })); break; case "Device_ConnectionMes": this.lb_ConnectionMes.BeginInvoke(new Action(() => { if (dl.Device_ConnectionMes) { this.lb_ConnectionMes.Text = "系统监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(0, 178, 89); } else { this.lb_ConnectionMes.Text = "不受监管"; this.lb_ConnectionMes.BackColor = System.Drawing.Color.FromArgb(201, 201, 201); } })); break; case "Device_Name": this.lb_Name.BeginInvoke(new Action(() => { this.lb_Name.Text = dl.Device_Name; })); break; case "Device_Pan": this.lb_OnLine.BeginInvoke(new Action(() => { if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Third)) { //this.uctrl_first.Visible = true; //this.uctrl_third.Visible = true; //this.uctrl_two.Visible = true; } else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Two)) { //dComponen.Visible = true; } else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_One)) { this.pan_left_top.Visible = true; this.pan_left_cen.Visible = true; this.pan_left_bottom.Visible = true; this.pan_left_top.BackColor = System.Drawing.Color.FromArgb(0, 204, 255); this.pan_left_cen.BackColor = System.Drawing.Color.FromArgb(0, 51, 255); this.pan_left_bottom.BackColor = System.Drawing.Color.FromArgb(0, 51, 255); } else if (dl.Device_Pan.Equals(EnumPlateNum.Plate_Zero)) { this.pan_left_bottom.Visible = false; this.pan_left_top.Visible = false; this.pan_left_cen.Visible = false; this.pan_left.BackColor = System.Drawing.Color.FromArgb(223, 223, 223); } })); break; case "Device_Runing": this.lb_Runing.BeginInvoke(new Action(() => { if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Run)) { lb_Runing.Text = "运行中"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(0, 178, 89); } else if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Err)) { lb_Runing.Text = "故障中"; this.lb_Runing.BackColor = System.Drawing.Color.Red; } else { lb_Runing.Text = "空闲"; this.lb_Runing.BackColor = System.Drawing.Color.FromArgb(201, 201, 201); } })); break; } } } }