using System; using HDL_ON.UI.CSS; using Shared; using HDL_ON.Entity; namespace HDL_ON.UI { public partial class FloorsManagementPage : FrameLayout { FrameLayout bodyView; /// /// 楼层显示区域 /// VerticalScrolViewLayout floorsListView; /// /// 显示区域 /// FrameLayout contentView; /// /// 楼层标题按钮 /// Button btnFloorTitle; public FloorsManagementPage() { bodyView = this; } /// /// 加载界面 /// public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; Action addFloorAction = (floorName) => { RefreshFloorsListView(floorName); }; new TopViewDiv(bodyView, Language.StringByID(StringId.FloorsManagement)).LoadTopView_FloorTopView(addFloorAction, null); int count = SpatialInfo.CurrentSpatial.FloorList.Count > 8 ? 8 : SpatialInfo.CurrentSpatial.FloorList.Count; var contentViewHeight = (count + 1) * Application.GetRealHeight(50); contentView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(80), Width = Application.GetRealWidth(343), Height = contentViewHeight, Radius = (uint)Application.GetRealHeight(5), BorderColor = 0x00FFFFFF, BorderWidth = 0, BackgroundColor = CSS_Color.MainBackgroundColor, }; bodyView.AddChidren(contentView); btnFloorTitle = new Button() { Height = Application.GetRealHeight(50), TextID = StringId.Floors, TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.SubheadingFontSize, 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() { Y = btnFloorTitle.Bottom, Height = count * Application.GetRealHeight(50), }; contentView.AddChidren(floorsListView); foreach (var floor in SpatialInfo.CurrentSpatial.FloorList) { LoadFloorRow(floor); } } /// /// 加载楼层Row /// /// void LoadFloorRow(SpatialInfo floor) { var row = new RowLayout() { Height = Application.GetRealHeight(50), Tag = floor.roomId, LineColor = CSS_Color.DividingLineColor, }; floorsListView.AddChidren(row); var btnFloor = new Button() { Height = Application.GetRealHeight(50), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.TextualColor, SelectedTextColor = CSS_Color.MainColor, Text = floor.roomName, Tag = floor.roomId, }; row.AddChidren(btnFloor); var btnDel = new Button() { TextID = StringId.Del, BackgroundColor = CSS_Color.WarningColor, TextColor = CSS_Color.MainBackgroundColor, Tag = floor.roomId }; row.AddRightView(btnDel); LoadEvent_DelFloor(btnDel); LoadEvent_FloorNamgeChange(btnFloor, floor); } void RefreshFloorsListView(string floorName) { try { var waitPage = new Loading(); MainPage.BaseView.AddChidren(waitPage); waitPage.Start(Language.StringByID(StringId.PleaseWait)); new System.Threading.Thread(() => { try { var f = new SpatialInfo("FLOOR") { roomName = floorName, parentId = DB_ResidenceData.Instance.CurrentRegion.id }; var addResult = SpatialInfo.CurrentSpatial.AddFloor(f, out f); if (addResult == DAL.Server.StateCode.SUCCESS) { Application.RunOnMainThread(() => { LoadFloorRow(f); int count2 = SpatialInfo.CurrentSpatial.FloorList.Count > 8 ? 8 : SpatialInfo.CurrentSpatial.FloorList.Count; var contentViewHeight = (count2 + 1) * Application.GetRealHeight(50); contentView.Height = contentViewHeight; floorsListView.Height = count2 * Application.GetRealHeight(50); }); } } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); waitPage.RemoveFromParent(); }); } }) { IsBackground = true }.Start(); } catch (Exception ex) { MainPage.Log("add floor eroor : " + ex.Message); } int count = SpatialInfo.CurrentSpatial.FloorList.Count > 10 ? 10 : SpatialInfo.CurrentSpatial.FloorList.Count; floorsListView.Height = Application.GetRealHeight(50 * count); contentView.Height = Application.GetRealHeight(50 * (count + 1)); } } }