From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs | 184 ++++++++++++++++++++++++++++++--------------- 1 files changed, 123 insertions(+), 61 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs index 09a400e..02092c1 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs @@ -24,14 +24,6 @@ /// </summary> private VerticalFrameControl listBackContr = null; /// <summary> - /// 妤煎眰椤哄簭 - /// </summary> - private List<string> listFloorSort = new List<string>(); - /// <summary> - /// 鎴块棿椤哄簭 - /// </summary> - private List<string> listRoomSort = new List<string>(); - /// <summary> /// 褰撳墠APP鐨勪綇瀹呮ā寮� 0:杩樻病鏈夎缃湁妯″紡 1:妤煎眰妯″紡 2:娌℃湁妤煎眰妯″紡 /// </summary> private int AppResidenceMode = 0; @@ -52,8 +44,12 @@ //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟 if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) { - //鍒濆鍖栧彸涓婅鑿滃崟 - this.InitTopRightMenu(); + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == false) + { + //鍒濆鍖栧彸涓婅鑿滃崟 + this.InitTopRightMenu(); + } } //鍒濆鍖栦腑閮ㄤ俊鎭� this.InitMiddleFrame(i_CanDeleteResidence); @@ -110,27 +106,19 @@ if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) { rowHome.frameTable.UseClickStatu = true; + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + rowHome.frameTable.CanClick = false; + } rowHome.frameTable.ButtonClickEvent += (sender, e) => { - //榛樿鍊� 23.134421,113.267189 - double latitude = Common.Config.Instance.Home.Latitude; - double longitude = Common.Config.Instance.Home.Longitude; - //鍦板浘 - GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => - { - HdlThreadLogic.Current.RunThread(() => - { - //淇濆瓨浣忓畢鍦板潃 - this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name); - }); - }, - Language.StringByID(R.MyInternationalizationString.uSelectAdrress), - Language.StringByID(R.MyInternationalizationString.uSave), - true, latitude, longitude, 100); + //妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘 + this.CheckAuthorityAndShowMap(btnLocation); }; } - if (i_CanDeleteResidence == true) + if (i_CanDeleteResidence == true && Common.Config.Instance.Home.IsShowTemplate == false) { //鍒犻櫎 var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowHome.Height, false); @@ -282,23 +270,17 @@ { //鑾峰彇妤煎眰 var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); - this.listFloorSort.Clear(); - foreach (string keys in dicFloor.Keys) - { - listFloorSort.Add(keys); - } - - if (Common.Config.Instance.Home.FloorDics.Count == 0) + if (dicFloor.Count == 0) { return; } HdlThreadLogic.Current.RunMainInThread(() => { - int count = listFloorSort.Count - 1; - for (int i = 0; i < listFloorSort.Count; i++) + int count = dicFloor.Count; + foreach (var keys in dicFloor.Keys) { - string keys = listFloorSort[i]; - this.AddFloorRow(keys, dicFloor[keys], i != count); + count--; + this.AddFloorRow(keys, dicFloor[keys], count != 0); } //璋冩暣鎺т欢楂樺害 this.AdjustContrlTableHeight(); @@ -340,6 +322,11 @@ if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) { + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + return; + } //鏇存敼 var btnChanged = frameRow.AddEditorControl(); btnChanged.TextID = R.MyInternationalizationString.uChanged1; @@ -366,17 +353,18 @@ Common.Config.Instance.Home.FloorDics.Remove(keys); if (Common.Config.Instance.Home.CurrentFloorId == keys) { - //濡傛灉鍒犻櫎鐨勬槸褰撳墠妤煎眰鐨勮瘽 Common.Config.Instance.Home.CurrentFloorId = string.Empty; - foreach (string floorId in Common.Config.Instance.Home.FloorDics.Keys) + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); + foreach (var floorId in dicFloor.Keys) { - //鎶婄涓�涓ゼ灞侷D缁欏畠 + //鎶婄涓�涓ゼ灞傝祴鍊肩粰褰撳墠妤煎眰 Common.Config.Instance.Home.CurrentFloorId = floorId; break; } //鍒犻櫎褰撳墠妤煎眰鐨勮瘽,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛� HdlRoomLogic.Current.RefreshRoomListView(); } + var uploadRoom = false; var listDeleteId = new List<string>(); var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); for (int i = 0; i < listAllRoom.Count; i++) @@ -385,6 +373,11 @@ { listDeleteId.Add(listAllRoom[i].Id); } + if (listAllRoom[i].ListDevice.Count > 0) + { + //闇�瑕佷笂浼犵┖闂村尯鍩� + uploadRoom = true; + } } //鍒犻櫎鎴块棿 foreach (string roomId in listDeleteId) @@ -392,9 +385,6 @@ HdlRoomLogic.Current.RemoveRoom(roomId); } Common.Config.Instance.Home.Save(); - //淇濆瓨椤哄簭 - listFloorSort.Remove(keys); - HdlRoomLogic.Current.SaveFloorSort(listFloorSort); if (Common.Config.Instance.Home.FloorDics.Count == 0) { @@ -422,8 +412,13 @@ //璋冩暣妗屽竷楂樺害 this.AdjustContrlTableHeight(); } + if (uploadRoom == true) + { + //涓婁紶绌洪棿鍖哄煙淇℃伅 + HdlRoomLogic.Current.SetRoomInfoToGateway(); + } //鍒犻櫎妤煎眰鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - UserView.UserPage.Instance.RefreshForm = true; + UserView.UserPage.Instance.RefreshAllForm = true; }); }; } @@ -477,14 +472,15 @@ { keys = Guid.NewGuid().ToString(); } + bool hadFloor = Common.Config.Instance.Home.CurrentFloorId != string.Empty; Common.Config.Instance.Home.FloorDics[keys] = textValue; Common.Config.Instance.Home.Save(); - if (Common.Config.Instance.Home.CurrentFloorId == string.Empty) + if (hadFloor == false) { - Common.Config.Instance.Home.CurrentFloorId = keys; //鍒涘缓绗竴涓柊鐨勬ゼ灞傜殑璇�,闇�瑕佸幓鍒锋柊涓婚〉宸﹁竟鐨勬埧闂村垪琛� HdlRoomLogic.Current.RefreshRoomListView(); } + if (btnFloor != null) { btnFloor.Text = textValue; @@ -495,7 +491,7 @@ this.InitFrameTableByMode(); } //鍒涘缓鎴栬�呬慨鏀规ゼ灞傜殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂� - UserView.UserPage.Instance.RefreshForm = true; + UserView.UserPage.Instance.RefreshAllForm = true; } }); } @@ -540,12 +536,6 @@ { //鑾峰彇妤煎眰鐨勬埧闂� var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty); - this.listRoomSort.Clear(); - for (int i = 0; i < listRoom.Count; i++) - { - this.listRoomSort.Add(listRoom[i].Id); - } - for (int i = 0; i < listRoom.Count; i++) { //娣诲姞鎴块棿琛� @@ -593,7 +583,6 @@ //濡傛灉鏄垎浜殑鎴块棿锛屼笉鑳界紪杈戝拰淇敼 return; } - //缂栬緫 var btnEditor = frameRow.AddEditorControl(); btnEditor.ButtonClickEvent += (sender, e) => @@ -605,7 +594,12 @@ btnName.Text = roomName; }; }; - + //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + btnEditor.Text = Language.StringByID(R.MyInternationalizationString.uSearch1); + return; + } //鍒犻櫎 var btnDelete = frameRow.AddDeleteControl(); btnDelete.ButtonClickEvent += (sender, e) => @@ -614,9 +608,6 @@ this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () => { HdlRoomLogic.Current.RemoveRoom(room.Id); - //淇濆瓨椤哄簭 - this.listRoomSort.Remove(room.Id); - HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort); var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); if (listAllRoom.Count <= 1) @@ -645,8 +636,13 @@ //璋冩暣妗屽竷楂樺害 this.AdjustContrlTableHeight(); } + if (room.ListDevice.Count > 0) + { + //涓婁紶绌洪棿鍖哄煙淇℃伅 + HdlRoomLogic.Current.SetRoomInfoToGateway(); + } //鍒犻櫎鎴块棿鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - UserView.UserPage.Instance.RefreshForm = true; + UserView.UserPage.Instance.RefreshAllForm = true; }); }; } @@ -721,16 +717,22 @@ var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]); //鍒囨崲浣忓畢 Common.Config.Instance.HomeId = myHouse.Id; + Common.Config.Instance.Home = myHouse; Common.Global.CreateHomeDirectory(myHouse.Id); Common.Config.Instance.Save(); //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ - UserCenterLogic.InitUserCenterMenmoryAndThread(false); + bool result2 = UserCenterLogic.InitUserCenterMenmoryAndThread(false); + if (result2 == false) + { + //寮�鍚簡璋冭瘯鍔熻兘 + return; + } //鍒犻櫎浣忓畢 HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId); - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { //鍏抽棴鐣岄潰 this.CloseForm(); @@ -739,6 +741,66 @@ #endregion + #region 鈻� 鏄剧ず鍦板浘___________________________ + + /// <summary> + /// 妫�娴嬫潈闄�,鐒跺悗鏄剧ず鍦板浘 + /// </summary> + /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param> + private void CheckAuthorityAndShowMap(NormalViewControl btnLocation) + { +#if Android + //鐢宠瀹氫綅鏉冮檺 + ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) => + { + if (result1 == false) { return; } + + //鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠� + ((BaseActivity)Application.Activity).SetPermission((result2) => + { + if (result2 == false) { return; } + //璇诲彇鐢佃瘽鐘舵�佹潈闄� + ((BaseActivity)Application.Activity).SetPermission((result3) => + { + if (result3 == false) { return; } + //鏄剧ず鍦板浘 + this.ShowMap(btnLocation); + }, "android.permission.READ_PHONE_STATE"); + + }, "android.permission.WRITE_EXTERNAL_STORAGE"); + }); +#endif +#if iOS + //鏄剧ず鍦板浘 + this.ShowMap(btnLocation); +#endif + } + + /// <summary> + /// 鏄剧ず鍦板浘 + /// </summary> + /// <param name="btnLocation">鍦板潃鏄剧ず鎺т欢</param> + private void ShowMap(NormalViewControl btnLocation) + { + //榛樿鍊� 23.134421,113.267189 + double latitude = Common.Config.Instance.Home.Latitude; + double longitude = Common.Config.Instance.Home.Longitude; + //鍦板浘 + GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => + { + HdlThreadLogic.Current.RunThread(() => + { + //淇濆瓨浣忓畢鍦板潃 + this.SaveResidenceAdrress(btnLocation, mLatitude, mLongitude, name); + }); + }, + Language.StringByID(R.MyInternationalizationString.uSelectAdrress), + Language.StringByID(R.MyInternationalizationString.uSave), + true, latitude, longitude, 100); + } + + #endregion + #region 鈻� 淇濆瓨浣忓畢鍦板浘鍦板潃___________________ /// <summary> -- Gitblit v1.8.0