| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | 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.UControl{    public partial class UserControl4 : UserControl    {        public DeviceStateDefaultList deviceStateDefaultList { get; set; } = new DeviceStateDefaultList();        IMCS.Componen.Uctl_DComponen1 dComponen = new Componen.Uctl_DComponen1();        IMCS.Componen.Uctl_DComponen2 uctrl_first = new Componen.Uctl_DComponen2();        IMCS.Componen.Uctl_DComponen2 uctrl_two = new Componen.Uctl_DComponen2();        IMCS.Componen.Uctl_DComponen2 uctrl_third = new Componen.Uctl_DComponen2();        public UserControl4()        {            InitializeComponent();            this.Load += (s, e) =>            {                this.lb_Name.BackColor = System.Drawing.Color.Green;                lb_Name.TextAlign = ContentAlignment.MiddleCenter;                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);            };        }        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.Green;                        }                        else                        {                            this.lb_OnLine.Text = "离线";                            lb_OnLine.BackColor = System.Drawing.SystemColors.GrayText;                        }                    }));                    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.Green;                        }                        else                        {                            this.lb_ConnectionMes.Text = "不受监管"; this.lb_ConnectionMes.BackColor = System.Drawing.SystemColors.GrayText;                        }                    }));                    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(() =>                    {                        this.uctrl_first.Visible = false;                        this.uctrl_third.Visible = false;                        this.uctrl_two.Visible = false;                        this.dComponen.Visible = false;                        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.uctrl_first.Location = new Point(93, 170);                            this.uctrl_first.Visible = true;                                                  }                    }));                    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.Green;                        }                        else if (dl.Device_Runing.Equals(EnumDeviceRunState.RunState_Err))                        {                            lb_Runing.Text = "故障中"; this.lb_Runing.BackColor = System.Drawing.SystemColors.GrayText;                        }                        else                        {                            lb_Runing.Text = "空闲";                        }                    }));                    break;            }        }        private void button1_Click(object sender, EventArgs e)        {            this.deviceStateDefaultList.Device_OnLine = false;            this.deviceStateDefaultList.Device_ConnectionMes = false;            this.deviceStateDefaultList.Device_Runing = EnumDeviceRunState.RunState_Run;            this.deviceStateDefaultList.Device_Pan = EnumPlateNum.Plate_One;                  }        private void button2_Click(object sender, EventArgs e)        {            this.deviceStateDefaultList.Device_OnLine = true;            this.deviceStateDefaultList.Device_ConnectionMes = true;            this.deviceStateDefaultList.Device_Runing = EnumDeviceRunState.RunState_Err;            this.deviceStateDefaultList.Device_Pan = EnumPlateNum.Plate_Two;        }    }}
 |