HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-10 4f92fe4e4397b05bc97d17e8ad02818a689acdb8
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
using System;
using System.Collections.Generic;
using System.Globalization;
using Shared.Common;
 
namespace Shared.Phone.Device.CommonForm
{
    public class DeviceDetailInfo : FrameLayout
    {
        #region ◆ 变量____________________________
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        /// <summary>
        /// 所属区域
        /// </summary>
        private string roomName;
        /// <summary>
        /// action
        /// </summary>
        public Action action;
 
        #endregion
 
        #region ◆ 移除____________________________
        /// <summary>
        /// RemoveFromParent
        /// </summary>
        public override void RemoveFromParent()
        {
            action();
            base.RemoveFromParent();
        }
        #endregion
 
        #region ◆ 构造方法_________________________
        /// <summary>
        /// DeviceDetailInfo
        /// </summary>
        public DeviceDetailInfo()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
        }
 
        #endregion
 
        #region ◆ 显示界面_________________________
        /// <summary>
        /// Show
        /// </summary>
        /// <param name="device"></param>
        /// <param name="room"></param>
        public void Show(DeviceUI device, Common.Room room)
        {
            Init(device);
 
            AddTop();
 
            AddBodyView(device);
 
        }
 
        #endregion
 
        #region Add____________________________________
 
        /// <summary>
        /// AddTop
        /// </summary>
        public void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.FunctionSetting);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
 
        }
        /// <summary>
        /// AddBodyView
        /// </summary>
        public void AddBodyView(DeviceUI device)
        {
            bodyFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(184),
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
            };
            AddChidren(bodyFrameLayout);
 
            var deviceBG = new Button()
            {
                Y = Application.GetRealHeight(118),
                Width = Application.GetMinRealAverage(207),
                Height = Application.GetMinRealAverage(207),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius=(uint)Application.GetMinRealAverage(207)
            };
            bodyFrameLayout.AddChidren(deviceBG);
 
            var deviceBG2 = new Button()
            {
                Y = Application.GetRealHeight(130),
                Width = Application.GetMinRealAverage(184),
                Height = Application.GetMinRealAverage(184),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
                Radius = (uint)Application.GetMinRealAverage(184)
            };
            bodyFrameLayout.AddChidren(deviceBG2);
 
            var deviceIMG = new Button()
            {
                Y = Application.GetRealHeight(161),
                Width = Application.GetMinRealAverage(124),
                Height = Application.GetMinRealAverage(124),
                UnSelectedImagePath = device.IconPath,
                Gravity = Gravity.CenterHorizontal
            };
            bodyFrameLayout.AddChidren(deviceIMG);
 
            var deviceTypeName = new Button()
            {
                Y = Application.GetRealHeight(360),
                Width = Application.GetRealWidth(900),
                Height = Application.GetRealHeight(80),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text = DeviceUI.GetDeviceTypeName(device.CommonDevice.Type),
                Gravity = Gravity.CenterHorizontal
            };
            bodyFrameLayout.AddChidren(deviceTypeName);
 
 
            var infoFL = new FrameLayout
            {
                Y = Application.GetRealHeight(540),
                Height = Application.GetRealHeight(1195),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
            };
            bodyFrameLayout.AddChidren(infoFL);
 
            var tipBtn = new Button
            {
                X = Application.GetRealWidth(CommonFormResouce.X_Left),
                Y = Application.GetRealHeight(81),
                Width = Application.GetRealWidth(500),
                Height = Application.GetRealHeight(60),
                TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 15,
                TextID = R.MyInternationalizationString.EditInfo
            };
            infoFL.AddChidren(tipBtn);
 
            var nameRow = new DeviceInfoEditRow(170);
            nameRow.Init();
            nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : ");
            nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceEpointName);
            infoFL.AddChidren(nameRow);
 
            var zoneRow = new DeviceInfoRow(308);
            zoneRow.Init();
            zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)} : ");
            zoneRow.SetTitle(roomName);
            infoFL.AddChidren(zoneRow);
 
            var modelRow = new DeviceInfoRow(446);
            modelRow.Init();
            modelRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongModel)} : ");
            modelRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName);
            infoFL.AddChidren(modelRow);
 
            var sharedRow = new DeviceInfoRow(585);
            sharedRow.Init();
            sharedRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.Share)} : ");
            sharedRow.SetTitle("2人");
            infoFL.AddChidren(sharedRow);
 
 
            var confirmBtn = new CommonForm.CompleteButton(962, 907, 127);
            confirmBtn.SetTitle(R.MyInternationalizationString.Confrim);
            infoFL.AddChidren(confirmBtn);
 
            #region event
            EventHandler<MouseEventArgs> selectZoneEvent = (sender, e) =>
            {
                //UserCenter.SelectRoomForm selectedRoom = new UserCenter.SelectRoomForm();
                //selectedRoom.AddForm(selectedRoom, roomNameList);
                //selectedRoom.ActionSelectRoom += ((rList) =>
                //{
                //    roomNameList = rList;
                //    zone.Text = Shared.Common.Room.CurrentRoom.GetRoomName(roomNameList);
                //});
            };
            //zoneRight.MouseUpEventHandler += selectZoneEvent;
            //zoneFL.MouseUpEventHandler += selectZoneEvent;
            //zone.MouseUpEventHandler += selectZoneEvent;
 
            EventHandler<MouseEventArgs> selectDeviceIconEvent = (sender, e) =>
            {
                var localPic = new DeviceIconSelectedIMGByLocal();
                UserView.HomePage.Instance.AddChidren(localPic);
                UserView.HomePage.Instance.PageIndex += 1;
                localPic.Show();
                localPic.action = (unSelectedImagePath, selectedImagePath) =>
                {
                    deviceIMG.UnSelectedImagePath = unSelectedImagePath;
                    deviceIMG.SelectedImagePath = selectedImagePath;
                };
            };
            deviceIMG.MouseUpEventHandler += selectDeviceIconEvent;
 
            confirmBtn.MouseUpEventHandler += async (sender, e) =>
            {
                //if (device.CommonDevice == null)
                //{
                //    CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
                //    return;
                //}
                //var result = await Shared.Common.LocalDevice.Current.ReName(device.CommonDevice, deviceName.Text.Trim());
                //if (result)
                //{
                //    var alertSuccess = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.Success), Language.StringByID(R.MyInternationalizationString.Confrim));
                //    alertSuccess.Show();
                //    alertSuccess.ResultEventHandler += (senderSuccess, eSuccess) =>
                //    {
                //        //改图片
                //        device.IconPath = deviceIMG.UnSelectedImagePath;
                //        device.IsCustomizeImage = true;
                //        device.ReSave();
                //        //改房间
                //        Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, roomNameList);
                //        RemoveFromParent();
                //    };
                //}
                //else
                //{
                //    return;
                //    //CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
                //}
            };
 
            #endregion
        }
 
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="device"></param>
        public void Init(DeviceUI device)
        {
            roomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device.CommonDevice);
        }
        #endregion
    }
}