gxc
2019-10-28 1c4904d77f484c075080942d87785481b52b6fb2
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
using System;
using System.Collections.Generic;
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.R;
using ZigBee.Device;
 
namespace Shared.Phone.Device.Logic
{
    public class DeviceTarget : FrameLayout
    {
 
        public DeviceTarget ()
        {
            Tag = "Logic";
        }
        public void Show ()
        {
            
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
 
            var topFrameLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(140),
                Y = Application.GetRealHeight(80),
            };
            AddChidren(topFrameLayout);
 
 
            var titleName = new Button {
                TextID = MyInternationalizationString.addaction,
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(150),
            };
            topFrameLayout.AddChidren (titleName);
 
            var back = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                X = Application.GetRealWidth (20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent ();
            };
 
          
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 220);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            this.AddChidren(middle);
 
            #region ----- 设备------    
            var deviceRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
            };
            middle.AddChidren (deviceRowLayout);
 
            var device = new Button {
                Width = Application.GetRealWidth (400),
                TextID = MyInternationalizationString.device,
                //Text = "设备",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            deviceRowLayout.AddChidren (device);
 
            var btndeviceback = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth (1080-140),//550
                Gravity = Gravity.CenterVertical,
            };
            deviceRowLayout.AddChidren (btndeviceback);
 
            EventHandler<MouseEventArgs> deviceclick = (sender, e) => {
                Common.Logic.LogicDviceList.Clear();
                if (Common.Logic.LogicDviceList.Count == 0)
                {
                    Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
                }
                var logicDevicePage = new LogicDevicePage();
                UserView.HomePage.Instance.AddChidren(logicDevicePage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicDevicePage.Show();
 
            };
             deviceRowLayout.MouseUpEventHandler += deviceclick;
             device.MouseUpEventHandler += deviceclick;
             btndeviceback.MouseUpEventHandler += deviceclick;
#endregion
 
            #region ----- 场景------        
            var sceneRowLayout = new RowLayout {
                Height = Application.GetRealHeight (180),
                //BackgroundColor = 0xff323232,
                Y=deviceRowLayout.Bottom,
            };
            middle.AddChidren (sceneRowLayout);
 
            var scene = new Button {
                Width = Application.GetRealWidth (400),
                TextID = MyInternationalizationString.scene,
                //Text = "场景",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            sceneRowLayout.AddChidren (scene);
 
            var btnsceneback = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth (1080-140),//550
                Gravity = Gravity.CenterVertical,
            };
            sceneRowLayout.AddChidren (btnsceneback);
 
            EventHandler<MouseEventArgs> sceneclick = (sender, e) => {
                CommonPage.Loading.Start ();
                System.Threading.Tasks.Task.Run (() => {
                    Application.RunOnMainThread (() => {
                        CommonPage.Loading.Hide ();
                        var addScenePage = new AddScenePage ();
                        UserView.HomePage.Instance.AddChidren (addScenePage);
                        UserView.HomePage.Instance.PageIndex += 1;
                        addScenePage.Show ();
 
                    });
                });
            };
             sceneRowLayout.MouseUpEventHandler += sceneclick;
             scene.MouseUpEventHandler += sceneclick;
             btnsceneback.MouseUpEventHandler += sceneclick;
#endregion
 
            #region ----- 安防模式------        
            ///安防模式
            var securityRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y = sceneRowLayout.Bottom,
            };
            middle.AddChidren(securityRowLayout);
 
            var security = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.securitymode,
                //Text = "安防模式",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            securityRowLayout.AddChidren(security);
 
            var btnsecurityback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                Gravity = Gravity.CenterVertical,
            };
            securityRowLayout.AddChidren(btnsecurityback);
 
            EventHandler<MouseEventArgs> securityclick = (sender, e) => {
                var securityMode = new SecurityMode();
                UserView.HomePage.Instance.AddChidren(securityMode);
                UserView.HomePage.Instance.PageIndex += 1;
                securityMode.Show();
            };
 
            securityRowLayout.MouseUpEventHandler += securityclick;
            security.MouseUpEventHandler += securityclick;
            btnsecurityback.MouseUpEventHandler += securityclick;
            #endregion
 
            #region ----- 已有自动化------      
 
            ///已有自动化
            var existenceRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y = securityRowLayout.Bottom,
            };
            //middle.AddChidren(existenceRowLayout);
 
            var existence = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.Alreadyautomated,
                //Text = "已有自动化",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            existenceRowLayout.AddChidren(existence);
 
            var btnexistenceback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                Gravity = Gravity.CenterVertical,
            };
            existenceRowLayout.AddChidren(btnexistenceback);
 
            EventHandler<MouseEventArgs> existenceclick = (sender, e) => {
                var logicListPage = new LogicListPage();
                UserView.HomePage.Instance.AddChidren(logicListPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicListPage.Show();
            };
 
            existenceRowLayout.MouseUpEventHandler += existenceclick;
            existence.MouseUpEventHandler += existenceclick;
            btnexistenceback.MouseUpEventHandler += existenceclick;
            #endregion
 
            #region ----- 延时------        
            var delayedRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y=securityRowLayout.Bottom,
            };
           //middle.AddChidren(delayedRowLayout);
 
            var delayed = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.delayed,
                //Text = "延时",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            delayedRowLayout.AddChidren(delayed);
 
            var btndelayedback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                Gravity = Gravity.CenterVertical,
            };
            delayedRowLayout.AddChidren(btndelayedback);
 
            EventHandler<MouseEventArgs> delayedclick = (sender, e) =>
            {
                //var delayTime = new DelayTime();
                //UserView.HomePage.Instance.AddChidren(delayTime);
                //UserView.HomePage.Instance.PageIndex += 1;
                //delayTime.Show();
                DelayTimeView();
            };
 
            delayedRowLayout.MouseUpEventHandler += delayedclick;
            delayed.MouseUpEventHandler += delayedclick;
            btndelayedback.MouseUpEventHandler += delayedclick;
#endregion
        }
 
        public static  void DelayTimeView(Dictionary<string, object> delayactionsInfo=null)
        {
            var listValues = new List<string>();
            for (int i = 0; i < 60; i++)
            {
                listValues.Add(i.ToString() + " " + Language.StringByID(MyInternationalizationString.second));
            }
            var list = new List<KeyValuePair<string, string[]>> { };
            for (int i = 0; i <= 60; i++)
            {
                list.Add(new KeyValuePair<string, string[]>(i.ToString() + " " + Language.StringByID(MyInternationalizationString.minute), listValues.ToArray()));
            }
 
            /*
            PickerView.Show(list, (obj) =>
            {
                var minute = obj.Split(',')[0].Split(' ')[0];
                var second = obj.Split(',')[1].Split(' ')[0];
                int value = int.Parse(minute) * 60 + int.Parse(second);
                if (value == 0)
                {
                    var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                                   "时间不能为0",
                                                  Language.StringByID(MyInternationalizationString.complete));
                    alert.Show();
                    return;
                }
                if (delayactionsInfo == null)
                {
                    Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                    actionsInfo.Add("LinkType", 10);
                    actionsInfo.Add("DelayTime", value);
                    Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
                }
                else
                {
                    if (delayactionsInfo.ContainsKey("DelayTime"))
                    {
                        delayactionsInfo.Remove("DelayTime");
                    }
                    delayactionsInfo.Add("DelayTime", value);
                }
                var logicCommunalPage = new LogicCommunalPage { };
                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
            }, Language.StringByID(MyInternationalizationString.complete), "");
            */
        }
    }
}