using System; using HDL_ON.Entity; using HDL_ON.Stan; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class EnvironmentPanelPage : DeviceFunction4CardCommonForm { #region ■ 变量声明___________________________ /// /// 图标 /// private IconViewControl btnIcon = null; /// /// 文本控件 /// private NormalViewControl btnSuctionView = null; Function acDevice; Function fhDevice; Function airFreshDevice; #endregion #region ■ 初始化_____________________________ /// /// 初始化白色区域的内容 /// public override void InitFrameWhiteContent() { base.ShowColltionButton = false; base.SetTitleText(Language.StringByID(StringId.SmartPanel)); foreach (var sid in device.targetSids) { var targetObj = FunctionList.List.Functions.Find((obj) => sid == obj.sid); if (targetObj == null) { continue; } if (SPK.AcSpkList().Contains(targetObj.spk)) { acDevice = targetObj; } else if (SPK.FhSpkList().Contains(targetObj.spk)) { fhDevice = targetObj; } else if (SPK.AirFreshSpkList().Contains(targetObj.spk)) { airFreshDevice = targetObj; } } //添加第二索引页 this.Add4Page(); //初始化第一个索引页的内容 this.InitFrameWhiteContent1(); //初始化第二个索引页的内容 this.InitFrameWhiteContent2(); this.InitFrameWhiteContent3(); //刷新界面状态 //this.RefreshFormStatu(); //读取状态 //new System.Threading.Thread(() => //{ // DriverLayer.Control.Ins.SendReadCommand(device); //}) //{ IsBackground = true }.Start(); } /// /// 初始化第一个索引页的内容 /// private void InitFrameWhiteContent1() { btnIcon = new IconViewControl(198) { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealWidth(146), UnSelectedImagePath = "FunctionIcon/Panel/PanelHelpNormalBgIcon.png", SelectedImagePath = "FunctionIcon/Panel/PanelHelpAlarmBgIcon.png", }; FrameWhiteCentet1.AddChidren(btnIcon); btnSuctionView = new NormalViewControl(300, 84, true) { Gravity = Gravity.CenterHorizontal, Y = btnIcon.Bottom, TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.MainColor, SelectedTextColor = CSS_Color.AuxiliaryColor2, //BackgroundColor = 0xFFFF0000 }; FrameWhiteCentet1.AddChidren(btnSuctionView); } /// /// 初始化第二个索引页的内容 /// private void InitFrameWhiteContent2() { var acPage = new UI2.FuntionControlView.Panel.AcContentView(acDevice); FrameWhiteCentet2.AddChidren(acPage); acPage.InitContent(); } private void InitFrameWhiteContent3() { var fhPage = new FhContentView(fhDevice); FrameWhiteCentet3.AddChidren(fhPage); fhPage.InitContentView(true); } #endregion #region ■ 设备状态反馈_______________________ /// /// 设备状态反馈 /// /// public override void DeviceStatuPush(Function i_LocalDevice) { //不是同一个东西 if (this.device.sid != i_LocalDevice.sid) { return; } //刷新界面状态 this.RefreshFormStatu(); } #endregion #region ■ 发送各种命令_______________________ #endregion #region ■ 刷新界面状态_______________________ /// /// 刷新界面状态 /// private void RefreshFormStatu() { Application.RunOnMainThread(() => { var temp = device.attributes.Find((sta) => sta.key == "alarm_status"); if (temp != null) { if (temp.state == "alarm") { btnIcon.IsSelected = true; btnSuctionView.TextID = StringId.InAlarm; btnSuctionView.IsSelected = true; } else { btnIcon.IsSelected = false; btnSuctionView.TextID = StringId.SensorNormalState; btnSuctionView.IsSelected = false; } } }); } #endregion #region ■ 一般方法___________________________ #endregion } }