wei
2021-08-21 557c8c4f75aafc97533721766272410042440d34
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
using System;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public class ArmCenterPage : FrameLayout
    {
        /// <summary>
        /// 主窗体
        /// </summary>
        FrameLayout bodyView;
        /// <summary>
        /// 自定义布防区域
        /// </summary>
        HorizontalScrolViewLayout customDeploymentView;
 
        public ArmCenterPage()
        {
            bodyView = this;
        }
 
        public void LoadPage()
        {
            Action skipAction = () => {
 
            };
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.SecurityCenter)).LoadTopView_ArmCenter(skipAction);
 
            VerticalScrolViewLayout contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                ScrollEnabled = false,
            };
            bodyView.AddChidren(contentView);
 
            contentView.AddChidren(new Button()
            {
                Height =Application.GetRealWidth(32),
            });
 
            //安防状态背景图
            Button btnArmTipIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(198),
                Height = Application.GetRealWidth(198),
                UnSelectedImagePath = "FunctionIcon/ArmCenter/NoDefenseBigIcon.png",
                SelectedImagePath = "FunctionIcon/ArmCenter/InDefenseBigIcon.png",
            };
            contentView.AddChidren(btnArmTipIcon);
 
            contentView.AddChidren(new Button()
            {
                Height = Application.GetRealWidth(16),
            });
 
 
            #region 撤防区域
            var disarmView = new FrameLayout()
            {
                Height = 0,
            };
            contentView.AddChidren(disarmView);
 
            var btnDisarm = new Button()
            {
                Width = Application.GetRealWidth(120),
                Height = Application.GetRealHeight(44),
                BackgroundColor = CSS_Color.WarningColor,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainBackgroundColor,
                Text = "撤防"
            };
            disarmView.AddChidren(btnDisarm);
            btnDisarm.MouseUpEventHandler = (sender, e) => {
                if (SecurityCenter.Security.CurrentDefenseMode != null)
                {
                    Control.Ins.ControlSecurity(SecurityCenter.Security.CurrentDefenseMode, "disable");
                }
            };
 
            #endregion
 
            #region 自定义布防
            //自定义布防标题
            Button btnCustomDeploymentTitle = new Button()
            {
                X = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(54),
                TextAlignment = TextAlignment.CenterLeft,
                IsBold = true,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.CustomDeployment,
            };
            contentView.AddChidren(btnCustomDeploymentTitle);
 
            customDeploymentView = new HorizontalScrolViewLayout()
            {
                X = Application.GetRealWidth(23),
                Height = Application.GetRealWidth(80),
                ScrollEnabled = false,
            };
            contentView.AddChidren(customDeploymentView);
 
            iniCustomDeploymentView();
 
 
            #endregion
 
            contentView.AddChidren(new Button()
            {
                Height = Application.GetRealHeight(20),
            });
 
            #region 固定布防区域
            /*
            var fixedDeploymentView = new FrameLayout()
            {
                Height = Application.GetRealHeight(133),
            };
            contentView.AddChidren(fixedDeploymentView);
 
            Button btnFixedDeploymentTitle = new Button()
            {
                X = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                TextAlignment = TextAlignment.CenterLeft,
                IsBold = true,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.FixedDeployment,
            };
            fixedDeploymentView.AddChidren(btnFixedDeploymentTitle);
 
            Button btnFixedDeploymentTip = new Button()
            {
                X = Application.GetRealWidth(24),
                Y = btnFixedDeploymentTitle.Bottom,
                Height = Application.GetRealWidth(19),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.MainColor,
                TextID = StringId.UndoDefenseDoesNotAffect
            };
            fixedDeploymentView.AddChidren(btnFixedDeploymentTip);
 
            var fixedDeploymentTypeView = new HorizontalScrolViewLayout()
            {
                Y = btnFixedDeploymentTip.Bottom + Application.GetRealHeight(15),
                Height = Application.GetRealHeight(80),
                ScrollEnabled = false,
            };
            fixedDeploymentView.AddChidren(fixedDeploymentTypeView);
 
            fixedDeploymentTypeView.AddChidren(new Button()
            {
                Width = Application.GetRealWidth(24),
            });
 
            #endregion
 
 
            //灾害报警
            var disasterAlarmView = new FixedArmView("FunctionIcon/ArmCenter/DisasterAlarmIcon.png", Language.StringByID(StringId.DisasterDefense), Language.StringByID(StringId.Defense24Hour));
            fixedDeploymentTypeView.AddChidren(disasterAlarmView);
 
            fixedDeploymentTypeView.AddChidren(new Button()
            {
                Width = Application.GetRealWidth(30),
            });
 
            //防盗报警
            var burglarAlarmView = new FixedArmView("FunctionIcon/ArmCenter/BurglarAlarmIcon.png", Language.StringByID(StringId.BurglarAlarm), Language.StringByID(StringId.AlarmMute));
            fixedDeploymentTypeView.AddChidren(burglarAlarmView);
            */
            #endregion
 
 
 
 
 
 
 
        }
 
        /// <summary>
        /// 初始化自定义布防区域
        /// </summary>
        private void iniCustomDeploymentView()
        {
            customDeploymentView.RemoveAll();
 
            foreach (var mode in FunctionList.List.securities)
            {
                var armDiyView = new ArmDiyView("FunctionIcon/ArmCenter/AddDefenseIcon.png", "FunctionIcon/ArmCenter/AddDefenseIcon.png",
                mode.name);
                customDeploymentView.AddChidren(armDiyView);
                EventHandler<MouseEventArgs> event2 = (sender, e) =>
                        {
                            ShowArmDialog(mode);
                        };
                armDiyView.SetClickEvent(event2);
            }
 
            if (FunctionList.List.securities.Count < 4)
            {
                var view = new ArmDiyView("FunctionIcon/ArmCenter/AddDefenseIcon.png", "FunctionIcon/ArmCenter/AddDefenseIcon.png",
                  Language.StringByID(StringId.Custom));
                customDeploymentView.AddChidren(view);
                EventHandler<MouseEventArgs> event1 = (sender, e) =>
                {
                    Action refreshAction = () =>
                    {
                        iniCustomDeploymentView();
                    };
 
                    var addDefensePage = new AddAlarmDeploymentPage(new SecurityAlarm(), refreshAction);
                    MainPage.BasePageView.AddChidren(addDefensePage);
                    addDefensePage.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                view.SetClickEvent(event1);
            }
 
        }
 
        private void ShowArmDialog(SecurityAlarm alarm)
        {
            Dialog dialog = new Dialog();
 
            FrameLayout contentView = new FrameLayout();
            dialog.AddChidren(contentView);
            contentView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
 
           VerticalScrolViewLayout optinView = new VerticalScrolViewLayout() {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(515),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(88),
                Radius = (uint)Application.GetRealHeight(13),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            contentView.AddChidren(optinView);
 
            Button btnOpen = new Button()
            {
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.OpenArm
            };
            optinView.AddChidren(btnOpen);
 
            optinView.AddChidren(new Button() {
                Height = 1,
                BackgroundColor = CSS_Color.DividingLineColor
            });
 
            Button btnCheckModify = new Button()
            {
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.PromptingColor1,
                TextID = StringId.CheckModify,
                TextSize = CSS_FontSize.SubheadingFontSize,
            };
            optinView.AddChidren(btnCheckModify);
 
 
            Button btnCancel = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = optinView.Bottom + Application.GetRealHeight(8),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(44),
                Radius = (uint)Application.GetRealHeight(13),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                TextID = StringId.Cancel,
                TextColor = CSS_Color.WarningColor,
                IsBold = true,
            };
            contentView.AddChidren(btnCancel);
 
            dialog.Show();
 
            btnOpen.MouseUpEventHandler = (sender, e) => {
                Control.Ins.ControlSecurity(alarm,  "enable");  
                dialog.Close();  
            };
 
 
            btnCheckModify.MouseUpEventHandler = (sender, e) => {
                dialog.Close();
                Action refreshAction = () =>
                {
                    iniCustomDeploymentView();
                };
                var armSetPage = new ArmDeploymentSettingPage(alarm,refreshAction);
                MainPage.BasePageView.AddChidren(armSetPage);
                armSetPage.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
 
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
 
        }
 
 
    }
 
 
    /// <summary>
    /// 安防自定义控件
    /// </summary>
    public class ArmDiyView : FrameLayout
    {
        Button btnIcon;
        Button btnText;
        /// <summary>
        /// 自定义布防界面
        /// </summary>
        /// <param name="UnSelectedIconPath">图片路径</param>
        /// <param name="SelectedIconPath">图片路径</param>
        /// <param name="Text">显示文本</param>
        public ArmDiyView(string UnSelectedIconPath, string SelectedIconPath, string Text)
        {
            this.Width = Application.GetRealWidth(82);
            this.Height = Application.GetRealWidth(80);
 
            btnIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = UnSelectedIconPath,
                SelectedImagePath = SelectedIconPath,
            };
            this.AddChidren(btnIcon);
 
            btnText = new Button()
            {
                Y = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(41),
                Text = Text,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            this.AddChidren(btnText);
        }
 
        public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler)
        {
            this.MouseUpEventHandler = eventHandler;
            btnIcon.MouseUpEventHandler = eventHandler;
            btnText.MouseUpEventHandler = eventHandler;
        }
 
 
    }
 
    public class FixedArmView : FrameLayout
    {
        /// <summary>
        /// 固定布防控件
        /// </summary>
        /// <param name="iconPath"></param>
        /// <param name="title"></param>
        /// <param name="titleTip"></param>
        public FixedArmView(string iconPath, string title, string titleTip)
        {
            this.Width = Application.GetRealWidth(144);
            this.Height = Application.GetRealHeight(66);
            this.Radius = (uint)Application.GetRealWidth(6);
            this.BorderColor = CSS_Color.MainColor;
            this.BorderWidth = 1;
 
            var btnIcon = new Button()
            {
                X = Application.GetRealWidth(15),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = iconPath,// "FunctionIcon/ArmCenter/DisasterAlarmIcon.png",
            };
            this.AddChidren(btnIcon);
 
            var btnTitle = new Button()
            {
                X = Application.GetRealWidth(55),
                Width = Application.GetRealWidth(89),
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                Text = title,
                IsBold = true,
            };
            this.AddChidren(btnTitle);
 
            var btnTitleTip = new Button()
            {
                X = Application.GetRealWidth(55),
                Y = Application.GetRealHeight(23),
                Width = Application.GetRealWidth(89),
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = titleTip,
            };
            this.AddChidren(btnTitleTip);
 
        }
    }
 
}