From bba578c2f0acf2eca747edcb69426771e0cadd32 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 18:20:50 +0800
Subject: [PATCH] 2020-03-23-3
---
ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs | 309 +++++++++++++++++++++++++++++++-------------------
1 files changed, 190 insertions(+), 119 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
index 55ccfe5..76d6357 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
@@ -1,14 +1,14 @@
-锘縰sing System;
+锘縰sing 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 鈻� 鍙橀噺澹版槑___________________________
@@ -52,11 +52,9 @@
{
//娓呯┖bodyFrame
this.ClearBodyFrame();
- if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
- {
- //鍒濆鍖栧彸涓婅鍥炬爣
- this.InitTopRightIcon();
- }
+
+ //鍒濆鍖栧彸涓婅鍥炬爣
+ this.InitTopRightIcon();
//鍒濆鍖栧叏閮ㄥ唴瀛樹俊鎭�
this.InitAllMemoryData();
@@ -67,30 +65,31 @@
/// </summary>
private void InitTabSwitchControl()
{
+ var frameBack = new FrameLayout();
+ frameBack.Height = Application.GetRealHeight(1300);
+ frameBack.Y = Application.GetRealHeight(444);
+ frameBack.BackgroundColor = 0xa1ffffff;
+ frameBack.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
+ bodyFrameLayout.AddChidren(frameBack);
+
//妗屽竷鎺т欢
frameLayoutDraw = new FrameLayout();
- frameLayoutDraw.Y = Application.GetRealHeight(590);
- frameLayoutDraw.Height = bodyFrameLayout.Height - Application.GetRealHeight(590);
- bodyFrameLayout.AddChidren(frameLayoutDraw);
-
- //涓存椂鐨勪竴涓笢瑗�,鐢ㄦ潵璁$畻鐪熷疄鍊艰�屽凡
- var btnTemp = new NormalViewControl(100, false);
- int realLogWidth = btnTemp.GetRealWidthByText(16, Language.StringByID(R.MyInternationalizationString.uSecurityLog));
- int realSensorWidth = btnTemp.GetRealWidthByText(16, Language.StringByID(R.MyInternationalizationString.uSensorStatu));
- btnTemp = null;
+ frameLayoutDraw.Y = Application.GetRealHeight(181);
+ frameLayoutDraw.Height = frameBack.Height - Application.GetRealHeight(181);
+ frameBack.AddChidren(frameLayoutDraw);
//瀹夐槻璁板綍(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�)
var frameLog = new FrameLayoutControl();
frameLog.UseClickStatu = false;
frameLog.Height = Application.GetRealHeight(123);
- frameLog.Width = realLogWidth;
- frameLog.X = Application.GetRealWidth(489) - realLogWidth;
- frameLog.Y = Application.GetRealHeight(467);
- bodyFrameLayout.AddChidren(frameLog);
+ frameLog.Width = Application.GetRealWidth(273);
+ frameLog.X = Application.GetRealWidth(259);
+ frameLog.Y = Application.GetRealHeight(58);
+ frameBack.AddChidren(frameLog);
//鏍囬
var btnLog = new NormalViewControl(100, 63, true);
- btnLog.Width = realLogWidth;
- btnLog.TextAlignment = TextAlignment.CenterRight;
+ btnLog.Width = frameLog.Width;
+ btnLog.TextAlignment = TextAlignment.Center;
btnLog.TextID = R.MyInternationalizationString.uSecurityLog;
btnLog.TextColor = UserCenterColor.Current.TextGrayColor3;
frameLog.AddChidren(btnLog, ChidrenBindMode.BindEventOnly);
@@ -107,16 +106,18 @@
var frameSensor = new FrameLayoutControl();
frameSensor.UseClickStatu = false;
frameSensor.Height = frameLog.Height;
- frameSensor.Width = realSensorWidth;
- frameSensor.X = Application.GetRealWidth(550);
+ frameSensor.Width = frameLog.Width;
+ frameSensor.X = frameLog.Right;
frameSensor.Y = frameLog.Y;
- bodyFrameLayout.AddChidren(frameSensor);
+ frameBack.AddChidren(frameSensor);
//鏍囬
var btnSensor = new NormalViewControl(100, 63, true);
- btnSensor.Width = realSensorWidth;
+ btnSensor.Width = frameSensor.Width;
btnSensor.TextID = R.MyInternationalizationString.uSensorStatu;
btnSensor.TextSize = 16;
+ btnSensor.TextAlignment = TextAlignment.Center;
btnSensor.TextColor = UserCenterColor.Current.TextColor2;
+ btnSensor.IsBold = true;
frameSensor.AddChidren(btnSensor, ChidrenBindMode.BindEventOnly);
//搴曠嚎
var btnSensorLine = new NormalViewControl(40, 10, true);
@@ -132,8 +133,10 @@
//瀛椾綋澶у皬鍜岄鑹插彉鏇�
btnSensor.TextColor = UserCenterColor.Current.TextGrayColor3;
btnSensor.TextSize = 14;
+ btnSensor.IsBold = false;
btnLog.TextColor = UserCenterColor.Current.TextColor2;
btnLog.TextSize = 16;
+ btnLog.IsBold = true;
btnLogLine.Visible = true;
btnSensorLine.Visible = false;
@@ -150,8 +153,10 @@
//瀛椾綋澶у皬鍜岄鑹插彉鏇�
btnSensor.TextColor = UserCenterColor.Current.TextColor2;
btnSensor.TextSize = 16;
+ btnSensor.IsBold = true;
btnLog.TextColor = UserCenterColor.Current.TextGrayColor3;
btnLog.TextSize = 14;
+ btnLog.IsBold = false;
btnLogLine.Visible = false;
btnSensorLine.Visible = true;
@@ -168,28 +173,98 @@
/// </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(this, 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, 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.ResidenceOption.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.ResidenceOption.SafetyShortcut = false;
+ UserCenterResourse.ResidenceOption.Save();
+ btnShortCut.IsSelected = false;
+ });
+ }
+ else
+ {
+ //纭畾鍒涘缓銆屽畨闃层�嶆嵎寰勫埌涓婚〉锛�
+ this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () =>
+ {
+ UserCenterResourse.ResidenceOption.SafetyShortcut = true;
+ UserCenterResourse.ResidenceOption.Save();
+ btnShortCut.IsSelected = true;
+ });
+ }
};
}
@@ -278,12 +353,12 @@
/// <summary>
/// 鐢婚潰鍏抽棴
/// </summary>
- public override void CloseForm()
+ public override void CloseFormBefore()
{
//绉婚櫎鍏ㄩ儴鐩戝惉浜嬩欢
this.RemoveAllListenEvent();
- base.CloseForm();
+ base.CloseFormBefore();
}
/// <summary>
@@ -291,8 +366,8 @@
/// </summary>
private void RemoveAllListenEvent()
{
- HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
- HdlDeviceAttributeLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormAlarm");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("SafetyManagementMainFormReceivePushOnline");
}
#endregion
@@ -326,15 +401,15 @@
listView.Height = frameLayoutDraw.Height;
frameLayoutDraw.AddChidren(listView);
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
//鑾峰彇瀹夐槻鐨勫叏閮ㄤ紶鎰熷櫒璁惧鐨勪俊鎭�
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])
{
@@ -352,19 +427,15 @@
listDevice.Add(tempDevice);
}
}
- //鏈�鍚庝竴涓槻鍖虹殑鏃跺�欙紝寮�鍚悇绉嶇洃瑙嗙嚎绋�
- if (zoneId == dicDevice.Count)
- {
- //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
- this.StartCheckDeviceAlarm();
-
- //寮�鍚澶囧湪绾跨洃娴�
- this.StartCheckDeviceOnline(listDevice);
- }
- });
- }
- })
- { IsBackground = true }.Start();
+ }
+ //璋冩暣鍒楄〃鎺т欢楂樺害
+ listView.AdjustChidrenFrameHeight(listView.frameTable, Application.GetRealHeight(46));
+ //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
+ this.StartCheckDeviceAlarm();
+ //寮�鍚澶囧湪绾跨洃娴�
+ this.StartCheckDeviceOnline(listDevice);
+ });
+ });
}
/// <summary>
@@ -385,6 +456,8 @@
var frameDevice = new SafetySensorStatuControl();
listView.AddChidrenFrame(frameDevice);
frameDevice.InitControl(device);
+ //娣诲姞闃村奖鐗规晥
+ frameDevice.SetViewShadow(true);
string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
this.dicSensorStatuView[mainkeys] = frameDevice;
@@ -400,15 +473,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);
@@ -419,7 +490,7 @@
var control = this.dicSensorStatuView[mainkey];
//鑾峰彇浼犳劅鍣ㄦ姤璀︿俊鎭殑缈昏瘧鏂囨湰
var msgInfo = HdlAlarmsLogic.Current.GetSensorAlarmInfo(device);
- Application.RunOnMainThread(() =>
+ HdlThreadLogic.Current.RunMain(() =>
{
control?.SetSensoReportInfo(msgInfo);
});
@@ -445,16 +516,19 @@
{
return;
}
- var timeValue = (DateTime.Now - oldGetOnlineTime).Milliseconds;
- if (timeValue <= 10000)
+ if (oldGetOnlineTime.Year != 1900)
{
- //鏈�灏戣闂撮殧鍗佺,鎵嶅幓閲嶆柊鑾峰彇
- return;
+ var timeValue = (DateTime.Now - oldGetOnlineTime).TotalSeconds;
+ if (timeValue < 10)
+ {
+ //鏈�灏戣闂撮殧鍗佺,鎵嶅幓閲嶆柊鑾峰彇
+ return;
+ }
}
oldGetOnlineTime = DateTime.Now;
//浠庤澶囧垪琛ㄤ腑鑾峰彇鍦ㄧ嚎鐘舵��
- new System.Threading.Thread(async () =>
+ HdlThreadLogic.Current.RunThread(() =>
{
//棣栧厛鑾峰彇杩欎簺浼犳劅鍣ㄦ墍鍦ㄧ殑缃戝叧
var listWay = new List<ZbGateway>();
@@ -475,19 +549,27 @@
//鐣岄潰鍏抽棴
return;
}
- await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
+ int statu = 0;
+ var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
+ if (statu != -1)
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ //璁剧疆璁惧鍦ㄧ嚎鐘舵��
+ this.ReceiveDeviceStatuPush(list[i]);
+ }
+ }
}
- })
- { IsBackground = true }.Start();
+ });
}
/// <summary>
- /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ��(涓嶈蹇樿鏈�鍚庡畠浼氭帹閫佷竴涓狽ull鐨勪笢瑗胯繃鏉�)
+ /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ��
/// </summary>
/// <param name="device"></param>
private void ReceiveDeviceStatuPush(CommonDevice device)
{
- if (this.Parent == null || device == null)
+ if (this.Parent == null)
{
//鐣岄潰鍏抽棴
return;
@@ -553,11 +635,11 @@
this.dicSensorStatuView.Clear();
frameLayoutDraw.RemoveAll();
- var listView = new VerticalFrameControl(35);
+ var listView = new VerticalFrameControl(0);
listView.Height = frameLayoutDraw.Height;
frameLayoutDraw.AddChidren(listView);
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
var dicAlarm = HdlAlarmsLogic.Current.GetSafeguardAlarmInfo();
var dicInfo = new Dictionary<string, Dictionary<int, List<SafeguardAlarmInfo>>>();
@@ -602,6 +684,7 @@
}
//鎵ц鍒濆鍖�
TodaySafeguardFrame = new SafeguardLogControl();
+ TodaySafeguardFrame.Y = Application.GetRealHeight(10);
listView.AddChidrenFrame(TodaySafeguardFrame);
TodaySafeguardFrame.InitControl(nowDayKey, nowDayData);
@@ -630,45 +713,20 @@
//寮�鍚紶鎰熷櫒鎶ヨ鐩戣
this.StartCheckDeviceAlarm();
});
- })
- { IsBackground = true }.Start();
+ });
}
/// <summary>
/// 娣诲姞瀹夐槻璁惧涓婃姤鐨勮鎺т欢(瀹夐槻鎺ㄩ�佷細璋冪敤杩欎釜涓滆タ)
/// </summary>
- /// <param name="device">璁惧瀵硅薄锛屼负null鏃舵槸甯冮槻</param>
+ /// <param name="device">璁惧瀵硅薄</param>
public void AddSafeguardLogPushRow(CommonDevice device)
{
- if (device == null && HdlSafeguardLogic.Current.listAlarmInfo.Count > 0)
- {
- //濡傛灉鏄畨闃叉帹閫佺殑璇濓紝澶翠笂闈㈢殑閭d笁涓渾鍦堢殑鍥炬爣瑕佹敼鍙�
- 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);
@@ -704,6 +762,18 @@
});
}
+ /// <summary>
+ /// 闃插尯鎺ㄩ��
+ /// </summary>
+ /// <param name="garrison"></param>
+ public void GarrisonModePush(GarrisonMode garrison)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ garrisonControl?.SetIconStatuByGarrisonMode(garrison);
+ });
+ }
+
#endregion
#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
@@ -711,7 +781,7 @@
/// <summary>
/// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
/// </summary>
- public override void FormActionAgainEvent()
+ public override int FormActionAgainEvent()
{
//璁剧疆甯冮槻鎸夐挳鐨勫彲瑙嗙姸鎬�
garrisonControl?.SetButtonVisible();
@@ -726,8 +796,9 @@
//璁剧疆浼犳劅鍣ㄦ暟鎹埌鐢婚潰
this.SetSensorDataToForm();
}
+ return 1;
}
- #endregion
- }
-}
+ #endregion
+ }
+}
--
Gitblit v1.8.0