xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System;
using Shared.Common;
namespace Shared.Phone.Device.Room
{
 
    public class RoomManagement : FrameLayout
    {
        public  Action action;
        /// <summary>
        /// 房间管理
        /// </summary>
        public void Show()
        {
            RoomPage();
        }
        public override void RemoveFromParent()
        {
            //更新界面
            action();
            base.RemoveFromParent();
        }
        /// <summary>
        /// 房间管理界面
        /// </summary>
        void RoomPage()
        {
            RemoveAll();
            #region topview
            var topBGView = new FrameLayout()
            {
                Height = Application.GetRealHeight(CommonPage.Navigation_Height),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
            };
            AddChidren(topBGView);
            var topView = new FrameLayout()
            {
                Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
                Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
            };
            AddChidren(topView);

            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                TextID=R.MyInternationalizationString.RoomList,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
                Gravity = Gravity.CenterHorizontal
            };
            topView.AddChidren(title);
 
            var back = new Device.CommonForm.BackButton() { };
            topView.AddChidren(back);
 
            back.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
 
            var addRoomItemBtn = new Device.CommonForm.SelectedStatuButton()
            {
                Width = Application.GetMinRealAverage(100),
                Height = Application.GetMinRealAverage(100),
                UnSelectedImagePath = "Item/Add.png",
                SelectedImagePath="Item/AddSelected.png",
                X = Application.GetRealWidth(1080 - 150),
                Gravity = Gravity.CenterVertical
            };
            topView.AddChidren(addRoomItemBtn);
 
            //Action action = RoomPage;
 
            addRoomItemBtn.MouseUpEventHandler += (sender, e) =>
            {
                //AddOrUpdateRoom(action);
                var addRoom = new AddRoom();
                Shared.Phone.UserView.HomePage.Instance.AddChidren(addRoom);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                addRoom.action = () =>
                {
                    Show();
                };
                AddRoom.OldBackgroundImagePath = string.Empty;
                addRoom.Show("");
            };
            #endregion
 
            var middleHomePage = new FrameLayout()
            {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
                Y = topView.Bottom,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            this.AddChidren(middleHomePage);
 
            var RoomBodyView = new VerticalScrolViewLayout()
            {
                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            middleHomePage.AddChidren(RoomBodyView);
 
 
            foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList)
            {
                var room = Shared.Common.Room.GetRoomByFilePath(roomFilePath);
                if (room == null)
                {
                    continue;
                }
 
                var roomFL = new FrameLayout()
                {
                    Height = Application.GetRealHeight(570),
                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                    Gravity = Gravity.CenterHorizontal,
                    Radius = CommonPage.BigFormRadius,
                };
                RoomBodyView.AddChidren(roomFL);
 
                var roomRowView = new RowLayout()
                {
                    Y = Application.GetRealHeight(20),
                    Height = Application.GetMinRealAverage(550),
                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
                    BackgroundColor =ZigbeeColor.Current.GXCBackgroundColor,
                    LineColor= ZigbeeColor.Current.GXCBackgroundColor,
                    Radius = CommonPage.BigFormRadius,
                    Gravity = Gravity.CenterHorizontal
                };
                roomFL.AddChidren(roomRowView);
 
                var backGroundBtn = new Button()
                {
                    UnSelectedImagePath = room.BackgroundImage,
                    Radius = CommonPage.BigFormRadius,
                    Height = Application.GetMinRealAverage(550),
                    Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
                };
                roomRowView.AddChidren(backGroundBtn);
 
                var hardBlackBG = new FrameLayout()
                {
                    Radius = CommonPage.BigFormRadius,
                    BackgroundColor = ZigbeeColor.Current.GXCBlack70Color
                };
                roomRowView.AddChidren(hardBlackBG);
 
                var btnRoomName = new Button()
                {
                    Width = Application.GetRealWidth(500),
                    Height=Application.GetRealHeight(200),
                    Text = room.Name,
                    TextAlignment = TextAlignment.Center,
                    TextSize=25,
                    TextColor=ZigbeeColor.Current.GXCTextWhiteColor,
                    Gravity=Gravity.Center
                };
                roomRowView.AddChidren(btnRoomName);
 
                var btnEditRoom = new Device.CommonForm.SelectedStatuButton()
                {
                    X = roomRowView.Width- Application.GetRealWidth(100+30),
                    Y=backGroundBtn.Y,
                    Width = Application.GetMinRealAverage(110),
                    Height=Application.GetMinRealAverage(110),
                    UnSelectedImagePath = "Room/More.png",
                    SelectedImagePath="Room/MoreSelected.png",
                };
                roomRowView.AddChidren(btnEditRoom);
 
                var delBtn = new Shared.Phone.Device.CommonForm.RowLayoutDeleteButton();
                //第一个是房间喜爱,不允许滑动删除  分享过来的也不允许删除
                if (!room.IsLove || !room.IsSharedRoom){
                    roomRowView.AddRightView(delBtn);
                }
                //删除住宅
                delBtn.MouseUpEventHandler += (sender, e) =>
                {
                    var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ConfirmDeleteThisRoom), Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
                    alert.Show();
                    alert.ResultEventHandler += (send, ee) =>
                    {
                        if(ee)
                        {
                            Shared.Common.Room.CurrentRoom.Remove(roomFilePath);
                            Show();
                        }
                    };
                };
 
                btnEditRoom.MouseUpEventHandler += (sender, e) =>
                {
                    //AddOrUpdateRoom(action, roomFilePath);
                    var addRoom = new AddRoom();
                    Shared.Phone.UserView.HomePage.Instance.AddChidren(addRoom);
                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                    addRoom.action = () =>
                    {
                        Show();
                    };
                    AddRoom.OldBackgroundImagePath = string.Empty;
                    addRoom.Show(roomFilePath);
                };
 
                roomRowView.MouseUpEventHandler += (sender, e) =>
                {
                    //var userRoom = new RoomAddDevice();
                    //this.AddChidren(userRoom);
                    //userRoom.Show(roomFilePath);
                };
 
            }
        }
    }
}