123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- 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 EntityDataSet;
- using IntelligentControlForsx.Service;
- using log4net.Util;
- namespace IntelligentControlForsx.MyControls
- {
- public partial class Bottom2 : UserControl
- {
- private List<Label> labelList=new List<Label>();
- public Bottom2()
- {
- InitializeComponent();
- }
- Label defalutLable;
- [Browsable(true), Category("Appearance")]
- public Label DefaultLable
- {
- get
- {
- return defalutLable;
- }
- set
- {
- if (!this.DesignMode)
- {
- if (defalutLable.Name != null && defalutLable.Name.Trim() != "")
- {
- value.BackColor = Color.FromArgb(0, 148, 220);
- value.Height = 46;
- value.Cursor = Cursors.Default;
- if (defalutLable.Name != value.Name)
- {
- defalutLable.BackColor = Color.FromArgb(0, 78, 140);
- defalutLable.Height = 37;
- defalutLable.Cursor = System.Windows.Forms.Cursors.Hand;
- }
- }
- }
- defalutLable = value;
- }
- }
- private void Bottom2_Load(object sender, EventArgs e)
- {
- try
- {
- IList<windpowerstation> lstStation = new List<windpowerstation>();
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- lstStation = ctx.windpowerstation.Where(s => s.ID.Contains("_FDC")).ToList().OrderBy(k => k.NAME).ToList();
- }
- Panel p = new Panel();
- p.Width = lstStation.Count * 100;
- p.Height = 39;
- int locationX = (820 - lstStation.Count * 100) / 2;
- int locationY = 7;
- p.Location = new System.Drawing.Point(locationX, locationY);
- // this.Controls.Clear();
- foreach (var st in lstStation)
- {
- Label lb = new Label();
- lb.Width = 100;
- lb.Height = 39;
- lb.Margin = new Padding(1, 1, 1, 1);
- lb.BorderStyle = BorderStyle.FixedSingle;
- lb.Name = "lbl" + st.ID;
- lb.Tag = st.ID;
- lb.Text = st.NAME.Replace("电站", "");
- lb.Click += lbl_Click;
- lb.MouseEnter += lbl_MouseEnter;
- lb.MouseLeave += lbl_MouseLeave;
- lb.BackColor = Color.FromArgb(0, 78, 140);
- lb.ForeColor = Color.White;
- lb.TextAlign = ContentAlignment.MiddleCenter;
- lb.Font = new Font("微软雅黑", (float)9, FontStyle.Bold);
- lb.Dock = DockStyle.Right;
- p.Controls.Add(lb);
- labelList.Add(lb);
- }
- this.Controls.Add(p);
- defalutLable = new Label();
- }
- catch
- { }
- }
-
- private void lbl_MouseEnter(object sender, System.EventArgs e)
- {
- if (!this.DesignMode)
- {
- Label lable = (Label)sender;
- if (defalutLable.Name != lable.Name)
- {
- lable.Height = 46;
- lable.BackColor = Color.FromArgb(0, 148, 220);
- }
- }
- }
- private void lbl_MouseLeave(object sender, System.EventArgs e)
- {
- if (!this.DesignMode)
- {
- Label lable = (Label)sender;
- if (defalutLable.Name != lable.Name)
- {
- lable.Height = 37;
- lable.BackColor = Color.FromArgb(0, 78, 140);
- }
- }
- }
- public event EventHandler MyClick;
- private void lbl_Click(object sender, System.EventArgs e)
- {
- if (!this.DesignMode)
- {
- Label lable = (Label)sender;
- MyClick(lable.Tag, e);
- DefaultLable = lable;
- }
- }
- public void StationChange(string stationId)
- {
- foreach (var item in labelList)
- {
-
- if (item is Label)
- {
- Label lb = (Label)item;
- if (lb.Name.Replace("lbl", "") == stationId)
- {
- DefaultLable = lb;
- }
- }
- }
- }
-
- }
- }
|