陈嘉乐
2021-04-01 89e5ee13906a80f5357e078301169fabbf9103c6
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
using System;
using HDL_ON.UI.Music;
using System.Collections.Generic;
using Shared;
using HDL_ON.Stan;
using ZXing.QrCode.Internal;
using static HDL_ON.UI.UI2.FuntionControlView.Video.VideoMethod;
 
namespace HDL_ON.UI.UI2.FuntionControlView.Video
{
    public class MainView : FrameLayout
    {
        /// <summary>
        /// 加载可视对讲UI
        /// </summary>
        /// <param name="listVideo">门口机列表</param>
        /// <param name="listCall">通话记录列表</param>
        /// <param name="video">当前的可视对讲</param>
        public void Show(List<VideoMethod.FlVideo> listVideo, List<CallView> listCall, VideoClouds video)
        {
            #region 布局界面
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.TextID = StringId.keshiduijiang;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
 
            var pageView = new PageLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64),
                IsShowPoint = false,
            };
            this.AddChidren(pageView);
            var view1 = new FrameLayout();
            pageView.AddChidren(view1);
            var view2 = new FrameLayout();
            pageView.AddChidren(view2);
            View1(view1, listVideo, video);
            View2(view2, listCall, video);
            Button btn11 = new Button
            {
                X = Application.GetRealWidth(170),
                Y = Application.GetRealHeight(578),
                Width = Application.GetRealWidth(14),
                Height = Application.GetRealHeight(6),
                BackgroundColor = MusicColor.SelectedColor,
                Radius = (uint)Application.GetRealHeight(4),
            };
            view1.AddChidren(btn11);
 
            Button btn12 = new Button
            {
                X = Application.GetRealWidth(192),
                Y = Application.GetRealHeight(578),
                Width = Application.GetRealWidth(14),
                Height = Application.GetRealHeight(6),
                BackgroundColor = 0x404484F4,
                Radius = (uint)Application.GetRealHeight(4),
            };
            view1.AddChidren(btn12);
            Button btn21 = new Button
            {
                X = Application.GetRealWidth(170),
                Y = Application.GetRealHeight(578),
                Width = Application.GetRealWidth(14),
                Height = Application.GetRealHeight(6),
                BackgroundColor = 0x404484F4,
                Radius = (uint)Application.GetRealHeight(4),
            };
            view2.AddChidren(btn21);
 
            Button btn22 = new Button
            {
                X = Application.GetRealWidth(192),
                Y = Application.GetRealHeight(578),
                Width = Application.GetRealWidth(14),
                Height = Application.GetRealHeight(6),
                BackgroundColor = MusicColor.SelectedColor,
                Radius = (uint)Application.GetRealHeight(4),
            };
            view2.AddChidren(btn22);
 
            pageView.PageChange = (sender, e) =>
            {
 
                if (pageView.PageIndex == 0)
                {
                    topView.topNameBtn.TextID = StringId.keshiduijiang;
                }
                else
                {
                    topView.topNameBtn.TextID = StringId.tonghuajilu;
 
                }
            };
            #endregion
        }
        /// <summary>
        /// 第一个界面
        /// </summary>
        /// <param name="view1">父控件</param>
        /// <param name="list">门口机列表</param>
        /// <param name="videoClouds">当前的可视对讲</param>
        void View1(FrameLayout view1, List<VideoMethod.FlVideo> list, VideoClouds videoClouds)
        {
            #region 布局界面
            var bjFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
                X = Application.GetRealWidth(24),
                Height = Application.GetRealHeight(526),
                Width = Application.GetRealWidth(327),
                BackgroundImagePath = "MusicIcon/playBj.png",
            };
            view1.AddChidren(bjFl);
            /// <summary>
            ///  汉字
            /// </summary>
            Button nameBtn = new Button
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(16),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(33),
                TextColor = MusicColor.MusicTxet14Color,
                TextSize = TextSize.Text24,
                TextAlignment = TextAlignment.CenterLeft,
                //Text = "可视对讲",
                TextID = StringId.keshiduijiang,
            };
            bjFl.AddChidren(nameBtn);
            /// <summary>
            ///  区域名称
            /// </summary>
            Button regionBtn = new Button
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(53),
                Width = Application.GetRealWidth(270),
                Height = Application.GetRealHeight(17),
                TextColor = MusicColor.MusicNoTxetColor,
                TextSize = TextSize.Text12,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "123456"
            };
           // bjFl.AddChidren(regionBtn);
            /// <summary>
            ///收藏图标
            /// </summary>
            Button collectIconBtn = new Button
            {
                X = Application.GetRealWidth(273),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "MusicIcon/collect.png",
                SelectedImagePath = "MusicIcon/collectSelected.png",
            };
           // bjFl.AddChidren(collectIconBtn);
            ///可视对讲图标
            Button intercomBtnIcon = new Button
            {
                X = Application.GetRealWidth(84),
                Y = Application.GetRealHeight(118),
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealWidth(160),
                UnSelectedImagePath = "VideoIcon/keshiduijiang.png",
 
            };
            bjFl.AddChidren(intercomBtnIcon);
 
            var vv = new VerticalScrolViewLayout
            {
                Y = Application.GetRealHeight(306),
                Height = Application.GetRealHeight(220),
                Width = Application.GetRealWidth(327),
            };
            bjFl.AddChidren(vv);
            if (list.Count > 0)
            {
                //门禁二维码固定有的,虚拟一个出来
                list.Add(new VideoMethod.FlVideo { aliasName =Language.StringByID(StringId.menjinerweima), devType = "100" });
            }
            //数组个数
            //int value = 15;
            //先计算数据所需要的很高度;
            int l = 0;
            if (list.Count % 3 == 0)
            {
                l = list.Count / 3;
            }
            else
            {
 
                l = (list.Count / 3) + 1;
            }
            var fL = new FrameLayout
            {
                Height = Application.GetRealHeight((48 + 24) * l),
 
            };
            vv.AddChidren(fL);
            int line = 0;
            #endregion
            for (int i = 1, j = 0; i <= list.Count; i++, j++)
            {
                var video = list[i - 1];
                #region
                var fLayout = new FrameLayout
                {
                    Width = Application.GetRealWidth(50),
                    Height = Application.GetRealWidth(48),
                    X = Application.GetRealWidth(31 + (58 + 50) * j),
                    Y = Application.GetRealHeight(20 + (48 + 24) * line),
 
                };
                fL.AddChidren(fLayout);
 
                var iconBtn = new Button
                {
                    X = Application.GetRealWidth(11),
                    Width = Application.GetRealWidth(28),
                    Height = Application.GetRealWidth(28),
                    UnSelectedImagePath = "VideoIcon/weiqiangji.png",
                };
                fLayout.AddChidren(iconBtn);
 
                var deviceNameBtn = new Button
                {
                    Y = iconBtn.Bottom + Application.GetRealHeight(6),
                    Width = Application.GetRealWidth(50),
                    Height = Application.GetRealHeight(14),
                    TextSize = TextSize.Text10,
                    TextColor = CSS.CSS_Color.TextualColor,
                    TextAlignment = TextAlignment.Center,
                    Text = video.aliasName,
                };
                fLayout.AddChidren(deviceNameBtn);
 
                var clickBtn = new Button { Tag = video };
 
                fLayout.AddChidren(clickBtn);
                if (i % 3 == 0)
                {
                    //满一行重置j=0值;
                    j = -1;
                    line += 1;
                }
                getIconAndText(video, iconBtn);
                #endregion
                //门口机的点击事件
                clickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    var flVideo = clickBtn.Tag as FlVideo;
                    if (flVideo.devType == "100")
                    {
                        //门禁二维码固定有的
                        VideoSend.GetQRcode(this, videoClouds, (tag, paw) =>
                        {
                            if (tag)
                            {
                                //注意:密码有可能延时1分钟生效
                                View.ShowDialog showDialog = new View.ShowDialog();
                                showDialog.QRcode(paw);
                            }
                        });
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(flVideo.uuid))
                        {
                            new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.peizhicanshuyouyichang));
                        }
                        ESVideoInfo eSVideoInfo = new ESVideoInfo
                        {
                            ESVideoUUID = getUuid(flVideo.uuid),
                            DeviceName = flVideo.aliasName,
                            roomno = videoClouds.flRoomId,
                            unitno = videoClouds.flBuildingId,
                        };
                        ESOnVideo.Current.ShowESVideoMonitor(eSVideoInfo);
                    }
 
 
                };
            }
 
 
        }
        /// <summary>
        /// 第二个界面
        /// </summary>
        /// <param name="view2">父控件</param>
        /// <param name="listCall">通话记录列表</param>
        /// <param name="video">当前的可视对讲</param>
        void View2(FrameLayout view2, List<CallView> listCall, VideoClouds video)
        {
 
            var bjFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
                X = Application.GetRealWidth(24),
                Height = Application.GetRealHeight(526),
                Width = Application.GetRealWidth(327),
                BackgroundImagePath = "MusicIcon/playBj.png",
            };
            view2.AddChidren(bjFl);
            /// <summary>
            ///  汉字
            /// </summary>
            Button nameBtn = new Button
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(16),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(33),
                TextColor = MusicColor.MusicTxet14Color,
                TextSize = TextSize.Text24,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.tonghuajilu,
            };
            bjFl.AddChidren(nameBtn);
            /// <summary>
            ///  云端照片只保留30天
            /// </summary>
            Button regionBtn = new Button
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(53),
                Width = Application.GetRealWidth(270),
                Height = Application.GetRealHeight(17),
                TextColor = MusicColor.SelectedColor,
                TextSize = TextSize.Text12,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.baolu30,
            };
            bjFl.AddChidren(regionBtn);
 
            var vv = new VerticalRefreshLayout
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(58),
                Height = Application.GetRealHeight(458),
                Width = Application.GetRealWidth(295),
            };
            bjFl.AddChidren(vv);
            vv.BeginHeaderRefreshingAction += () =>
            {
                VideoMethod videoMethod = new VideoMethod();
                var list = videoMethod.GetCall(video.id);
                RefreshView(vv, list);
                //关闭刷新View;
                vv.EndHeaderRefreshing();
            };
            RefreshView(vv, listCall);
 
        }
        /// <summary>
        /// 通话记录刷新界面
        /// </summary>
        /// <param name="vv">上下滑动控件</param>
        /// <param name="listCall">通话记录列表</param>
        public void RefreshView(VerticalRefreshLayout vv, List<CallView> listCall)
        {
            vv.RemoveAll();
            for (int i = 0; i < listCall.Count; i++)
            {
                var year = listCall[i];
                //年文本父控件
                View.FrameLayout50 frameLayout50 = new View.FrameLayout50();
                vv.AddChidren(frameLayout50.FLayoutView());
                frameLayout50.btnText.Text = year.year + Language.StringByID(StringId.nian);//年
                for (int j = 0; j < year.callList.Count; j++)
                {
                    var call = year.callList[j];
                    //门口机状态父控件
                    View.FrameLayout60 frameLayout60 = new View.FrameLayout60();
                    vv.AddChidren(frameLayout60.FLayoutView());
                    ///呼叫时间
                    frameLayout60.btnTime.Text = getTime(call.callTime);
                    ///呼叫状态(0:未接;1:已接;2:拒接);是否开锁;
                    frameLayout60.btnStateText.Text = getStateText(call.callStatus) + "," + getUnlockText(call.isUnlock);
 
                }
 
            }
 
 
        }
        /// <summary>
        /// 显示图标
        /// </summary>
        /// <param name="flVideo"></param>
        /// <param name="iconBtn">图标</param>
        private void getIconAndText(FlVideo flVideo, Button iconBtn)
        {
            //(1室内机,2室外机,3围墙机,4管理机,5二次确认机)
            string iconstr = "";
            switch (flVideo.devType)
            {
                case "1":
                    {
                        iconstr = "VideoIcon/danyuanji.png";
                    }
                    break;
                case "2":
                    {
                        iconstr = "VideoIcon/danyuanji.png";
                    }
                    break;
                case "3":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "4":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "5":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "100":
                    {
                        iconstr = "VideoIcon/menjin.png";
                    }
                    break;
                default:
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
 
            }
            iconBtn.UnSelectedImagePath = iconstr;
 
        }
        /// <summary>
        /// 获取显示时间文本
        /// </summary>
        /// <param name="str">utcTime</param>
        /// <returns></returns>
        private string getTime(string str)
        {
            var utcTime = Convert.ToDateTime(str);
            var dateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
            return dateTime.ToString("HH") + ":" + dateTime.ToString("mm");
        }
        /// <summary>
        /// 获取呼叫状态文本
        /// </summary>
        /// <param name="str">状态值0:未接;1:已接;2:拒接</param>
        /// <returns></returns>
        private string getStateText(string str)
        {
            string s = "";
            switch (str)
            {
                case "0":
                    {
                        s = Language.StringByID(StringId.weijieting);
                    }
                    break;
                case "1":
                    {
                        Language.StringByID(StringId.yijieting);
                    }
                    break;
                case "2":
                    {
                        Language.StringByID(StringId.yijujue);
                    }
                    break;
            }
            return s;
        }
        /// <summary>
        /// 获取开锁状态文本
        /// </summary>
        /// <param name="if_bool"></param>
        /// <returns></returns>
        private string getUnlockText(bool if_bool)
        {
            string s = "";
            if (if_bool)
            {
                s = Language.StringByID(StringId.yikaisuo);
            }
            else
            {
                s = Language.StringByID(StringId.weikaisuo);
            }
            return s;
        }
        /// <summary>
        /// 获取uuid
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        private string getUuid(string uuid)
        {
            if (uuid.Contains(","))
            {
                var uuid1 = uuid.Split(',');
                return uuid1[0];
            }
            else
            {
                return uuid;
            }
        }
 
    }
 
}