黄学彪
2019-11-25 160785587667cc0d927f85e44c139ec9dde13a9e
ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
@@ -1,14 +1,14 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 安防管理的主界面★
    /// </summary>
    public class SafetyManagementMainForm : EditorCommonForm
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 安防管理的主界面★
    /// </summary>
    public class SafetyManagementMainForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
@@ -346,12 +346,12 @@
        /// <summary>
        /// 画面关闭
        /// </summary>
        public override void CloseForm()
        public override void CloseFormBefore()
        {
            //移除全部监听事件
            this.RemoveAllListenEvent();
            base.CloseForm();
            base.CloseFormBefore();
        }
        /// <summary>
@@ -359,8 +359,8 @@
        /// </summary>
        private void RemoveAllListenEvent()
        {
            HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
            HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
            HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
            HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
        }
        #endregion
@@ -400,9 +400,9 @@
                var dicDevice = HdlSafeguardLogic.Current.GetAllSensorDeviceInfo();
                var listDevice = new List<CommonDevice>();
                foreach (var zoneId in dicDevice.Keys)
                HdlThreadLogic.Current.RunMain(() =>
                {
                    Application.RunOnMainThread(() =>
                    foreach (var zoneId in dicDevice.Keys)
                    {
                        foreach (var Info in dicDevice[zoneId])
                        {
@@ -420,17 +420,12 @@
                                listDevice.Add(tempDevice);
                            }
                        }
                        //最后一个防区的时候,开启各种监视线程
                        if (zoneId == dicDevice.Count)
                        {
                            //开启传感器报警监视
                            this.StartCheckDeviceAlarm();
                            //开启设备在线监测
                            this.StartCheckDeviceOnline(listDevice);
                        }
                    });
                }
                    }
                    //开启传感器报警监视
                    this.StartCheckDeviceAlarm();
                    //开启设备在线监测
                    this.StartCheckDeviceOnline(listDevice);
                });
            });
        }
@@ -452,6 +447,9 @@
            var frameDevice = new SafetySensorStatuControl();
            listView.AddChidrenFrame(frameDevice);
            frameDevice.InitControl(device);
            //添加阴影特效
            var btnTemp = new ButtonBase();
            btnTemp.AddBottomShadow(frameDevice);
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
            this.dicSensorStatuView[mainkeys] = frameDevice;
@@ -467,15 +465,13 @@
        private void StartCheckDeviceAlarm()
        {
            //根据接口推送,设置报警信息
            HdlDeviceAttributeLogic.Current.AddAttributeEvent("SafetyManagementMainFormAlarm", "IASInfoReport", (device) =>
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("SafetyManagementMainFormAlarm", ReceiveComandDiv.A传感器上报, (device) =>
            {
                if (HdlSafeguardLogic.Current.IsSensorDeviceExist(device) == false)
                {
                    //如果这个设备不存在于安防,则不处理
                    return;
                }
                //添加安防设备上报的行控件
                this.AddSafeguardLogPushRow(device);
                //传感器状态
                string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
@@ -622,7 +618,7 @@
            this.dicSensorStatuView.Clear();
            frameLayoutDraw.RemoveAll();
            var listView = new VerticalFrameControl(35);
            var listView = new VerticalFrameControl(0);
            listView.Height = frameLayoutDraw.Height;
            frameLayoutDraw.AddChidren(listView);
@@ -671,6 +667,7 @@
                    }
                    //执行初始化
                    TodaySafeguardFrame = new SafeguardLogControl();
                    TodaySafeguardFrame.Y = Application.GetRealHeight(10);
                    listView.AddChidrenFrame(TodaySafeguardFrame);
                    TodaySafeguardFrame.InitControl(nowDayKey, nowDayData);
@@ -705,38 +702,14 @@
        /// <summary>
        /// 添加安防设备上报的行控件(安防推送会调用这个东西)
        /// </summary>
        /// <param name="device">设备对象,为null时是布防</param>
        /// <param name="device">设备对象</param>
        public void AddSafeguardLogPushRow(CommonDevice device)
        {
            if (device == null && HdlSafeguardLogic.Current.listAlarmInfo.Count > 0)
            {
                //如果是安防推送的话,头上面的那三个圆圈的图标要改变
                Application.RunOnMainThread(() =>
                {
                    var infoTemp = HdlSafeguardLogic.Current.listAlarmInfo[0];
                    if (infoTemp.AlarmType == SafeguardAlarmType.AtHome)
                    {
                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.AtHome);
                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
                    }
                    else if (infoTemp.AlarmType == SafeguardAlarmType.RemoveHome)
                    {
                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.RemoveHome);
                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
                    }
                    else if (infoTemp.AlarmType == SafeguardAlarmType.RemoveGarrison)
                    {
                        garrisonControl?.SetIconStatuByGarrisonMode(GarrisonMode.RemoveGarrison);
                        this.ShowMassage(ShowMsgType.Tip, infoTemp.AlarmMsg);
                    }
                });
                return;
            }
            if (this.TabSelectIndex != 1 || HdlSafeguardLogic.Current.listAlarmInfo.Count == 0)
            if (this.TabSelectIndex != 1 || HdlAlarmsLogic.Current.listSafetyAlarmInfo.Count == 0)
            {
                return;
            }
            var info = HdlSafeguardLogic.Current.listAlarmInfo[0];
            var info = HdlAlarmsLogic.Current.listSafetyAlarmInfo[0];
            if (device != null)
            {
                string mainkey1 = Common.LocalDevice.Current.GetDeviceMainKeys(info.DeviceAddr, info.DeviceEpoint);
@@ -772,6 +745,18 @@
            });
        }
        /// <summary>
        /// 防区推送
        /// </summary>
        /// <param name="garrison"></param>
        public void GarrisonModePush(GarrisonMode garrison)
        {
            HdlThreadLogic.Current.RunMain(() =>
            {
                garrisonControl?.SetIconStatuByGarrisonMode(garrison);
            });
        }
        #endregion
        #region ■ 界面重新激活事件___________________
@@ -797,6 +782,6 @@
            return 1;
        }
        #endregion
    }
}
        #endregion
    }
}