| | |
| | | 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 ■ 变量声明___________________________
|
| | |
|
| | |
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //初始化右上角图标
|
| | | this.InitTopRightIcon();
|
| | | }
|
| | |
|
| | | //初始化右上角图标
|
| | | this.InitTopRightIcon();
|
| | |
|
| | | //初始化全部内存信息
|
| | | this.InitAllMemoryData();
|
| | |
| | | /// </summary>
|
| | | private void InitTopRightIcon()
|
| | | {
|
| | | var btnIcon = new MostRightIconControl(69, 69);
|
| | | btnIcon.UnSelectedImagePath = "Item/More.png";
|
| | | topFrameLayout.AddChidren(btnIcon);
|
| | | btnIcon.InitControl();
|
| | | btnIcon.ButtonClickEvent += (sender, e) =>
|
| | | //快捷方式
|
| | | var btnShortCut = new MostRightIconControl(69, 69);
|
| | | btnShortCut.UnSelectedImagePath = "Safeguard/SafetyShortcut.png";
|
| | | btnShortCut.SelectedImagePath = "Safeguard/SafetyShortcutSelected.png";
|
| | |
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //菜单控件
|
| | | var frameMenu = new TopRightMenuControl(2);
|
| | | //防区列表
|
| | | string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
|
| | | frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
|
| | | //快捷方式向左移动
|
| | | btnShortCut.X = Application.GetRealWidth(855);
|
| | |
|
| | | var btnIcon = new MostRightIconControl(69, 69);
|
| | | btnIcon.UnSelectedImagePath = "Item/More.png";
|
| | | topFrameLayout.AddChidren(btnIcon);
|
| | | btnIcon.InitControl();
|
| | | btnIcon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new GarrisonAreaListMenuForm();
|
| | | form.AddForm();
|
| | | });
|
| | | //密码设置
|
| | | string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
|
| | | frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
|
| | | //菜单控件
|
| | | var frameMenu = new TopRightMenuControl(2);
|
| | | //防区列表
|
| | | string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
|
| | | frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
|
| | | {
|
| | | HdlCheckLogic.Current.CheckSecondarySecurity(() =>
|
| | | { |
| | | //验证成功
|
| | | var form = new GarrisonAreaListMenuForm();
|
| | | form.AddForm(); |
| | | }, |
| | | () =>
|
| | | {
|
| | | //请前往个人中心{0}设置二次安全验证方式
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | var form = new UserMain.SecondAuthenticationForm();
|
| | | form.AddForm();
|
| | | });
|
| | | });
|
| | | });
|
| | | //密码设置
|
| | | string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
|
| | | frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
|
| | | {
|
| | | HdlCheckLogic.Current.CheckSecondarySecurity(() =>
|
| | | {
|
| | | //验证成功
|
| | | var form = new PasswordMenuForm();
|
| | | form.AddForm();
|
| | | },
|
| | | () =>
|
| | | {
|
| | | //请前往个人中心{0}设置二次安全验证方式
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | var form = new UserMain.SecondAuthenticationForm();
|
| | | form.AddForm();
|
| | | });
|
| | | });
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | topFrameLayout.AddChidren(btnShortCut);
|
| | | btnShortCut.InitControl();
|
| | | if (UserCenterResourse.Option.SafetyShortcut == true)
|
| | | {
|
| | | //使用快捷方式
|
| | | btnShortCut.IsSelected = true;
|
| | | }
|
| | | btnShortCut.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (btnShortCut.IsSelected == true)
|
| | | {
|
| | | var form = new SafetyPasswordMenuForm();
|
| | | form.AddForm();
|
| | | });
|
| | | //确定取消主页的「安防」捷径?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCancelSafetyShortcutMsg), () =>
|
| | | {
|
| | | UserCenterResourse.Option.SafetyShortcut = false;
|
| | | UserCenterResourse.Option.Save();
|
| | | btnShortCut.IsSelected = false;
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | //确定创建「安防」捷径到主页?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () =>
|
| | | {
|
| | | UserCenterResourse.Option.SafetyShortcut = true;
|
| | | UserCenterResourse.Option.Save();
|
| | | btnShortCut.IsSelected = true;
|
| | | });
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary>
|
| | | public override void CloseForm()
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | //移除全部监听事件
|
| | | this.RemoveAllListenEvent();
|
| | |
|
| | | base.CloseForm();
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | private void RemoveAllListenEvent()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | 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])
|
| | | {
|
| | |
| | | listDevice.Add(tempDevice);
|
| | | }
|
| | | }
|
| | | //最后一个防区的时候,开启各种监视线程
|
| | | if (zoneId == dicDevice.Count)
|
| | | {
|
| | | //开启传感器报警监视
|
| | | this.StartCheckDeviceAlarm();
|
| | |
|
| | | //开启设备在线监测
|
| | | this.StartCheckDeviceOnline(listDevice);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | //开启传感器报警监视
|
| | | this.StartCheckDeviceAlarm();
|
| | | //开启设备在线监测
|
| | | this.StartCheckDeviceOnline(listDevice);
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | var frameDevice = new SafetySensorStatuControl();
|
| | | listView.AddChidrenFrame(frameDevice);
|
| | | frameDevice.InitControl(device);
|
| | | //添加阴影特效
|
| | | frameDevice.SetViewShadow(true);
|
| | |
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | this.dicSensorStatuView[mainkeys] = frameDevice;
|
| | |
| | | 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);
|
| | |
| | | oldGetOnlineTime = DateTime.Now;
|
| | |
|
| | | //从设备列表中获取在线状态
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //首先获取这些传感器所在的网关
|
| | | var listWay = new List<ZbGateway>();
|
| | |
| | | //界面关闭
|
| | | return;
|
| | | }
|
| | | await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
|
| | | Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | this.dicSensorStatuView.Clear();
|
| | |
|
| | | frameLayoutDraw.RemoveAll();
|
| | | var listView = new VerticalFrameControl(35);
|
| | | var listView = new VerticalFrameControl(0);
|
| | | listView.Height = frameLayoutDraw.Height;
|
| | | frameLayoutDraw.AddChidren(listView);
|
| | |
|
| | |
| | | }
|
| | | //执行初始化
|
| | | TodaySafeguardFrame = new SafeguardLogControl();
|
| | | TodaySafeguardFrame.Y = Application.GetRealHeight(10);
|
| | | listView.AddChidrenFrame(TodaySafeguardFrame);
|
| | | TodaySafeguardFrame.InitControl(nowDayKey, nowDayData);
|
| | |
|
| | |
| | | /// <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);
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 防区推送
|
| | | /// </summary>
|
| | | /// <param name="garrison"></param>
|
| | | public void GarrisonModePush(GarrisonMode garrison)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | garrisonControl?.SetIconStatuByGarrisonMode(garrison);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面重新激活事件___________________
|
| | |
| | | return 1;
|
| | | }
|
| | |
|
| | | #endregion |
| | | } |
| | | } |
| | | #endregion
|
| | | }
|
| | | }
|