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> GetVideoInfoList() { List eSVideoInfosList = new List(); 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>>(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 { /// /// 室外机的UUID /// 例:JJY000007FSEYX /// public string ESVideoUUID = string.Empty; /// /// 当前用户的房间ID /// 例:0801 /// public int ESRoomID; /// /// 室外机的名称 /// 例:室外机 /// public string DeviceName = string.Empty; /// /// 房间命名 /// 例:8栋1单元0801 /// public string RoomName = string.Empty; } }