黄学彪
2019-11-25 5727cf0b9b54da0a191dd1e23cb5abf21320fbff
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
using System;
using Shared.Common;
namespace Shared.Phone.Device.Room
{
    /// <summary>
    /// Add devie detail from add function.
    /// </summary>
    public class AddDevieDetailFromAddFunction:FrameLayout
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Shared.Phone.Device.Room.AddDevieDetailFromAddFunction"/> class.
        /// </summary>
        public AddDevieDetailFromAddFunction()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            Tag = "categoryAddScene";
        }
        /// <summary>
        /// Removes from parent.
        /// </summary>
        public override void RemoveFromParent()
        {
            AddRoomContent.instance?.RefreshBodyView();
            base.RemoveFromParent();
        }
        /// <summary>
        /// Show the specified device and room.
        /// </summary>
        /// <param name="device">Device.</param>
        /// <param name="room">Room.</param>
        public void Show(DeviceUI device, Shared.Common.Room room)
        {
 
            #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 back = new Device.CommonForm.BackButton() { };
            topView.AddChidren(back);
            back.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
 
            if (device == null || device.CommonDevice == null)
            {
                return;
            }
 
            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                Text=DeviceUI.GetDeviceTypeName(device.CommonDevice.Type),
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(1080 - 500),
                Gravity = Gravity.CenterHorizontal
            };
            topView.AddChidren(title);
            #endregion
 
            #region midFL
 
            var midFL = new FrameLayout()
            {
                Height = Application.GetRealHeight(1920 - 220),
                Y = topView.Bottom,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            this.AddChidren(midFL);
 
            var deviceIMG = new Button()
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetMinRealAverage(320),
                Height = Application.GetMinRealAverage(320),
                UnSelectedImagePath = device.IconPath,
                SelectedImagePath = device.IconPath,
                Gravity = Gravity.CenterHorizontal
            };
            midFL.AddChidren(deviceIMG);
 
            var deviceTypeName = new Button()
            {
                Y = deviceIMG.Bottom,
                Width = Application.GetRealWidth(900),
                Height = Application.GetRealHeight(100),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text=DeviceUI.GetDeviceTypeName(device.CommonDevice.Type),
                Gravity = Gravity.CenterHorizontal
            };
            midFL.AddChidren(deviceTypeName);
 
 
            var deviceNameFL = new FrameLayout()
            {
                Y = deviceTypeName.Bottom,
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(deviceNameFL);
            var deviceNameTip = new Button()
            {
                X=Application.GetRealWidth(50),
                Height = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(500),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                TextID = R.MyInternationalizationString.DeviceName,
            };
            deviceNameFL.AddChidren(deviceNameTip);
            var deviceName = new Button()
            {
                X = Application.GetRealWidth(50),
                Y =deviceNameTip.Bottom,
                Height = Application.GetRealHeight(100)-1,
                Width = Application.GetRealWidth(900),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text=device.CommonDevice.DeviceEpointName,
            };
            deviceNameFL.AddChidren(deviceName);
            var deviceNameLine = new Button()
            {
                Y = deviceName.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            deviceNameFL.AddChidren(deviceNameLine);
 
            var zoneFL = new FrameLayout()
            {
                Y = deviceNameFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(zoneFL);
            var zoneTip = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(500),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                TextID = R.MyInternationalizationString.BelongZone,
            };
            zoneFL.AddChidren(zoneTip);
            var zone = new Button()
            {
                X = Application.GetRealWidth(50),
                Y = deviceNameTip.Bottom,
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(900),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text = room.Name,
            };
            zoneFL.AddChidren(zone);
            //var zoneRight = new Button()
            //{
            //    X = Application.GetRealWidth(1080 - 150),
            //    Width = Application.GetMinRealAverage(110),
            //    Height = Application.GetMinRealAverage(110),
            //    UnSelectedImagePath = "Item/Next.png",
            //    Gravity = Gravity.CenterVertical
            //};
            //zoneFL.AddChidren(zoneRight);
            var zoneLine = new Button()
            {
                Y = zone.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            zoneFL.AddChidren(zoneLine);
 
            var modelFL = new FrameLayout()
            {
                Y = zoneFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(modelFL);
            var modelTip = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                TextID = R.MyInternationalizationString.BelongModel,
            };
            modelFL.AddChidren(modelTip);
            var model = new Button()
            {
                X = Application.GetRealWidth(50),
                Y = deviceNameTip.Bottom,
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(900),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text = device.CommonDevice.DeviceName
            };
            modelFL.AddChidren(model);
 
            var modelLine = new Button()
            {
                Y = model.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            modelFL.AddChidren(modelLine);
 
            var sharedFL = new FrameLayout()
            {
                Y = modelFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
            //midFL.AddChidren(sharedFL);
 
            var sharedBtn = new Button()
            {
                X = Application.GetRealWidth(50),
                Y = Application.GetRealHeight(70),
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(500),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextID=R.MyInternationalizationString.Shared
            };
            sharedFL.AddChidren(sharedBtn);
 
            var sharedRight = new Button()
            {
                X = Application.GetRealWidth(1080 - 150),
                Width = Application.GetMinRealAverage(110),
                Height = Application.GetMinRealAverage(110),
                UnSelectedImagePath = "Item/Next.png",
                Gravity = Gravity.CenterVertical
            };
            sharedFL.AddChidren(sharedRight);
 
            var sharedNum = new Button()
            {
                X = Application.GetRealWidth(1080 - 150 - 110),
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                TextAlignment = TextAlignment.CenterRight,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                Text ="1人",
                Gravity=Gravity.CenterVertical
            };
            sharedFL.AddChidren(sharedNum);
 
            var sharedLine = new Button()
            {
                Y = sharedBtn.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            sharedFL.AddChidren(sharedLine);
 
            var confirmBtn = new Device.CommonForm.CompleteButton(1,2,3)
            {
                TextID = R.MyInternationalizationString.ConfirmAdd,
            };
            AddChidren(confirmBtn);
 
            confirmBtn.MouseUpEventHandler += (sender, e) =>
            {
                room.AddDevice(device.FileName);
                var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.AddDeviceSuccess), Language.StringByID(R.MyInternationalizationString.Close));
                alert.Show();
                alert.ResultEventHandler += (alertSend, alertE) =>
                {
                    //回到功能、场景界面
                    UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
                };
            };
            #endregion
        }
        }
    }