From cc0d80c7d86c6d0167269b3408c4b30c24ce84e9 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 16:55:37 +0800
Subject: [PATCH] ???????
---
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs | 231 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 195 insertions(+), 36 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
index 434417d..30cd414 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -68,6 +68,7 @@
rowHome.Height = Application.GetRealHeight(173);
rowHome.BackgroundColor = UserCenterColor.Current.White;
bodyFrameLayout.AddChidren(rowHome);
+ rowHome.frameTable.UseClickStatu = false;
var btnAdreeIcon = rowHome.frameTable.AddLeftIcon(81);
btnAdreeIcon.UnSelectedImagePath = "Item/FixedPositionSelected.png";
@@ -83,8 +84,36 @@
btnNowView.Y = Application.GetRealHeight(95);
btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
rowHome.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
- //鍙崇澶�
- rowHome.frameTable.AddRightArrow();
+ //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
+ if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+ {
+ //鍙崇澶�
+ rowHome.frameTable.AddRightArrow();
+ }
+ //缁忕含搴�
+ var btnLocation = rowHome.frameTable.AddMostRightView(string.Empty, 500);
+ btnLocation.Text = this.GetLatitudeAndLongitudeText(Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
+
+ //涓讳汉鎴栬�呯鐞嗗憳鎵嶄細鍑虹幇杩欎釜鑿滃崟
+ if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+ {
+ rowHome.frameTable.UseClickStatu = true;
+ 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);
+ });
+ }, Language.StringByID(R.MyInternationalizationString.uSelectAdrress), true, latitude, longitude, 100);
+ };
+ }
if (i_CanDeleteResidence == true)
{
@@ -160,12 +189,12 @@
//娌℃湁璁剧疆杩囨ā寮�
if (AppResidenceMode == 0)
{
- var frame = new TopRightMenuControl(2);
+ var frame = new TopRightMenuControl(2, 2);
//鍒涘缓妤煎眰
frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatFloor), "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () =>
{
//鍒涘缓妤煎眰
- this.CreatOrEditorFloor(null, string.Empty, string.Empty);
+ this.CreatOrEditorFloor(null, null, string.Empty, string.Empty);
});
//鍒涘缓鎴块棿
frame.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uCreatRoom), "Item/RoomIcon.png", "Item/RoomIconSelected.png", () =>
@@ -183,7 +212,7 @@
else if (AppResidenceMode == 1)
{
//鍒涘缓妤煎眰
- this.CreatOrEditorFloor(null, string.Empty, string.Empty);
+ this.CreatOrEditorFloor(null, null, string.Empty, string.Empty);
}
//鏃犳ゼ灞傛ā寮�
else if (AppResidenceMode == 2)
@@ -237,7 +266,7 @@
private void InitFloorRow()
{
//鑾峰彇妤煎眰
- var dicFloor = Common.Room.CurrentRoom.GetFloorSortList();
+ var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
this.listFloorSort.Clear();
foreach (string keys in dicFloor.Keys)
{
@@ -306,7 +335,7 @@
btnChanged.ButtonClickEvent += (sender, e) =>
{
//鍒涘缓鎴栬�呯紪杈戞ゼ灞�
- this.CreatOrEditorFloor(btnFloor, keys, floorName);
+ this.CreatOrEditorFloor(frameRow, btnFloor, keys, floorName);
};
//鍒犻櫎
@@ -324,32 +353,40 @@
{
//绉婚櫎妤煎眰
Common.Config.Instance.Home.FloorDics.Remove(keys);
- if (Common.Room.CurrentRoom == null)
+ if (Common.Config.Instance.Home.CurrentFloorId == keys)
{
- Common.Room.CurrentRoom = Common.Room.Lists[0];
- }
- var listDeleteFile = new List<string>();
- for (int i = 0; i < Common.Room.Lists.Count; i++)
- {
- if (Common.Room.Lists[i].FloorId == keys)
+ //濡傛灉鍒犻櫎鐨勬槸褰撳墠妤煎眰鐨勮瘽
+ Common.Config.Instance.Home.CurrentFloorId = string.Empty;
+ foreach (string floorId in Common.Config.Instance.Home.FloorDics.Keys)
{
- listDeleteFile.Add(Common.Room.Lists[i].FileName);
+ //鎶婄涓�涓ゼ灞侷D缁欏畠
+ Common.Config.Instance.Home.CurrentFloorId = floorId;
+ break;
}
}
- //鍒犻櫎鎴块棿
- foreach (string fileName in listDeleteFile)
+ var listDeleteId = new List<string>();
+ var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
+ for (int i = 0; i < listAllRoom.Count; i++)
{
- Common.Room.CurrentRoom.Remove(fileName);
+ if (listAllRoom[i].FloorId == keys)
+ {
+ listDeleteId.Add(listAllRoom[i].Id);
+ }
}
//濡傛灉褰撳墠閫夋嫨鐨勬埧闂存槸鍒犻櫎瀵硅薄鐨勮瘽
- if (Common.Room.CurrentRoom.FloorId == keys)
+ if (HdlRoomLogic.Current.CurrentRoom.FloorId == keys)
{
- Common.Room.CurrentRoom = Common.Room.Lists[0];
+ HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
+ }
+ //鍒犻櫎鎴块棿
+ foreach (string roomId in listDeleteId)
+ {
+ HdlRoomLogic.Current.RemoveRoom(roomId);
}
Common.Config.Instance.Home.Save();
//淇濆瓨椤哄簭
listFloorSort.Remove(keys);
- Common.Room.CurrentRoom.SaveFloorSort(listFloorSort);
+ HdlRoomLogic.Current.SaveFloorSort(listFloorSort);
if (Common.Config.Instance.Home.FloorDics.Count == 0)
{
@@ -372,10 +409,10 @@
/// <param name="btnFloor"></param>
/// <param name="keys"></param>
/// <param name="floorName"></param>
- private void CreatOrEditorFloor(NormalViewControl btnFloor, string keys, string floorName)
+ private void CreatOrEditorFloor(RowLayoutControl frameRow, NormalViewControl btnFloor, string keys, string floorName)
{
//鐢熸垚涓�涓脊绐楃敾闈�
- var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
+ var dialogForm = new DialogInputControl();
//鍒涘缓妤煎眰
dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uCreatFloor));
if (keys != string.Empty)
@@ -385,8 +422,15 @@
}
//璇疯緭鍏ユゼ灞傚悕绉�
dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInputFloorName));
- dialogForm.Text = floorName;
-
+ if (Common.Config.Instance.Home.FloorDics.ContainsKey(keys) == true)
+ {
+ dialogForm.Text = Common.Config.Instance.Home.FloorDics[keys];
+ floorName = Common.Config.Instance.Home.FloorDics[keys];
+ }
+ else
+ {
+ dialogForm.Text = floorName;
+ }
//鎸変笅纭鎸夐挳
dialogForm.ComfirmClickEvent += ((textValue) =>
{
@@ -397,6 +441,8 @@
}
//鐢婚潰鍏抽棴
dialogForm.CloseDialog();
+ //杩樺師宸﹀彸鑿滃崟
+ frameRow?.HideMenu();
if (floorName != textValue)
{
//缂栬緫鎴栬�呭垱寤烘ゼ灞傚悕绉�
@@ -406,6 +452,10 @@
}
Common.Config.Instance.Home.FloorDics[keys] = textValue;
Common.Config.Instance.Home.Save();
+ if (Common.Config.Instance.Home.CurrentFloorId == string.Empty)
+ {
+ Common.Config.Instance.Home.CurrentFloorId = keys;
+ }
if (btnFloor != null)
{
btnFloor.Text = textValue;
@@ -458,7 +508,7 @@
private void InitRoomListRow()
{
//鑾峰彇妤煎眰鐨勬埧闂�
- var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(string.Empty);
+ var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty);
this.listRoomSort.Clear();
for (int i = 0; i < listRoom.Count; i++)
{
@@ -516,6 +566,8 @@
var btnEditor = frameRow.AddEditorControl();
btnEditor.ButtonClickEvent += (sender, e) =>
{
+ //鍏抽棴宸﹀彸鑿滃崟
+ frameRow.HideMenu();
var form = new EditorRoomInforForm();
form.AddForm(room);
form.FinishEditorEvent += (roomName) =>
@@ -531,17 +583,18 @@
//纭鍒犻櫎鎴块棿?
this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
{
- if (Common.Room.CurrentRoom.Id == room.Id)
+ if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id)
{
//濡傛灉鍒犻櫎鐨勬槸褰撳墠鎴块棿鐨勮瘽
- Common.Room.CurrentRoom = Common.Room.Lists[0];
+ HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom();
}
- Common.Room.CurrentRoom.Remove(room.FileName);
+ HdlRoomLogic.Current.RemoveRoom(room.Id);
//淇濆瓨椤哄簭
this.listRoomSort.Remove(room.Id);
- Common.Room.CurrentRoom.SaveRoomSort(string.Empty, this.listRoomSort);
+ HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort);
- if (Common.Room.Lists.Count <= 1)
+ var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
+ if (listAllRoom.Count <= 1)
{
//鏍规嵁鎸囧畾妯″紡,鍒濆鍖栨甯冩帶浠�
this.InitFrameTableByMode();
@@ -572,10 +625,10 @@
Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHome", true, Pra);
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
if (result == false)
{
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
return;
}
@@ -607,9 +660,10 @@
Common.Config.Instance.HomeId = myHouse.Id;
Common.Global.CreateHomeDirectory(myHouse.Id);
Common.Config.Instance.Save();
+
//鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
- await UserCenterLogic.InitUserCenterMenmoryAndThread();
- Common.Room.InitAllRoom();
+ await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
+ HdlRoomLogic.Current.InitAllRoom();
//鍒犻櫎浣忓畢
Common.House.DeleteHouseByHouseId(deleteId);
@@ -618,6 +672,67 @@
{
//鍏抽棴鐣岄潰
this.CloseForm();
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 淇濆瓨浣忓畢鍦板浘鍦板潃___________________
+
+ /// <summary>
+ /// 淇濆瓨浣忓畢鍦板潃
+ /// </summary>
+ /// <param name="btnLocation">鏄剧ず鎺т欢</param>
+ /// <param name="latitude">绾害</param>
+ /// <param name="longitude">缁忓害</param>
+ private async void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude)
+ {
+ //寮�鍚繘搴︽潯
+ this.ShowProgressBar();
+
+ var Pra = new EditorResidencePra();
+ Pra.HomeId = Common.Config.Instance.Home.Id;
+ Pra.Name = Common.Config.Instance.Home.Name;
+ Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+ Pra.Latitude = latitude;
+ Pra.Longitude = longitude;
+
+ //缂栬緫浣忓畢
+ bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", true, Pra);
+ if (flage == false)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ //璁剧疆鍏ㄩ儴缃戝叧鐨勪綇瀹呭湴鍧�
+ var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
+ foreach (var gateway in listGateway)
+ {
+ ZigBee.Device.ZbGateway realWay = null;
+ if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gateway) == false)
+ {
+ //閿欒:缃戝叧瀵硅薄涓㈠け
+ continue;
+ }
+ var result = HdlGatewayLogic.Current.SetGatewaySite(gateway, longitude, latitude, ShowErrorMode.YES);
+ if (result == false)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ }
+
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ //淇濆瓨缂撳瓨
+ Common.Config.Instance.Home.Longitude = longitude;
+ Common.Config.Instance.Home.Latitude = latitude;
+ Common.Config.Instance.Home.Save();
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ btnLocation.Text = this.GetLatitudeAndLongitudeText(longitude, latitude);
});
}
@@ -636,7 +751,7 @@
//鎷ユ湁妤煎眰
return 1;
}
- if (Common.Room.Lists.Count > 1)
+ if (HdlRoomLogic.Current.GetAllListRooms().Count > 1)
{
//鏃犳ゼ灞傛ā寮�
return 2;
@@ -674,6 +789,50 @@
return true;
}
+ /// <summary>
+ /// 鑾峰彇缁忕含搴︾殑缈昏瘧鍚嶅瓧
+ /// </summary>
+ /// <param name="Longitude">缁忓害</param>
+ /// <param name="Latitude">绾害</param>
+ /// <returns></returns>
+ private string GetLatitudeAndLongitudeText(double Longitude, double Latitude)
+ {
+ string value1 = string.Empty;
+ string value2 = string.Empty;
+ if (Longitude == 0)
+ {
+ //榛樿涓滅粡
+ value1 = "0掳00'E";
+ }
+ else if (Longitude > 0)
+ {
+ //涓滅粡
+ value1 = Math.Round(Longitude, 2).ToString().Replace(".", "掳") + "'E";
+ }
+ else if (Longitude < 0)
+ {
+ //瑗跨粡
+ value1 = Math.Round(-Longitude, 2).ToString().Replace(".", "掳") + "'W";
+ }
+
+ if (Latitude == 0)
+ {
+ //榛樿鍖楃含
+ value2 = "0掳00'N";
+ }
+ else if (Latitude > 0)
+ {
+ //鍖楃含
+ value2 = Math.Round(Latitude, 2).ToString().Replace(".", "掳") + "'N";
+ }
+ else if (Latitude < 0)
+ {
+ //鍗楃含
+ value2 = Math.Round(-Latitude, 2).ToString().Replace(".", "掳") + "'S";
+ }
+ return value1 + " " + value2;
+ }
+
#endregion
#region 鈻� 缁撴瀯浣揰____________________________
--
Gitblit v1.8.0