using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace IntelligentControlForsx.MyControls { public partial class PopupDevice : UserControl { public PopupDevice() { InitializeComponent(); } string deviceId; double windSpeed; double power; double status; string rank; [Browsable(true), Category("Data")] public string DeviceId { get { return deviceId; } set { deviceId = value; lblDeviceId.Text = value; } } [Browsable(true), Category("Data")] public double WindSpeed { get { return windSpeed; } set { windSpeed = value; lblWindSpeed.Text = Convert.ToDouble(value).ToString("0.00") + "m/s"; } } [Browsable(true), Category("Data")] public double Power { get { return power; } set { power = value; lblPower.Text = Convert.ToDouble(value).ToString("0.00") + "KW"; } } [Browsable(true), Category("Data")] public double Status { get { return status; } set { status = value; this.BackColor = getBackColor(value); } } [Browsable(true), Category("Data")] public string Rank { get { return rank; } set { rank = value; lblRank.Text = value; } } private Color getBackColor(double status) { int st = Convert.ToInt32(status); switch(st) { //case 0: //启动状态 //case 7: //低温启动状态 // return Color.FromArgb(0, 51, 102); //case 1: //待机状态 // return Color.FromArgb(51, 153, 51); //case 2: //上电状态 // return Color.FromArgb(153, 0, 102); //case 3: //并网(发电)状态 // return Color.FromArgb(0, 153, 204); //case 4: //正常停机状态 // return Color.FromArgb(153, 153, 51); //case 5: //维护状态 // return Color.FromArgb(255, 102, 0); //case 6: //故障停机状态 // return Color.FromArgb(204, 51, 51); //case 8: //离线状态 // return Color.FromArgb(153, 153, 153); //default: // return Color.Black; case 0: //停机状态 return Color.FromArgb(176, 151, 63); case 1: //上电状态 return Color.FromArgb(177, 14, 126); case 2: //待机状态 return Color.FromArgb(15, 141, 106); case 3: //启动状态 return Color.FromArgb(14, 72, 91); case 4: //并网状态 return Color.FromArgb(15, 135, 170); case 5: //故障状态 return Color.FromArgb(170, 15, 59); case 6: //维护状态 return Color.FromArgb(204, 83, 51); case 7: //离线状态 return Color.FromArgb(134, 150, 165); default: return Color.Black; } } private void btnClose_MouseHover(object sender, EventArgs e) { Button btn = sender as Button; btn.FlatAppearance.BorderSize = 1; } private void btnClose_MouseLeave(object sender, EventArgs e) { Button btn = sender as Button; btn.FlatAppearance.BorderSize = 0; } private void btnClose_Click(object sender, EventArgs e) { this.Dispose(); } } }