using System.Threading; using System.Windows.Forms.VisualStyles; using IntelligentControlForsx.Code; using IntelligentControlForsx.MyControls; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Text; using System.Windows.Forms; using IntelligentControlForsx.Service; using IntelligentControlForsx.Service.HomeFormInfo; using IntelligentControlForsx.Service.HomeFormInfo.Domain; namespace IntelligentControlForsx.ChildForms { public partial class HomeForm : IntelligentControlForsx.Template.TemplateForm { public override void Active() { this.Show(); isUpdateOver = false; Thread th = new Thread(UpdateThread); th.Start(); timer2.Enabled = true; timer1.Enabled = true; } public override void DeActive() { this.Hide(); timer2.Enabled = false; timer1.Enabled = false; } private bool isUpdateOver = true; public HomeForm() { InitializeComponent(); plSBQ.MyMouseEnter += panelLabel_MouseEnter; plSBQ.MyMouseLeave += panelLabel_MouseLeave; plNSS.MyMouseEnter += panelLabel_MouseEnter; plNSS.MyMouseLeave += panelLabel_MouseLeave; plQS.MyMouseEnter += panelLabel_MouseEnter; plQS.MyMouseLeave += panelLabel_MouseLeave; plMHS.MyMouseEnter += panelLabel_MouseEnter; plMHS.MyMouseLeave += panelLabel_MouseLeave; plXS.MyMouseEnter += panelLabel_MouseEnter; plXS.MyMouseLeave += panelLabel_MouseLeave; SFI_MHS.Hide(); SFI_NSS.Hide(); SFI_QS.Hide(); SFI_SBQ.Hide(); SFI_XS.Hide(); wpf_MHS.WindPowerId = "MHS_FDC"; wpf_MHS.MyClick += WPF_StationClick; wpf_NSS.WindPowerId = "NSS_FDC"; wpf_NSS.MyClick += WPF_StationClick; wpf_SBQ.WindPowerId = "SBQ_FDC"; wpf_SBQ.MyClick += WPF_StationClick; wpf_XS.WindPowerId = "XS_FDC"; wpf_XS.MyClick += WPF_StationClick; wpf_QS.WindPowerId = "QS_FDC"; wpf_QS.MyClick += WPF_StationClick; #region 日发电能量绑定测试 IList list = new List(); Info info1 = new Info(); info1.Power = 21233; info1.Station = "麻黄山"; Info info2 = new Info(); info2.Power = 12333; info2.Station = "石板泉"; Info info3 = new Info(); info3.Power = 9333; info3.Station = "牛首山"; Info info4 = new Info(); info4.Power = 9333; info4.Station = "牛首山"; Info info5 = new Info(); info5.Power = 9333; info5.Station = "牛首山"; Info info6 = new Info(); info6.Power = 9333; info6.Station = "牛首山"; Info info7 = new Info(); info7.Power = 9333; info7.Station = "牛首山"; Info info8 = new Info(); info8.Power = 9333; info8.Station = "牛首山"; list.Add(info1); list.Add(info2); list.Add(info3); list.Add(info4); list.Add(info5); list.Add(info6); list.Add(info7); list.Add(info8); datePowerStat.DataBind(list); #endregion } private void HomeForm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Color aColor = System.Drawing.Color.FromArgb(((int)(((byte)(8)))), ((int)(((byte)(13)))), ((int)(((byte)(33))))); Color bColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(67)))), ((int)(((byte)(139))))); Brush b = new LinearGradientBrush(this.ClientRectangle, aColor, bColor, LinearGradientMode.Vertical); g.FillRectangle(b, this.ClientRectangle); } void WPF_StationClick(object sender, EventArgs e) { WpfWindturbine pl = (WpfWindturbine)sender; NavService.Instance.StationId = pl.WindPowerId; NavService.Instance.Nav("ZMForm", (MainWindow)this.Parent.Parent); //MessageBox.Show(pl.WindPowerId); } private void panelLabel_MouseEnter(object sender, EventArgs e) { string s = sender.ToString(); if (sender.ToString() == "plSBQ") { SFI_SBQ.Show(); } else if (sender.ToString() == "plNSS") { SFI_NSS.Show(); } else if (sender.ToString() == "plQS") { SFI_QS.Show(); } else if (sender.ToString() == "plMHS") { SFI_MHS.Show(); } else if (sender.ToString() == "plXS") { SFI_XS.Show(); } } private void panelLabel_MouseLeave(object sender, EventArgs e) { if (sender.ToString() == "plSBQ") { SFI_SBQ.Hide(); } else if (sender.ToString() == "plNSS") { SFI_NSS.Hide(); } else if (sender.ToString() == "plQS") { SFI_QS.Hide(); } else if (sender.ToString() == "plMHS") { SFI_MHS.Hide(); } else if (sender.ToString() == "plXS") { SFI_XS.Hide(); } } private void timer1_Tick(object sender, EventArgs e) { this.DateLabel.Text = DateTime.Now.ToString(); } private void timer2_Tick(object sender, EventArgs e) { if (isUpdateOver) { isUpdateOver = false; Thread updateThread = new Thread(UpdateThread); updateThread.Start(); } } private delegate void UpdateFormDataDelegate(LeftInfo leftInfo, CenterInfo centerInfo, RightInfo rightInfo); private void UpdateThread() { HomeFormInfoSvc svc = HomeFormInfoSvc.Instance; LeftInfo leftInfo = svc.GetLeftInfo(); CenterInfo centerInfo = svc.GetCenterInfo(); RightInfo rightInfo = svc.GetRightInfo(); UpdateFormDataDelegate del = new UpdateFormDataDelegate(UpdateFormData); this.BeginInvoke(del, leftInfo, centerInfo, rightInfo); } private void UpdateFormData(LeftInfo leftInfo, CenterInfo centerInfo, RightInfo rightInfo) { try { BindDataLeft(leftInfo); BindDataCenter(centerInfo); BindDataRight(rightInfo); isUpdateOver = true; } catch (Exception e) { MessageBox.Show("数据更新失败,请检查网络或联系维护人员"); } } private void BindDataLeft(LeftInfo info) { wlblPowerAll.LableText = info.PowerAll; wlblPowerDay.LableText = info.PowerByDay; wlblPowerDay.BindData(info.PowerByDay, "station", "-1", "RFDLB", "日发电量"); wlblPowerMonth.BindData(info.PowerByMonth, "station", "-1", "YFDLB", "月发电量"); wlblPowerYear.BindData(info.PowerByYear, "station", "-1", "NFDL", "年发电量"); wlblUseHourByMonth.LableText = info.UseHourByMounth; wlblUseHourByYear.LableText = info.UseHourByYear; wlblSpeedNowByStation.BindData(info.WindSpeedNow, "station", "-1", "SSFS", "实时风速"); wlblPowerNowByStation.BindData(info.PowerNow, "station", "-1", "SSZGL", "实时总功率"); wlblLinkCount.LableText = info.LinkCount; wlblRunCount.LableText = info.RunCount; wlblStandByCount.LableText = info.StandByCount; wlblFaultCount.LableText = info.FaultCount; wlblMaintainCount.LableText = info.MaintainCount; wlblLimitCount.LableText = info.StopCount; wlblOfflineCount.LableText = info.OfflineCount; } private void BindDataCenter(CenterInfo info) { SFI_SBQ.Power = info.SBQ_PowerByNow; SFI_SBQ.Speed = info.SBQ_Speed; SFI_SBQ.UnitLable = "m/s"; SFI_SBQ.WindSpeedOrLightLable = "实时风速"; SFI_SBQ.PowerCount = info.SBQ_PowerByDay; wpf_SBQ.State = GetWindturbineStatus(info.SBQ_Status); SFI_MHS.Power = info.SBQ_PowerByNow; SFI_MHS.Speed = info.MHS_Speed; SFI_MHS.UnitLable = "m/s"; SFI_MHS.WindSpeedOrLightLable = "实时风速"; SFI_MHS.PowerCount = info.MHS_PowerByDay; wpf_MHS.State = GetWindturbineStatus(info.MHS_Status); SFI_QS.Power = info.SBQ_PowerByNow; SFI_QS.Speed = info.QS_Speed; SFI_QS.UnitLable = "m/s"; SFI_QS.WindSpeedOrLightLable = "实时风速"; SFI_QS.PowerCount = info.QS_PowerByDay; wpf_QS.State = GetWindturbineStatus(info.QS_Status); SFI_NSS.Power = info.SBQ_PowerByNow; SFI_NSS.Speed = info.NSS_Speed; SFI_NSS.UnitLable = "m/s"; SFI_NSS.WindSpeedOrLightLable = "实时风速"; SFI_NSS.PowerCount = info.NSS_PowerByDay; wpf_NSS.State = GetWindturbineStatus(info.NSS_Status); SFI_XS.Power = info.SBQ_PowerByNow; SFI_XS.Speed = info.XS_Speed; SFI_XS.UnitLable = "m/s"; SFI_XS.WindSpeedOrLightLable = "实时风速"; SFI_XS.PowerCount = info.XS_PowerByDay; wpf_XS.State = GetWindturbineStatus(info.XS_Status); } private void BindDataRight(RightInfo info) { historyLine.BuildChart(info.DateTimeArray, info.SpeedArray, info.PowerArray); datePowerStat.DataBind(info.InfoList); webfontLable16.LableText = info.SafetyDayCount; } private int GetWindturbineStatus(Status status) { int? statusValue = null; switch (status) { case Status.Run: statusValue = 1; break; case Status.StandBy: statusValue = 0; break; case Status.Falut: statusValue = 2; break; case Status.Maintain: statusValue = 4; break; case Status.Limit: statusValue = 5; break; case Status.Offline: statusValue = 3; break; default: break; } if (statusValue.HasValue) return statusValue.Value; else return 0; } } }