lss
2020-06-12 9c16d3614d9b88c637f967518a329f239fcd3aaf
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs
@@ -23,6 +23,14 @@
        /// 各防区的行控件
        /// </summary>
        private Dictionary<int, List<FrameLayout>> dicRowFrame = new Dictionary<int, List<FrameLayout>>();
        /// <summary>
        /// 桌布控件
        /// </summary>
        private FrameLayout frameTable = null;
        /// <summary>
        /// 开放这个控件出来,有点用
        /// </summary>
        private NormalViewControl btnTime = null;
        #endregion
@@ -33,9 +41,7 @@
        /// </summary>
        public SafeguardLogControl()
        {
            this.BackgroundColor = UserCenterColor.Current.White;
            this.Radius = 17;
            this.Height = Application.GetRealHeight(260);
            this.Height = Application.GetRealHeight(260 + 44);
        }
        /// <summary>
@@ -45,31 +51,39 @@
        /// <param name="dicInfo">防区报警信息</param>
        public void InitControl(string dayText, Dictionary<int, List<SafeguardAlarmInfo>> dicInfo)
        {
            this.frameTable = new FrameLayout();
            frameTable.Gravity = Gravity.CenterHorizontal;
            frameTable.Radius = (uint)Application.GetRealHeight(17);
            frameTable.Height= Application.GetRealHeight(260);
            frameTable.Width = Application.GetRealWidth(968);
            frameTable.BackgroundColor = UserCenterColor.Current.White;
            this.AddChidren(frameTable);
            //记录时间
            var btnTime = new NormalViewControl(300, 58, true);
            btnTime.X = Application.GetRealWidth(92);
            this.btnTime = new NormalViewControl(300, 58, true);
            btnTime.X = Application.GetRealWidth(35);
            btnTime.Y = Application.GetRealHeight(29);
            btnTime.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTime.TextID = R.MyInternationalizationString.uRecordTime;
            this.AddChidren(btnTime);
            this.frameTable.AddChidren(btnTime);
            //日期
            string month = dayText.Substring(4, 2);
            string day = dayText.Substring(6, 2);
            var btnDay = new NormalViewControl(300, 58, true);
            btnDay.X = this.Width - Application.GetRealWidth(300 + 89);
            btnDay.X = frameTable.Width - Application.GetRealWidth(300 + 35);
            btnDay.Y = btnTime.Y;
            btnDay.TextColor = UserCenterColor.Current.TextColor2;
            btnDay.TextAlignment = TextAlignment.CenterRight;
            btnDay.Text = month + Language.StringByID(R.MyInternationalizationString.Month) + day + Language.StringByID(R.MyInternationalizationString.Day);
            this.AddChidren(btnDay);
            this.frameTable.AddChidren(btnDay);
            //线
            var btnLine = new NormalViewControl(Application.GetRealWidth(904), ControlCommonResourse.BottomLineHeight, false);
            btnLine.X = Application.GetRealWidth(86);
            btnLine.X = Application.GetRealWidth(29);
            btnLine.Y = Application.GetRealHeight(98);
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            this.AddChidren(btnLine);
            this.frameTable.AddChidren(btnLine);
            //预创建五大防区的桌布
            var listId = new List<int>() { 1, 2, 4, 5, 3 };
@@ -79,7 +93,7 @@
                var frame1 = new FrameLayout();
                frame1.Height = Application.GetRealHeight(10);
                frame1.Y = tempY == 0 ? Application.GetRealHeight(98) : tempY;
                this.AddChidren(frame1);
                this.frameTable.AddChidren(frame1);
                dicFrame[listId[i]] = frame1;
                dicRowFrame[listId[i]] = new List<FrameLayout>();
@@ -91,17 +105,23 @@
                    var listRow = dicRowFrame[listId[i]];
                    foreach (var alarmInfo in dicInfo[listId[i]])
                    {
                        //添加报警信息
                        var contr = this.AddAlarmInfoControl(alarmInfo);
                        if (listRow.Count != 0)
                        //一条信息里面,它可能包含多个报警
                        var listMsg = HdlAlarmsLogic.Current.GetSensorListAlarmMsg(alarmInfo);
                        foreach (var strMsg in listMsg)
                        {
                            contr.Y = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(23);
                            //添加报警信息控件
                            var contr = this.AddAlarmInfoControl(alarmInfo, strMsg);
                            if (listRow.Count != 0)
                            {
                                contr.Y = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(23);
                            }
                            listRow.Add(contr);
                        }
                        listRow.Add(contr);
                    }
                    //变更高度
                    frame1.Height = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(55);
                    this.Height = frame1.Bottom;
                    this.frameTable.Height = frame1.Bottom;
                    this.Height = frame1.Bottom + Application.GetRealHeight(44);
                    tempY = frame1.Bottom;
                }
                else
@@ -113,13 +133,15 @@
            if (dicInfo == null || dicInfo.Count == 0)
            {
                //今日无任何报警记录
                btnMsg = new NormalViewControl(this.Width, Application.GetRealHeight(58), false);
                btnMsg.Y = btnLine.Bottom + Application.GetRealHeight(29);
                btnMsg = new NormalViewControl(frameTable.Width, Application.GetRealHeight(60), false);
                btnMsg.Y = btnLine.Bottom + Application.GetRealHeight(28);
                btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
                btnMsg.TextID = R.MyInternationalizationString.uNowDayNotHadAlarmLog;
                btnMsg.TextAlignment = TextAlignment.Center;
                this.AddChidren(btnMsg);
                this.frameTable.AddChidren(btnMsg);
            }
            //添加底部阴影特效
            this.frameTable.SetViewShadow(true);
        }
        #endregion
@@ -135,7 +157,7 @@
            FrameLayout frame = dicFrame[zoneId];
            //图标
            var btnIcon = new IconViewControl(69);
            btnIcon.X = Application.GetRealWidth(86);
            btnIcon.X = Application.GetRealWidth(29);
            btnIcon.Y = Application.GetRealHeight(23);
            //只会是1~5
            if (zoneId == 1 || zoneId == 2)
@@ -149,13 +171,13 @@
            frame.AddChidren(btnIcon);
            //防区名
            var btnName = new NormalViewControl(400, 58, true);
            btnName.X = Application.GetRealWidth(167);
            btnName.X = Application.GetRealWidth(109);
            btnName.Y = Application.GetRealHeight(35);
            btnName.Text = HdlSafeguardLogic.Current.GetGarrisonText(zoneId);
            frame.AddChidren(btnName);
            //已启动
            var btnStatu = new NormalViewControl(300, 46, true);
            btnStatu.X = frame.Width - Application.GetRealWidth(300 + 89);
            btnStatu.X = frame.Width - Application.GetRealWidth(300 + 35);
            btnStatu.Y = Application.GetRealHeight(35);
            btnStatu.TextSize = 12;
            btnStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
@@ -176,8 +198,34 @@
        /// <summary>
        /// 添加报警信息
        /// </summary>
        /// <param name="alarmInfo"></param>
        /// <returns></returns>
        public int AddSafeguardAlarmInfo(SafeguardAlarmInfo alarmInfo)
        {
            if (dicFrame.ContainsKey(alarmInfo.ZoneId) == false)
            {
                return -1;
            }
            //一条信息里面,它可能包含多个报警
            var listMsg = HdlAlarmsLogic.Current.GetSensorListAlarmMsg(alarmInfo);
            int valueCount = 0;
            foreach (var strMsg in listMsg)
            {
                //一个报警信息,一个控件
                int value = this.AddSafeguardAlarmInfo2(alarmInfo, strMsg);
                //这个value是控件增加的高度值
                valueCount += value;
            }
            return valueCount;
        }
        /// <summary>
        /// 添加报警信息(一个报警信息,一个控件)
        /// </summary>
        /// <param name="alarmInfo"></param>
        /// <param name="strMsg">针对一条数据里面包含多个报警的问题,追加的报警文本</param>
        /// <returns></returns>
        private int AddSafeguardAlarmInfo2(SafeguardAlarmInfo alarmInfo, string strMsg)
        {
            if (dicFrame.ContainsKey(alarmInfo.ZoneId) == false)
            {
@@ -206,7 +254,7 @@
            }
            //添加报警信息控件
            var frameRow = this.AddAlarmInfoControl(alarmInfo);
            var frameRow = this.AddAlarmInfoControl(alarmInfo, strMsg);
            if (listRow.Count >= 100)
            {
                //移除最后一个
@@ -251,8 +299,12 @@
            if (realHeight > 0)
            {
                //变更整个控件的真实高度 
                this.Height = realHeight;
                this.frameTable.Height = realHeight;
                this.Height = realHeight + Application.GetRealHeight(44);
            }
            //添加底部阴影特效
            this.frameTable.SetViewShadow(true);
            return value;
        }
@@ -261,7 +313,7 @@
        /// </summary>
        /// <param name="alarmInfo"></param>
        /// <returns></returns>
        private FrameLayout AddAlarmInfoControl(SafeguardAlarmInfo alarmInfo)
        private FrameLayout AddAlarmInfoControl(SafeguardAlarmInfo alarmInfo, string strMsg)
        {
            var frame = dicFrame[alarmInfo.ZoneId];
@@ -272,7 +324,7 @@
            //房间
            var btnRoom = new NormalViewControl(165, 58, true);
            btnRoom.X = Application.GetRealWidth(92);
            btnRoom.X = Application.GetRealWidth(35);
            btnRoom.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnRoom.Text = alarmInfo.RoomName;
            rowFrame.AddChidren(btnRoom);
@@ -280,32 +332,19 @@
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(alarmInfo.DeviceAddr, alarmInfo.DeviceEpoint);
            var device = Common.LocalDevice.Current.GetDevice(mainkeys);
            var btnDevice = new NormalViewControl(271, 58, true);
            btnDevice.X = Application.GetRealWidth(256);
            btnDevice.X = Application.GetRealWidth(199);
            btnDevice.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnDevice.Text = device == null ? alarmInfo.DeviceName : Common.LocalDevice.Current.GetDeviceEpointName(device);
            rowFrame.AddChidren(btnDevice);
            //报警信息
            var btnMsg = new NormalViewControl(303, 58, true);
            btnMsg.X = Application.GetRealWidth(527);
            btnMsg.X = Application.GetRealWidth(469);
            btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
            //电池电量
            if (alarmInfo.BatteryMsg != null)
            {
                btnMsg.Text = alarmInfo.BatteryMsg;
            }
            //被拆报警
            else if (alarmInfo.DemolishmentMsg != null)
            {
                btnMsg.Text = alarmInfo.DemolishmentMsg;
            }
            else
            {
                btnMsg.Text = alarmInfo.AlarmMsg;
            }
            btnMsg.Text = strMsg;
            rowFrame.AddChidren(btnMsg);
            //时间:时分秒
            var btnTime = new NormalViewControl(176, 58, true);
            btnTime.X = Application.GetRealWidth(829);
            var btnTime = new NormalViewControl(190, 58, true);
            btnTime.X = Application.GetRealWidth(758);
            btnTime.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTime.TextAlignment = TextAlignment.CenterRight;
            btnTime.Text = alarmInfo.Time;