From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 17 十二月 2020 09:07:13 +0800 Subject: [PATCH] 新云端Ver1.3 --- ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs | 154 +++++++++++++++++++++++++-------------------------- 1 files changed, 76 insertions(+), 78 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs index 015a7d6..4b5ea8d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs @@ -15,7 +15,7 @@ /// <summary> /// 妗屽竷鎺т欢锛岀敤浜庡瓨鏀炬垨鑰呯Щ闄ゅ姛鑳藉潡鎺т欢(Tab鎺т欢涓撶敤) /// </summary> - private FrameLayout frameLayoutDraw = null; + private NormalFrameLayout frameLayoutDraw = null; /// <summary> /// 瀹夐槻鎺т欢 /// </summary> @@ -73,17 +73,28 @@ bodyFrameLayout.AddChidren(frameBack); //妗屽竷鎺т欢 - frameLayoutDraw = new FrameLayout(); + frameLayoutDraw = new NormalFrameLayout(); frameLayoutDraw.Y = Application.GetRealHeight(181); frameLayoutDraw.Height = frameBack.Height - Application.GetRealHeight(181); frameBack.AddChidren(frameLayoutDraw); + //璁$畻瀹藉害浣跨敤 + var btnTemp = new ButtonBase(); + btnTemp.TextSize = 16; + btnTemp.IsBold = true; + + btnTemp.TextID = R.MyInternationalizationString.uSecurityLog; + int frameLogWidth = btnTemp.GetRealWidthByText() + Application.GetRealWidth(30); + + btnTemp.TextID = R.MyInternationalizationString.uSensorStatu; + int frameSensorWidth = btnTemp.GetRealWidthByText() + Application.GetRealWidth(30); + //瀹夐槻璁板綍(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�) - var frameLog = new FrameLayoutControl(); + var frameLog = new FrameLayoutStatuControl(); frameLog.UseClickStatu = false; frameLog.Height = Application.GetRealHeight(123); - frameLog.Width = Application.GetRealWidth(273); - frameLog.X = Application.GetRealWidth(259); + frameLog.Width = frameLogWidth; + frameLog.X = (frameBack.Width - frameLogWidth - frameSensorWidth) / 2; frameLog.Y = Application.GetRealHeight(58); frameBack.AddChidren(frameLog); //鏍囬 @@ -92,21 +103,22 @@ btnLog.TextAlignment = TextAlignment.Center; btnLog.TextID = R.MyInternationalizationString.uSecurityLog; btnLog.TextColor = UserCenterColor.Current.TextGrayColor3; - frameLog.AddChidren(btnLog, ChidrenBindMode.BindEventOnly); + frameLog.AddChidren(btnLog, ChidrenBindMode.BindEvent); //搴曠嚎 var btnLogLine = new NormalViewControl(40, 10, true); btnLogLine.Y = Application.GetRealHeight(86); - btnLogLine.X = btnLog.X + btnLog.Width / 2 - Application.GetRealWidth(40) / 2; + //btnLogLine.X = btnLog.X + btnLog.Width / 2 - Application.GetRealWidth(40) / 2; + btnLogLine.Gravity = Gravity.CenterHorizontal; btnLogLine.Radius = (uint)Application.GetRealHeight(10) / 2; btnLogLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor; - frameLog.AddChidren(btnLogLine, ChidrenBindMode.BindEventOnly); + frameLog.AddChidren(btnLogLine, ChidrenBindMode.BindEvent); btnLogLine.Visible = false; //浼犳劅鍣ㄧ姸鎬�(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�) - var frameSensor = new FrameLayoutControl(); + var frameSensor = new FrameLayoutStatuControl(); frameSensor.UseClickStatu = false; frameSensor.Height = frameLog.Height; - frameSensor.Width = frameLog.Width; + frameSensor.Width = frameSensorWidth; frameSensor.X = frameLog.Right; frameSensor.Y = frameLog.Y; frameBack.AddChidren(frameSensor); @@ -118,14 +130,15 @@ btnSensor.TextAlignment = TextAlignment.Center; btnSensor.TextColor = UserCenterColor.Current.TextColor2; btnSensor.IsBold = true; - frameSensor.AddChidren(btnSensor, ChidrenBindMode.BindEventOnly); + frameSensor.AddChidren(btnSensor, ChidrenBindMode.BindEvent); //搴曠嚎 var btnSensorLine = new NormalViewControl(40, 10, true); btnSensorLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor; btnSensorLine.Y = btnLogLine.Y; - btnSensorLine.X = btnSensor.X + btnSensor.Width / 2 - Application.GetRealWidth(40) / 2; + //btnSensorLine.X = btnSensor.X + btnSensor.Width / 2 - Application.GetRealWidth(40) / 2; + btnSensorLine.Gravity = Gravity.CenterHorizontal; btnSensorLine.Radius = (uint)Application.GetRealHeight(10) / 2; - frameSensor.AddChidren(btnSensorLine, ChidrenBindMode.BindEventOnly); + frameSensor.AddChidren(btnSensorLine, ChidrenBindMode.BindEvent); //瀹夐槻璁板綍Tab frameLog.ButtonClickEvent += (sender, e) => @@ -178,7 +191,7 @@ btnShortCut.UnSelectedImagePath = "Safeguard/SafetyShortcut.png"; btnShortCut.SelectedImagePath = "Safeguard/SafetyShortcutSelected.png"; - if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) { //蹇嵎鏂瑰紡鍚戝乏绉诲姩 btnShortCut.X = Application.GetRealWidth(855); @@ -238,7 +251,7 @@ topFrameLayout.AddChidren(btnShortCut); btnShortCut.InitControl(); - if (UserCenterResourse.Option.SafetyShortcut == true) + if (HdlUserCenterResourse.ResidenceOption.SafetyShortcut == true) { //浣跨敤蹇嵎鏂瑰紡 btnShortCut.IsSelected = true; @@ -250,9 +263,11 @@ //纭畾鍙栨秷涓婚〉鐨勩�屽畨闃层�嶆嵎寰勶紵 this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCancelSafetyShortcutMsg), () => { - UserCenterResourse.Option.SafetyShortcut = false; - UserCenterResourse.Option.Save(); + HdlUserCenterResourse.ResidenceOption.SafetyShortcut = false; + HdlUserCenterResourse.ResidenceOption.Save(); btnShortCut.IsSelected = false; + //鍙栨秷涓婚〉鐨勩�屽畨闃层�嶆嵎寰勭殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂� + UserView.UserPage.Instance.RefreshAllForm = true; }); } else @@ -260,9 +275,11 @@ //纭畾鍒涘缓銆屽畨闃层�嶆嵎寰勫埌涓婚〉锛� this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () => { - UserCenterResourse.Option.SafetyShortcut = true; - UserCenterResourse.Option.Save(); + HdlUserCenterResourse.ResidenceOption.SafetyShortcut = true; + HdlUserCenterResourse.ResidenceOption.Save(); btnShortCut.IsSelected = true; + //鍒涘缓涓婚〉鐨勩�屽畨闃层�嶆嵎寰勭殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂� + UserView.UserPage.Instance.RefreshAllForm = true; }); } }; @@ -311,7 +328,7 @@ this.CloseProgressBar(); //鏁版嵁鍒濆鍖栧畬鎴愬悗 - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { //鍒濆鍖栧ご閮ㄧ殑閭d笁涓浘鏍� garrisonControl = new SafetyMasterControl(); @@ -421,7 +438,7 @@ this.AddSensorStatuRow(listView, zoneId, Info); //鏀堕泦浼犳劅鍣� - var tempDevice = Common.LocalDevice.Current.GetDevice(Info.MacAddr, Info.Epoint); + var tempDevice = HdlDeviceCommonLogic.Current.GetDevice(Info.MacAddr, Info.Epoint); if (tempDevice != null) { listDevice.Add(tempDevice); @@ -446,7 +463,7 @@ /// <param name="sensorInfo">浼犳劅鍣ㄧ殑淇℃伅</param> private void AddSensorStatuRow(VerticalFrameControl listView, int zoneID, Safeguard.ZoneDeviceListData sensorInfo) { - CommonDevice device = Common.LocalDevice.Current.GetDevice(sensorInfo.MacAddr, sensorInfo.Epoint); + CommonDevice device = HdlDeviceCommonLogic.Current.GetDevice(sensorInfo.MacAddr, sensorInfo.Epoint); if (device == null) { return; @@ -454,12 +471,12 @@ //鑷畾涔変紶鎰熷櫒鐘舵�佹帶浠� var frameDevice = new SafetySensorStatuControl(); - listView.AddChidrenFrame(frameDevice); + listView.AddChidren(frameDevice); frameDevice.InitControl(device); //娣诲姞闃村奖鐗规晥 frameDevice.SetViewShadow(true); - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); + string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); this.dicSensorStatuView[mainkeys] = frameDevice; } @@ -482,7 +499,7 @@ } //浼犳劅鍣ㄧ姸鎬� - string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device); + string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); if (this.dicSensorStatuView.ContainsKey(mainkey) == false) { return; @@ -530,78 +547,59 @@ //浠庤澶囧垪琛ㄤ腑鑾峰彇鍦ㄧ嚎鐘舵�� HdlThreadLogic.Current.RunThread(() => { - //棣栧厛鑾峰彇杩欎簺浼犳劅鍣ㄦ墍鍦ㄧ殑缃戝叧 - var listWay = new List<ZbGateway>(); foreach (var device in listDevice) - { - ZbGateway realWay = null; - //鏄惁瀛樺湪鐪熷疄鐗╃悊缃戝叧 - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, device.CurrentGateWayId) == false) - { - continue; - } - listWay.Add(realWay); - } - foreach (var zbway in listWay) { if (this.Parent == null) { //鐣岄潰鍏抽棴 return; } - int statu = 0; - var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); - if (statu != -1) + var deviceInfo = HdlDeviceCommonLogic.Current.ReadDeviceEpointDeviceInfo(device); + if (deviceInfo != null) { - for (int i = 0; i < list.Count; i++) - { - //璁剧疆璁惧鍦ㄧ嚎鐘舵�� - this.ReceiveDeviceStatuPush(list[i]); - } + //璁剧疆璁惧鍦ㄧ嚎鐘舵�� + this.ReceiveDeviceStatuPush(device, deviceInfo); } + System.Threading.Thread.Sleep(50); } - }); + }, ShowErrorMode.NO); } /// <summary> /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�� /// </summary> /// <param name="device"></param> - private void ReceiveDeviceStatuPush(CommonDevice device) + private void ReceiveDeviceStatuPush(CommonDevice device, CommonDevice.DeviceInfoData deviceInfo) { if (this.Parent == null) { //鐣岄潰鍏抽棴 return; } - - lock (objOnlineLock) + string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); + if (this.dicSensorStatuView.ContainsKey(mainkeys) == true) { - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); - if (this.dicSensorStatuView.ContainsKey(mainkeys) == true) + CommonDevice Loacldevice = HdlDeviceCommonLogic.Current.GetDevice(mainkeys); + if (Loacldevice == null) { - CommonDevice Loacldevice = Common.LocalDevice.Current.GetDevice(mainkeys); - if (Loacldevice == null) - { - return; - } - //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� - if (Loacldevice.IsOnline == device.IsOnline) - { - return; - } - //淇濆瓨鐘舵�� - Loacldevice.IsOnline = device.IsOnline; - Loacldevice.ReSave(); - - //鍥犱负杩欐槸鎺ㄩ�佽繃鏉ョ殑锛屾垜涓嶄繚璇侀偅涓�鐬棿杩欎釜涓滆タ浼氫笉浼氳绉婚櫎 - var control = this.dicSensorStatuView[mainkeys]; - Application.RunOnMainThread(() => - { - //璁剧疆鎺т欢鐨勫湪绾跨姸鎬佹枃鏈晥鏋� - control?.SetOnlineStatu(device.IsOnline == 1); - }); + return; } + //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� + if (Loacldevice.IsOnline == deviceInfo.IsOnline) + { + return; + } + //淇濆瓨鐘舵�� + Loacldevice.IsOnline = deviceInfo.IsOnline; + + //鍥犱负杩欐槸鎺ㄩ�佽繃鏉ョ殑锛屾垜涓嶄繚璇侀偅涓�鐬棿杩欎釜涓滆タ浼氫笉浼氳绉婚櫎 + var control = this.dicSensorStatuView[mainkeys]; + HdlThreadLogic.Current.RunMain(() => + { + //璁剧疆鎺т欢鐨勫湪绾跨姸鎬佹枃鏈晥鏋� + bool bolOnline = HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(device); + control?.SetOnlineStatu(bolOnline); + }); } } @@ -667,7 +665,7 @@ } dicAlarm = null; - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { if (this.Parent == null) { @@ -685,7 +683,7 @@ //鎵ц鍒濆鍖� TodaySafeguardFrame = new SafeguardLogControl(); TodaySafeguardFrame.Y = Application.GetRealHeight(10); - listView.AddChidrenFrame(TodaySafeguardFrame); + listView.AddChidren(TodaySafeguardFrame); TodaySafeguardFrame.InitControl(nowDayKey, nowDayData); //鍒濆鍖栧叾浠栨棩鏈熺殑瀹夐槻璁板綍鎺т欢 @@ -693,7 +691,7 @@ { otherDaySafeguardFrame = new FrameLayout(); otherDaySafeguardFrame.Height = Application.GetRealHeight(10); - listView.AddChidrenFrame(otherDaySafeguardFrame); + listView.AddChidren(otherDaySafeguardFrame); foreach (var dayText in dicInfo.Keys) { //鎵ц鍒濆鍖� @@ -729,8 +727,8 @@ var info = HdlAlarmsLogic.Current.listSafetyAlarmInfo[0]; if (device != null) { - string mainkey1 = Common.LocalDevice.Current.GetDeviceMainKeys(info.DeviceAddr, info.DeviceEpoint); - string mainkey2 = Common.LocalDevice.Current.GetDeviceMainKeys(device); + string mainkey1 = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(info.DeviceAddr, info.DeviceEpoint); + string mainkey2 = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); if (mainkey1 != mainkey2) { //涓嶆槸鍚屼竴涓笢瑗� @@ -738,7 +736,7 @@ } } - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { if (this.TodaySafeguardFrame != null) { -- Gitblit v1.8.0