gxc
2019-12-13 eb424d24e39bab4a245725f35deab3f234ea0f13
ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs
@@ -1,6 +1,7 @@
using System;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.Device.DeviceLogic;
using ZigBee.Device;
namespace Shared.Phone.Device.Light
@@ -61,6 +62,11 @@
        /// MaxLevel
        /// </summary>
        private const int MaxLevel = 254;
        /// <summary>
        /// IsDrawerLockMode
        /// </summary>
        public bool IsDrawerLockMode;
        #endregion
        #region ◆ 接口__________________________
@@ -120,10 +126,10 @@
                        }
                        if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight)
                        {
                            if (common.DeviceStatusReport.CluterID == 6)
                            if ((common as DimmableLight).DeviceStatusReport.CluterID == 6)
                            {
                                dimmableLight = deviceUI.CommonDevice as DimmableLight;
                                dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
                                dimmableLight.DeviceStatusReport = (common as DimmableLight).DeviceStatusReport;
                                //记录、更新状态
                                if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
                                {
@@ -146,10 +152,10 @@
                                dimmableLight.LastDateTime = DateTime.Now;
                            }
                            //亮度
                            if (common.DeviceStatusReport.CluterID == 8)
                            if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 8)
                            {
                                dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
                                dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
                                dimmableLight.DeviceStatusReport = (common as ZigBee.Device.DimmableLight).DeviceStatusReport;
                                var attriButeList = dimmableLight.DeviceStatusReport.AttriBute;
                                if (attriButeList == null || attriButeList.Count == 0)
                                {
@@ -191,8 +197,12 @@
        {
            ZbGateway.StatusList.Remove(this);
            UserView.HomePage.Instance.ScrollEnabled = true;
            action();
            action = null;
            //action();
            //action = null;
            if (IsDrawerLockMode)
            {
                CommonPage.Instance.IsDrawerLockMode = false;
            }
            base.RemoveFromParent();
        }
@@ -204,6 +214,7 @@
        /// </summary>
        public DimmableLightControl()
        {
            UserView.HomePage.Instance.ScrollEnabled = false;
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            ZbGateway.StatusList.Add(this);
        }
@@ -236,9 +247,7 @@
                //发送读取状态命令
                UserView.UserHomeView.ReadStatus(dimmableLight, () =>
                {
                    dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    dimmableLight.ReadOnOffStatus();
                    dimmableLight.ReadLevel();
                    ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice);
                });
            }
            else
@@ -246,9 +255,7 @@
                //防止短时间内多次读取设备状态
                if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                {
                    dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    dimmableLight.ReadOnOffStatus();
                    dimmableLight.ReadLevel();
                    ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice);
                }
            }
        }
@@ -269,16 +276,6 @@
            {
                RemoveFromParent();
            };
            var sharedBtn = new Button
            {
                X = Application.GetRealWidth(850),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Shared.png"
            };
            top.topView.AddChidren(sharedBtn);
            var moreBtn = new Button
            {