黄学彪
2020-07-13 f3e65daca7978b21b5888f49b1bf35e1a6e5d4fd
ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/Base/DeviceRowCommon.cs
@@ -100,16 +100,21 @@
            Common.LocalDevice.Current.SetDeviceIconToControl(btnDeviceIcon, i_device);
            frameIconBackGroud.AddChidren(btnDeviceIcon);
            //重新绑定事件
            this.frameTable.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEventOnly);
            this.frameTable.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEvent);
            //设备名字
            this.btnDeviceName = new NormalViewControl(600, 60, true);
            if (this.device.Type == DeviceType.WindowCoveringDevice)
            {
                //窗帘因为右边有三个按钮,所以需要所有名字的宽度
                this.btnDeviceName.Width = Application.GetRealWidth(360);
            }
            btnDeviceName.X = Application.GetRealWidth(181);
            //当指定实际坐标时,这里需要的偏移量为2倍
            btnDeviceName.Y = Application.GetRealHeight(16) + this.chidrenYaxis * 2;
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(i_device);
            btnDeviceName.SelectedTextColor = Common.ZigbeeColor.Current.GXCTextSelectedColor;
            this.frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
            this.frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
            
            if (this.hadStatuFunction == false)
            {
@@ -127,7 +132,7 @@
                btnStatu.Y = Application.GetRealHeight(70) + this.chidrenYaxis * 2;
                btnStatu.TextSize = 10;
                btnStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
                this.frameTable.AddChidren(btnStatu, ChidrenBindMode.BindEventOnly);
                this.frameTable.AddChidren(btnStatu, ChidrenBindMode.BindEvent);
            }
            //底线
@@ -258,31 +263,13 @@
            {
                this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device);
            }
            if (this.btnDeviceName.IsSelected == isOpen)
            {
                //状态一样,则不需要处理
                return;
            }
            //设备名称控件
            this.btnDeviceName.IsSelected = isOpen;
            this.btnDeviceName.IsBold = isOpen;
            //设备的背景圆圈图
            if (isOpen == true)
            {
                this.frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCSelectedBackgroundColor;
            }
            else
            {
                this.frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
            }
            //设备图标控件
            this.btnDeviceIcon.IsSelected = isOpen;
            //开关控件
            if (this.btnSwitch != null)
            if (this.btnSwitch != null && this.btnSwitch.IsSelected != isOpen)
            {
                this.btnSwitch.IsSelected = isOpen;
            }
            //切换卡片状态特效
            this.SwitchRowStatuAppeal(isOpen);
        }
        /// <summary>
@@ -394,7 +381,7 @@
            this.ResponeResult = 0;
            HdlThreadLogic.Current.RunThread(() =>
            {
                int waitime = 30;
                int waitime = 40;
                while (waitime > 0)
                {
                    System.Threading.Thread.Sleep(100);
@@ -404,8 +391,15 @@
                        break;
                    }
                    waitime--;
                    //2秒的时候,还是接受不到的话,强制再次刷新设备状态
                    if (waitime == 20)
                    {
                        //从新发送获取设备的状态(强制)
                        this.device.HadReadDeviceStatu = false;
                        this.SendStatuComand();
                    }
                }
                if (waitime <= 0)
                if (waitime <= 0 && this.Parent != null)
                {
                    //没有获取得到结果
                    HdlThreadLogic.Current.RunMain(() =>
@@ -452,6 +446,80 @@
        #endregion
        #region ■ 行闪烁特效_________________________
        /// <summary>
        /// 是否处于特效中
        /// </summary>
        private bool isAppeal = false;
        /// <summary>
        /// 开启行闪烁特效
        /// </summary>
        public void StartRowLightAppeal()
        {
            //设备状态必须刷新
            this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device);
            if (this.isAppeal == true) { return; }
            this.isAppeal = true;
            HdlThreadLogic.Current.RunThread(() =>
            {
                //闪烁5秒,间隔400毫秒
                int count = 5000 / 400;
                bool isOpen = false;
                while (this.Parent != null && count >= 0)
                {
                    //闪烁特效
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        isOpen = !isOpen;
                        this.SwitchRowStatuAppeal(isOpen);
                    });
                    System.Threading.Thread.Sleep(400);
                    count--;
                }
                if (this.Parent != null && isOpen == false)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //结束时,默认为打开特效
                        this.SwitchRowStatuAppeal(true);
                    }, ShowErrorMode.NO);
                }
                this.isAppeal = false;
            }, ShowErrorMode.NO);
        }
        /// <summary>
        /// 切换卡片状态特效
        /// </summary>
        private void SwitchRowStatuAppeal(bool isOpen)
        {
            if (this.btnDeviceName.IsSelected == isOpen)
            {
                //状态一样,则不需要处理
                return;
            }
            //设备名称控件
            this.btnDeviceName.IsSelected = isOpen;
            this.btnDeviceName.IsBold = isOpen;
            //设备的背景圆圈图
            if (isOpen == true)
            {
                this.frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCSelectedBackgroundColor;
            }
            else
            {
                this.frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
            }
            //设备图标控件
            this.btnDeviceIcon.IsSelected = isOpen;
        }
        #endregion
        #region ■ 控件摧毁___________________________
        /// <summary>