黄学彪
2020-12-17 6c0c799c1f5da2d215ec8d9df9b92b3d1948dc14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using HDL_ON.UI.CSS;
using Shared;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    public partial class FloorsManagementPage : FrameLayout
    {
        FrameLayout bodyView;
        /// <summary>
        /// 楼层显示区域
        /// </summary>
        VerticalScrolViewLayout floorsListView;
        /// <summary>
        /// 显示区域
        /// </summary>
        FrameLayout contentView;
        /// <summary>
        /// 楼层标题按钮
        /// </summary>
        Button btnFloorTitle;
 
        public FloorsManagementPage()
        {
            bodyView = this;
        }
 
        /// <summary>
        /// 加载界面
        /// </summary>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            Action<string> 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);
            }
        }
 
        /// <summary>
        /// 加载楼层Row
        /// </summary>
        /// <param name="floor"></param>
        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 f = new SpatialInfo("FLOOR") { roomName = floorName, parentId = DB_ResidenceData.Instance.CurrentRegion.RegionID };
                var addResult = SpatialInfo.CurrentSpatial.AddFloor(f,out f);
                if (addResult == DAL.Server.StateCode.SUCCESS)
                {
                    LoadFloorRow(f);
                }
            }
            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));
        }
 
    }
}