黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs
@@ -20,20 +20,27 @@
        /// </summary>
        private bool hadRefresh = false;
        /// <summary>
        /// 在线状态
        /// 传感器推送中
        /// </summary>
        private bool m_isOnline = false;
        private bool sensorPushing = false;
        /// <summary>
        /// 在线状态
        /// </summary>
        public bool isOnline
        private bool m_isOnline = true;
        /// <summary>
        /// 在线状态
        /// </summary>
        public bool IsOnline
        {
            get { return m_isOnline; }
            set
            {
                m_isOnline = value;
                //设置在线状态的特效
                this.SetOnlineStatu(m_isOnline);
                if (m_isOnline != value)
                {
                    m_isOnline = value;
                    //设置在线状态的特效
                    this.SetOnlineStatu(m_isOnline);
                }
            }
        }
@@ -42,13 +49,13 @@
        /// </summary>
        public IconViewControl btnIcon = null;
        /// <summary>
        /// 设备类型控件
        /// </summary>
        private NormalViewControl btnDeviceObject = null;
        /// <summary>
        /// 设备备注控件
        /// </summary>
        private NormalViewControl btnDeviceName = null;
        /// <summary>
        /// 设备房间控件
        /// </summary>
        private NormalViewControl btnDeviceRoom = null;
        #endregion
@@ -58,7 +65,7 @@
        /// 做成一个显示设备类型+设备MAC备注的RowLayout
        /// </summary>
        /// <param name="i_deviceMac">设备的Mac地址</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
        public DeviceObjectControl(string i_deviceMac, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
        {
            this.deviceMac = i_deviceMac;
@@ -70,36 +77,29 @@
        public void InitControl()
        {
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(this.deviceMac);
            if (listDevice.Count == 0)
            {
                //针对单纯只有一个200端点的设备
                listDevice.Add(Common.LocalDevice.Current.GetOTADevice(this.deviceMac));
            }
            //图标
            btnIcon = frameTable.AddLeftIcon(81);
            Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnIcon, listDevice);
            //设备类型
            string objText = Common.LocalDevice.Current.GetDeviceObjectText(listDevice);
            btnDeviceObject = frameTable.AddLeftCaption(objText, 800, 60, true);
            btnDeviceObject.TextSize = 15;
            //这个坐标有点特殊
            btnDeviceObject.Y = Application.GetRealHeight(12) + this.chidrenYaxis;
            btnDeviceObject.Text = Common.LocalDevice.Current.GetDeviceObjectText(listDevice);
            frameTable.AddChidren(btnDeviceObject, ChidrenBindMode.BindEventOnly);
            Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
            //设备
            string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
            btnDeviceName = frameTable.AddLeftCaption(deviceName, 800, 49, true);
            //这个坐标有点特殊
            btnDeviceName.Y = Application.GetRealHeight(72) + this.chidrenYaxis;
            btnDeviceName.TextSize = 12;
            btnDeviceName.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
            frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
            btnDeviceName = frameTable.AddTopView(deviceName, 800);
            frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
            //房间
            string roomName = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]);
            btnDeviceRoom = frameTable.AddBottomView(roomName, 800);
            //底线
            frameTable.AddBottomLine();
            //设置在线状态的特效
            this.isOnline = listDevice[0].IsOnline == 1;
            listDevice = null;
            this.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]);
        }
        #endregion
@@ -109,16 +109,16 @@
        /// <summary>
        /// 设置在线状态的特效
        /// </summary>
        /// <param name="isOnline"></param>
        private void SetOnlineStatu(bool isOnline)
        /// <param name="i_isOnline"></param>
        private void SetOnlineStatu(bool i_isOnline)
        {
            if (isOnline == false)
            if (i_isOnline == false)
            {
                btnDeviceObject.TextColor = UserCenterColor.Current.TextGrayColor1;
                btnDeviceName.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
            else
            {
                btnDeviceObject.TextColor = UserCenterColor.Current.TextColor1;
                btnDeviceName.TextColor = UserCenterColor.Current.TextColor1;
            }
        }
@@ -135,17 +135,87 @@
            hadRefresh = true;
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(this.deviceMac);
            if (listDevice.Count == 0)
            {
                //针对单纯只有一个200端点的设备
                listDevice.Add(Common.LocalDevice.Current.GetOTADevice(this.deviceMac));
            }
            //图标
            Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnIcon, listDevice);
            //设备类型
            btnDeviceObject.Text = Common.LocalDevice.Current.GetDeviceObjectText(listDevice);
            Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
            //设备
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
            //设置在线状态的特效
            this.isOnline = listDevice[0].IsOnline == 1;
            listDevice = null;
            //设备房间
            btnDeviceRoom.Text = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]);
        }
        /// <summary>
        /// 显示传感器上报的特效
        /// </summary>
        public void StartSensorPushAppeal()
        {
            if (this.sensorPushing == true)
            {
                //传感器正在特效中
                return;
            }
            this.sensorPushing = 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);
                    }, ShowErrorMode.NO);
                    System.Threading.Thread.Sleep(400);
                    count--;
                }
                if (this.Parent != null && isOpen == true)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //结束时,默认为无特效
                        this.SwitchRowStatuAppeal(false);
                    }, ShowErrorMode.NO);
                }
                this.sensorPushing = false;
            }, ShowErrorMode.NO);
        }
        /// <summary>
        /// 切换行闪烁特效
        /// </summary>
        /// <param name="isOpen"></param>
        private void SwitchRowStatuAppeal(bool isOpen)
        {
            if (isOpen == true)
            {
                //图标
                btnIcon.IsSelected = true;
                //设备
                btnDeviceName.TextColor = UserCenterColor.Current.TextOrangeColor;
                //设备房间
                btnDeviceRoom.TextColor = UserCenterColor.Current.TextOrangeColor;
            }
            else
            {
                //图标
                btnIcon.IsSelected = false;
                //设备
                btnDeviceName.TextColor = UserCenterColor.Current.TextColor1;
                //设备房间
                btnDeviceRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
        }
        #endregion
    }
}