HDL Home App 第二版本 旧平台金堂用 正在使用
chenqiyang
2022-06-22 dc0309e64f02227d8e1468b7326c07955f804612
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs
old mode 100755 new mode 100644
@@ -1,155 +1,163 @@
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 安防传感器状态的自定义控件
    /// </summary>
    public class SafetySensorStatuControl : FrameLayout
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 在线状态
        /// </summary>
        private NormalViewControl btnOnline = null;
        /// <summary>
        /// 信息提示图标
        /// </summary>
        private IconViewControl btnMsgIcon = null;
        /// <summary>
        /// 信息
        /// </summary>
        private NormalViewControl btnMsg = null;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 安防传感器状态的自定义控件
        /// </summary>
        public SafetySensorStatuControl()
        {
            this.Height = Application.GetRealHeight(256);
            this.BackgroundColor = UserCenterColor.Current.White;
            this.Radius = (uint)Application.GetMinRealAverage(6);
        }
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="device">设备对象</param>
        public void InitControl(CommonDevice device)
        {
            //区域
            var btnArea = new NormalViewControl(400, 49, true);
            btnArea.Y = Application.GetRealHeight(40);
            btnArea.X = Application.GetRealWidth(104);
            btnArea.TextSize = 12;
            btnArea.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnArea.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
            this.AddChidren(btnArea);
            //状态
            var btnStatu = new NormalViewControl(200, 49, true);
            btnStatu.Y = btnArea.Y;
            btnStatu.X = this.Width - Application.GetRealWidth(200 + 101);
            btnStatu.TextSize = 12;
            btnStatu.TextAlignment = TextAlignment.CenterRight;
            btnStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnStatu.TextID = R.MyInternationalizationString.uStatu;
            this.AddChidren(btnStatu);
            //线
            var btnLine = new NormalViewControl(Application.GetRealWidth(876), 2, false);
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            btnLine.X = Application.GetRealWidth(104);
            btnLine.Y = Application.GetRealHeight(104);
            this.AddChidren(btnLine);
            //设备名称
            var btnDeviceName = new NormalViewControl(400, 58, true);
            btnDeviceName.X = Application.GetRealWidth(104);
            btnDeviceName.Y = Application.GetRealHeight(141);
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            this.AddChidren(btnDeviceName);
            //在线状态
            btnOnline = new NormalViewControl(200, 58, true);
            btnOnline.X = this.Width - Application.GetRealWidth(200 + 101);
            btnOnline.Y = btnDeviceName.Y;
            btnOnline.TextAlignment = TextAlignment.CenterRight;
            this.SetOnlineStatu(device.IsOnline == 1);
            this.AddChidren(btnOnline);
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 设置在线状态
        /// </summary>
        /// <param name="online"></param>
        public void SetOnlineStatu(bool online)
        {
            if (online == false)
            {
                //离线
                btnOnline.TextID = R.MyInternationalizationString.uOffLine;
                btnOnline.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
            else
            {
                //在线
                btnOnline.TextID = R.MyInternationalizationString.uOnline;
                btnOnline.TextColor = UserCenterColor.Current.TextColor1;
            }
        }
        /// <summary>
        /// 设置传感器报警信息
        /// </summary>
        /// <param name="reportInfo"></param>
        public void SetSensoReportInfo(IASZoneReportInfo reportInfo)
        {
            if (reportInfo == null)
            {
                return;
            }
            //在线状态的控件隐藏
            btnOnline.Visible = false;
            if (btnMsg == null)
            {
                //图标
                btnMsgIcon = new IconViewControl(58);
                btnMsgIcon.X = Application.GetRealWidth(922);
                btnMsgIcon.Y = Application.GetRealHeight(141);
                btnMsgIcon.UnSelectedImagePath = "Item/Tips.png";
                this.AddChidren(btnMsgIcon);
                //信息
                btnMsg = new NormalViewControl(400, 58, true);
                btnMsg.TextAlignment = TextAlignment.CenterRight;
                btnMsg.TextColor = 0xfff34747;
                btnMsg.X = Application.GetRealWidth(910 - 400);
                btnMsg.Y = Application.GetRealHeight(141);
                this.AddChidren(btnMsg);
            }
            if (reportInfo.DemolishmenMsg != null)
            {
                btnMsg.Text = reportInfo.DemolishmenMsg;
            }
            else if (reportInfo.BatteryMsg != null)
            {
                btnMsg.Text = reportInfo.BatteryMsg;
            }
            else
            {
                btnMsg.Text = reportInfo.AlarmMsg;
            }
        }
        #endregion
    }
}
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 安防传感器状态的自定义控件
    /// </summary>
    public class SafetySensorStatuControl : FrameLayout
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 在线状态
        /// </summary>
        private NormalViewControl btnOnline = null;
        /// <summary>
        /// 信息提示图标
        /// </summary>
        private IconViewControl btnMsgIcon = null;
        /// <summary>
        /// 信息
        /// </summary>
        private NormalViewControl btnMsg = null;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 安防传感器状态的自定义控件
        /// </summary>
        public SafetySensorStatuControl()
        {
            this.Height = Application.GetRealHeight(256);
            this.Width = Application.GetRealWidth(968);
            this.Gravity = Gravity.CenterHorizontal;
            this.BackgroundColor = UserCenterColor.Current.White;
            this.Radius = (uint)Application.GetRealHeight(17);
        }
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="device">设备对象</param>
        public void InitControl(CommonDevice device)
        {
            //区域
            var btnArea = new NormalViewControl(400, 49, true);
            btnArea.Y = Application.GetRealHeight(40);
            btnArea.X = Application.GetRealWidth(46);
            btnArea.TextSize = 12;
            btnArea.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnArea.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device);
            this.AddChidren(btnArea);
            //状态
            var btnStatu = new NormalViewControl(200, 49, true);
            btnStatu.Y = btnArea.Y;
            btnStatu.X = this.Width - Application.GetRealWidth(200 + 46);
            btnStatu.TextSize = 12;
            btnStatu.TextAlignment = TextAlignment.CenterRight;
            btnStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnStatu.TextID = R.MyInternationalizationString.uStatu;
            this.AddChidren(btnStatu);
            //线
            var btnLine = new NormalViewControl(Application.GetRealWidth(876), ControlCommonResourse.BottomLineHeight, false);
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            btnLine.X = Application.GetRealWidth(46);
            btnLine.Y = Application.GetRealHeight(104);
            this.AddChidren(btnLine);
            //设备名称
            var btnDeviceName = new NormalViewControl(400, 58, true);
            btnDeviceName.X = Application.GetRealWidth(46);
            btnDeviceName.Y = Application.GetRealHeight(141);
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            this.AddChidren(btnDeviceName);
            //在线状态
            btnOnline = new NormalViewControl(200, 58, true);
            btnOnline.X = this.Width - Application.GetRealWidth(200 + 46);
            btnOnline.Y = btnDeviceName.Y;
            btnOnline.TextAlignment = TextAlignment.CenterRight;
            this.SetOnlineStatu(Common.LocalDevice.Current.CheckDeviceIsOnline(device));
            this.AddChidren(btnOnline);
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 设置在线状态
        /// </summary>
        /// <param name="online"></param>
        public void SetOnlineStatu(bool online)
        {
            if (online == false)
            {
                //离线
                btnOnline.TextID = R.MyInternationalizationString.uOffLine;
                btnOnline.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
            else
            {
                //在线
                btnOnline.TextID = R.MyInternationalizationString.uOnline;
                btnOnline.TextColor = UserCenterColor.Current.TextColor1;
            }
        }
        /// <summary>
        /// 设置传感器报警信息
        /// </summary>
        /// <param name="reportInfo"></param>
        public void SetSensoReportInfo(IASZoneReportInfo reportInfo)
        {
            if (reportInfo == null)
            {
                return;
            }
            string strMsg = reportInfo.AlarmMsg;
            if (reportInfo.DemolishmenMsg != null)
            {
                //被拆报警
                strMsg = reportInfo.DemolishmenMsg;
            }
            else if (reportInfo.BatteryMsg != null)
            {
                //电池报警
                strMsg = reportInfo.BatteryMsg;
            }
            if (strMsg == null || strMsg == string.Empty)
            {
                //不是在册的报警消息
                return;
            }
            //在线状态的控件隐藏
            btnOnline.Visible = false;
            if (btnMsg == null)
            {
                //图标
                btnMsgIcon = new IconViewControl(58);
                btnMsgIcon.X = Application.GetRealWidth(864);
                btnMsgIcon.Y = Application.GetRealHeight(141);
                btnMsgIcon.UnSelectedImagePath = "Item/Tips.png";
                this.AddChidren(btnMsgIcon);
                //信息
                btnMsg = new NormalViewControl(400, 58, true);
                btnMsg.TextAlignment = TextAlignment.CenterRight;
                btnMsg.TextColor = 0xfff34747;
                btnMsg.X = this.Width - Application.GetRealWidth(400 + 115);
                btnMsg.Y = Application.GetRealHeight(141);
                this.AddChidren(btnMsg);
            }
            btnMsg.Text = strMsg;
        }
        #endregion
    }
}