From 611786df5108dca0bdcff03834cc285cba4b8e61 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 13 十月 2020 16:48:43 +0800 Subject: [PATCH] 2020-10-13-1 --- HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/FloorsManagementPage.cs | 81 ++++++++++++++++++++++++---------------- 1 files changed, 48 insertions(+), 33 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/FloorsManagementPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/FloorsManagementPage.cs index 9d63a67..9b3fe94 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/FloorsManagementPage.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/FloorsManagementPage.cs @@ -34,17 +34,25 @@ /// <summary> /// 鏍囬鏍忎慨鏀规ゼ灞備箣鍚庣殑鍥炶皟浜嬩欢 /// </summary> - Action<string,string> topCallBack; + Action<string,string> refreshFloorList; /// <summary> /// 鍚庨��鍥炶皟浜嬩欢 /// </summary> Action backAction; + /// <summary> + /// 鏈�鍚庝竴娆$偣鍑荤殑鎸夐挳 + /// </summary> + Button lastButton; public FloorsManagementPage() { bodyView = this; } + /// <summary> + /// 浠庢埧闂磋繘鍏ユゼ灞備慨鏀圭晫闈紝闇�瑕佸洖璋冧簨浠舵洿鏂版埧闂寸殑妤煎眰淇℃伅 + /// </summary> + /// <param name="action"></param> public FloorsManagementPage(Action action) { bodyView = this; @@ -57,11 +65,10 @@ { bodyView.RemoveAll(); bodyView.BackgroundColor = CSS_Color.BackgroundColor; - topCallBack = (type,floor) => { - ChangeFloorsListView(type, floor); + refreshFloorList = (type,floorName) => { + RefreshFloorsListView(type, floorName); }; - new TopViewDiv(bodyView, Language.StringByID(StringId.FloorsManagement)).LoadTopView("floors",topCallBack,backAction); - //new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.FloorsManagement),"floors",topCallBcak); + new TopViewDiv(bodyView, Language.StringByID(StringId.FloorsManagement)).LoadTopView("floors",refreshFloorList,backAction); int count = DB_ResidenceData.residenceData.floors.Count > 8 ? 8 : DB_ResidenceData.residenceData.floors.Count; var contentViewHeight = (count + 1) * Application.GetRealHeight(50); @@ -89,6 +96,12 @@ TextColor = CSS_Color.FirstLevelTitleColor, }; contentView.AddChidren(btnFloorTitle); + contentView.AddChidren(new Button() + { + Height = Application.GetRealHeight(1), + Y = Application.GetRealHeight(49), + BackgroundColor = CSS_Color.DividingLineColor, + }); floorsListView = new VerticalScrolViewLayout() { @@ -107,20 +120,13 @@ /// 鍔犺浇妤煎眰Row /// </summary> /// <param name="floor"></param> - void LoadFloorRow(string floor) + void LoadFloorRow(Floor floor) { - floorsListView.AddChidren( - new Button() - { - Height = Application.GetRealHeight(1), - BackgroundColor = CSS_Color.DividingLineColor, - Tag = floor + "line" - }); - var row = new RowLayout() { Height = Application.GetRealHeight(50), - Tag = floor + Tag = floor.name, + LineColor = CSS_Color.DividingLineColor, }; floorsListView.AddChidren(row); @@ -131,40 +137,44 @@ TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.TextualColor, SelectedTextColor = CSS_Color.MainColor, - Text = floor, + Text = floor.name, + Tag = floor.sid, }; row.AddChidren(btnFloor); if (room == null) { - LoadEvent_FloorNamgeChange(floor, btnFloor); - var btnDel = new Button() { TextID = StringId.Del, BackgroundColor = CSS_Color.WarningColor, TextColor = CSS_Color.MainBackgroundColor, - Tag = floor + Tag = floor.name }; row.AddRightView(btnDel); LoadEvent_DelFloor(btnDel); + LoadEvent_FloorNamgeChange(btnFloor,btnDel,row,floor); } else { LoadEvent_FloorChoose(btnFloor); + if (room.floorId == floor.sid) + { + lastButton = btnFloor; + btnFloor.IsSelected = true; + } } } - void ChangeFloorsListView(string changeType,string floorName) + void RefreshFloorsListView(string changeType,string floorName) { - int count = DB_ResidenceData.residenceData.floors.Count > 10 ? 10 : DB_ResidenceData.residenceData.floors.Count; - floorsListView.Height = Application.GetRealHeight(50 * count); - contentView.Height = Application.GetRealHeight(50 * (count + 1)); switch (changeType) { case "add": try { - LoadFloorRow(floorName); + var f = new Floor() { sid = Guid.NewGuid().ToString(), name = floorName }; + DB_ResidenceData.residenceData.floors.Add(f); + LoadFloorRow(f); } catch (Exception ex) { @@ -190,16 +200,16 @@ } break; case "del": + //璇ユゼ灞傚垹闄や箣鍚庯紝缁戝畾璇ユゼ灞傜殑鎴块棿瑕侀噸缃粦瀹氱殑妤煎眰 + foreach (var r in DB_ResidenceData.residenceData.rooms) + { + if (r.floorId == DB_ResidenceData.residenceData.floors.Find((obj) => obj.name == floorName).sid) + { + r.floorId = ""; + } + } for (int i = 0; i < floorsListView.ChildrenCount; i++) { - //璇ユゼ灞傚垹闄や箣鍚庯紝缁戝畾璇ユゼ灞傜殑鎴块棿瑕侀噸缃粦瀹氱殑妤煎眰 - foreach (var r in DB_ResidenceData.residenceData.rooms) - { - if (r.floorIndex == DB_ResidenceData.residenceData.floors.IndexOf(floorName)) - { - r.floorIndex = -1; - } - } if (floorsListView.GetChildren(i).GetType() == typeof(Button)) { Button btn = floorsListView.GetChildren(i) as Button; @@ -215,14 +225,19 @@ RowLayout row = floorsListView.GetChildren(i) as RowLayout; if (row.Tag == null) continue; - if (row.Tag.ToString() == floorName ) + if (row.Tag.ToString() == floorName) { row.RemoveFromParent(); } } + DB_ResidenceData.residenceData.floors.Remove(DB_ResidenceData.residenceData.floors.Find((obj) => obj.name == floorName)); } break; } + DB_ResidenceData.residenceData.SaveResidenceData(); + int count = DB_ResidenceData.residenceData.floors.Count > 10 ? 10 : DB_ResidenceData.residenceData.floors.Count; + floorsListView.Height = Application.GetRealHeight(50 * count); + contentView.Height = Application.GetRealHeight(50 * (count + 1)); } /// <summary> -- Gitblit v1.8.0