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; using IntelligentControlForsx.Code; namespace IntelligentControlForsx.MyControls { public partial class Photovoltaic : UserControl { public Photovoltaic() { InitializeComponent(); } private int state; public int State { get { return state; } set { if (!this.DesignMode) { state = value; string path = UserTools.Path; string str = path + @"\images\图标光伏-待机.png"; switch (value) { case 0: str = path + @"\images\图标光伏-待机.png"; break; case 1: str = path + @"\images\图标光伏-运行.png"; break; case 2: str = path + @"\images\图标光伏-故障.png"; break; case 3: str = path + @"\images\图标光伏-离线.png"; break; case 4: str = path + @"\images\图标光伏-维护.png"; break; case 5: str = path + @"\images\图标光伏-限电.png"; break; case 6: str = path + @"\images\图标光伏-限电.png"; break; default: str = path + @"\images\图标光伏-待机.png"; break; } this.BackgroundImage = Image.FromFile(str); } } } private void Photovoltaic_MouseEnter(object sender, EventArgs e) { if (!this.DesignMode) { string path = UserTools.Path; string str = path + @"\images\图标光伏-待机1.png"; switch (state) { case 0: str = path + @"\images\图标光伏-待机1.png"; break; case 1: str = path + @"\images\图标光伏-运行1.png"; break; case 2: str = path + @"\images\图标光伏-故障1.png"; break; case 3: str = path + @"\images\图标光伏-离线1.png"; break; case 4: str = path + @"\images\图标光伏-维护1.png"; break; case 5: str = path + @"\images\图标光伏-限电1.png"; break; case 6: str = path + @"\images\图标光伏-限电1.png"; break; default: str = path + @"\images\图标光伏-待机1.png"; break; } this.BackgroundImage = Image.FromFile(str); } } private void Photovoltaic_MouseLeave(object sender, EventArgs e) { if (!this.DesignMode) { string path = UserTools.Path; string str = path + @"\images\图标光伏-待机.png"; switch (state) { case 0: str = path + @"\images\图标光伏-待机.png"; break; case 1: str = path + @"\images\图标光伏-运行.png"; break; case 2: str = path + @"\images\图标光伏-故障.png"; break; case 3: str = path + @"\images\图标光伏-离线.png"; break; case 4: str = path + @"\images\图标光伏-维护.png"; break; case 5: str = path + @"\images\图标光伏-限电.png"; break; case 6: str = path + @"\images\图标光伏-限电.png"; break; default: str = path + @"\images\图标光伏-待机.png"; break; } this.BackgroundImage = Image.FromFile(str); } } public event EventHandler MyClick; private void Photovoltaic_Click(object sender, EventArgs e) { if (MyClick != null) { MyClick(this, e); } MessageBox.Show(state.ToString()); } } }