HDL Home App 第二版本 旧平台金堂用 正在使用
chenqiyang
2022-06-22 dc0309e64f02227d8e1468b7326c07955f804612
ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs
@@ -50,6 +50,10 @@
        /// </summary>
        private IconViewControl btnCollect = null;
        /// <summary>
        /// 电池控件
        /// </summary>
        private IconViewControl btnBattery = null;
        /// <summary>
        /// 是否获取网关反馈的结果  0:没有获取得到  1:已经获取得到
        /// </summary>
        private int ResponeResult = 0;
@@ -96,7 +100,7 @@
            this.AddChidren(btnBackGroud, ChidrenBindMode.BindEvent);
            //设备名称控件
            this.btnDeviceName = new NormalViewControl(320, 63, true);
            this.btnDeviceName = new NormalViewControl(360, 63, true);
            btnDeviceName.X = HdlControlLogic.Current.GetPictrueRealSize(40);
            btnDeviceName.Y = HdlControlLogic.Current.GetPictrueRealSize(17);
            btnDeviceName.TextSize = 16;
@@ -151,7 +155,7 @@
            this.ChangedChidrenBindMode(fraDeviceRound, ChidrenBindMode.BindEvent);
            //状态文本控件
            this.btnStatu = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(300), HdlControlLogic.Current.GetPictrueRealSize(63), false);
            this.btnStatu = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(400), HdlControlLogic.Current.GetPictrueRealSize(63), false);
            btnStatu.X = HdlControlLogic.Current.GetPictrueRealSize(46);
            btnStatu.Y = HdlControlLogic.Current.GetPictrueRealSize(236);
            btnStatu.TextColor = UserCenterColor.Current.TextColor1;
@@ -165,6 +169,21 @@
            btnSwitch.Y = HdlControlLogic.Current.GetPictrueRealSize(202);
            btnSwitch.UnSelectedImagePath = "Item/Switch1.png";
            btnSwitch.SelectedImagePath = "Item/SwitchSelected1.png";
            //电池控件
            if (this.device.Type == DeviceType.IASZone)
            {
                this.btnBattery = new IconViewControl(69);
                btnBattery.X = HdlControlLogic.Current.GetPictrueRealSize(348);
                btnBattery.Y = HdlControlLogic.Current.GetPictrueRealSize(236);
                btnBattery.UnSelectedImagePath = "Item/Battery.png";
                btnBattery.SelectedImagePath = "Item/BatterySelected.png";
                this.AddChidren(btnBattery, ChidrenBindMode.BindEvent);
                if (this.device.IsBatteryDown == false)
                {
                    btnBattery.Visible = false;
                }
            }
            //刷新信息
            this.RefreshControlInfo(i_device);
@@ -211,6 +230,13 @@
                //等待网关回复后会重新刷新,不然一直是关闭状态
                isOpen = false;
            }
            //如果是传感器类,则默认是关的效果
            if (this.device.Type == DeviceType.PMSensor || this.device.Type == DeviceType.IASZone
                || this.device.Type == DeviceType.TemperatureSensor)
            {
                isOpen = false;
            }
            this.SetCardOpenStatu(isOpen);
        }
@@ -220,8 +246,39 @@
        /// <param name="isOpen"></param>
        public void SetCardOpenStatu(bool isOpen)
        {
            //设备状态必须刷新
            this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device);
            //获取设备类型
            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
            {
                var aqSensor = (TemperatureSensor)this.device;
                //空气质量传感器
                var tempAirQuality = aqSensor.AirQuality(aqSensor);
                string curQuality = string.Empty;
                if (tempAirQuality == 1)
                {
                    curQuality = Language.StringByID(R.MyInternationalizationString.ExcellentAirQuality);
                }
                else if (tempAirQuality == 2)
                {
                    curQuality = Language.StringByID(R.MyInternationalizationString.GoodAirQuality);
                }
                else if (tempAirQuality == 3)
                {
                    curQuality = Language.StringByID(R.MyInternationalizationString.Pollution);
                }
                else
                {
                    curQuality = "";
                }
                this.btnStatu.Text = curQuality;
            }
            else
            {
                //设备状态必须刷新
                this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device);
            }
            //开关控件
            if (btnSwitch != null && this.btnSwitch.IsSelected != isOpen)
            {
@@ -382,6 +439,43 @@
            this.ResponeResult = 1;
        }
        /// <summary>
        /// 接收网关回复的状态(true:已经接收到网关的回复 false:还没有接收到网关回复)
        /// </summary>
        /// <returns></returns>
        public bool ReceiveResponeResultStatu()
        {
            return this.ResponeResult == 1;
        }
        #endregion
        #region ■ 显示低电量_________________________
        /// <summary>
        /// 刷新电池电量状态
        /// </summary>
        public void RefreshBatteryStatu()
        {
            if (this.btnBattery == null) { return; }
            if (this.device.IsBatteryDown == true)
            {
                //电量低,显示图标
                if (this.btnBattery.Visible == false)
                {
                    this.btnBattery.Visible = true;
                }
            }
            else
            {
                //电量足够,隐藏图标
                if (this.btnBattery.Visible == true)
                {
                    this.btnBattery.Visible = false;
                }
            }
        }
        #endregion
        #region ■ 一般方法___________________________
@@ -456,7 +550,7 @@
        /// <summary>
        /// 切换卡片状态特效
        /// </summary>
        private void SwitchCardStatuAppeal(bool isOpen)
        public void SwitchCardStatuAppeal(bool isOpen)
        {
            if (this.btnBackGroud.IsSelected == isOpen)
            {
@@ -481,6 +575,11 @@
            this.btnDeviceIcon.IsSelected = isOpen;
            //状态文本控件
            this.btnStatu.IsSelected = isOpen;
            //电池控件
            if (this.btnBattery != null && this.btnBattery.Visible == true)
            {
                this.btnBattery.IsSelected = isOpen;
            }
        }
        #endregion