陈嘉乐
2020-07-08 4230f40556c36ac1d9f1aae1d80f6cb81754e708
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
using System;
using Newtonsoft.Json.Linq;
using Shared.Common;
using System.Collections.Generic;
using Shared.Phone.Device.Logic;
 
 
 
namespace Shared.Phone.Device.VideoIntercom
{
    public class VideoMachine : FrameLayout
    {
        public VideoMachine()
        {
        }
        public async void Show()
        {
 
            var videoInfosLists = await GetVideoInfoList();
 
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            //view.toptitleNameBtn.TextID = R.MyInternationalizationString.selection;
            view.toptitleNameBtn.Text = "可视对讲";
            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
 
            var middle = new VerticalRefreshLayout
            {
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
 
            for (int i = 0; i < videoInfosLists.Count; i++)
            {
                var videoInfos = videoInfosLists[i];
                var fLayout = new FrameLayout
                {
                    Height = Application.GetRealHeight(160),
                    BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                };
                middle.AddChidren(fLayout);
                var iconBtn = new Button
                {
                    Width = Application.GetMinRealAverage(81),
                    Height = Application.GetMinRealAverage(81),
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(55),
                    UnSelectedImagePath = "Item/videoIntercom.png",
                };
                fLayout.AddChidren(iconBtn);
                var nameBtn = new Button
                {
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    TextSize = 15,
                    Y = Application.GetRealHeight(30),
                    X = Application.GetRealWidth(176),
                    Height = Application.GetRealHeight(60),
                    Width = Application.GetRealWidth(400),
                    Text = videoInfos.DeviceName,
                };
                fLayout.AddChidren(nameBtn);
 
                var name1Btn = new Button
                {
                    Text = "2,2,0801",
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                    TextSize = 12,
                    Y = nameBtn.Bottom + Application.GetRealHeight(3),
                    X = Application.GetRealWidth(176),
                    Height = Application.GetRealHeight(60),
                    Width = Application.GetRealWidth(400),
                };
                fLayout.AddChidren(name1Btn);
 
                var nextBtn = new Button
                {
                    Width = Application.GetMinRealAverage(104),
                    Height = Application.GetMinRealAverage(104),
                    UnSelectedImagePath = "Item/videoIntercomNext.png",
                    X = Application.GetRealWidth(743 + 176),
                    Y = Application.GetRealHeight(30),
                };
                fLayout.AddChidren(nextBtn);
 
                var lineBtn = new Button
                {
                    Width = Application.GetRealWidth(845),
                    Height = 1,
                    Y = fLayout.Height - 1,
                    X = Application.GetRealWidth(176),
                    BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                };
                fLayout.AddChidren(lineBtn);
                var clickBtn = new Button
                {
                    Height = Application.GetRealHeight(160),
                };
                fLayout.AddChidren(clickBtn);
 
                clickBtn.MouseUpEventHandler += (sen, e) =>
                 {
#if iOS
                     GateWay.Ios.ESVideoInfo eSVideoInfo = new GateWay.Ios.ESVideoInfo();
                     eSVideoInfo.DeviceName = videoInfos.DeviceName;
                     eSVideoInfo.ESVideoUUID = videoInfos.ESVideoUUID;
                     eSVideoInfo.ESRoomID = videoInfos.ESRoomID;
                     eSVideoInfo.RoomName = videoInfos.RoomName;
                     GateWay.Ios.ESVideo.ShowESVideoMonitor(eSVideoInfo);
#elif Android
                   
#endif
                 };
 
            }
 
        }
 
        async System.Threading.Tasks.Task<List<VideoCalss>> GetVideoInfoList()
        {
            List<VideoCalss> eSVideoInfosList = new List<VideoCalss>();
            var jobject = new JObject();
            jobject.Add("cmtID", "10006");
            jobject.Add("unitno", "0801");
            jobject.Add("method", "getUUIDList");
            var url = " http://112.74.164.111:180/api.php/Device/getmonitorUUID";
            var str = await Send.HttpWebRequest(url, jobject.ToString(), "POST");
            if (string.IsNullOrEmpty(str))
            {
                return eSVideoInfosList;
            }
            var json = JObject.Parse(str);
            if (json == null)
            {
                return eSVideoInfosList;
            }
            if (json["resCode"].ToString() != "0")
            {
                return eSVideoInfosList;
            }
            var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(json["list"].ToString());
            if (list.Count == 0)
            {
                return eSVideoInfosList;
            }
            foreach (var videoInfo in list)
            {
                VideoCalss eSVideoInfo = new VideoCalss();
                eSVideoInfo.DeviceName = videoInfo["aliasName"];
                if (videoInfo["uuid"].Contains(","))
                {
                    var uuid = videoInfo["uuid"].Split(',');
                    eSVideoInfo.ESVideoUUID = uuid[0];
                }
                else
                {
                    eSVideoInfo.ESVideoUUID = videoInfo["uuid"];
                }
                eSVideoInfosList.Add(eSVideoInfo);
            }
            return eSVideoInfosList;
        }
 
    }
 
    class VideoCalss
    {
        /// <summary>
        /// 室外机的UUID
        /// 例:JJY000007FSEYX
        /// </summary>
        public string ESVideoUUID = string.Empty;
        /// <summary>
        /// 当前用户的房间ID
        /// 例:0801
        /// </summary>
        public int ESRoomID;
        /// <summary>
        /// 室外机的名称
        /// 例:室外机
        /// </summary>
        public string DeviceName = string.Empty;
        /// <summary>
        /// 房间命名
        /// 例:8栋1单元0801
        /// </summary>
        public string RoomName = string.Empty;
 
    }
}