using System; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl; using System.Collections.Generic; using Newtonsoft.Json.Linq; namespace SmartHome.UI.SimpleControl.Phone { public class YiPanelSceneList:FrameLayout { YIPanel yipanel; public List localSceneList = new List (); public void Show (YIPanel yipanel, string name) { this.yipanel = yipanel; this.BackgroundColor = 0xFF1F1F1F; this.AddChidren (new Button { Height = Application.GetRealHeight (30), }); var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight (100), Y = Application.GetRealHeight (30), }; AddChidren (topFrameLayout); var titleName = new Button { Text = name, //TextID = MyInternationalizationString.adddevice, TextSize = 17, }; topFrameLayout.AddChidren (titleName); var add = new Button { Width = Application.GetRealWidth (72), Height = Application.GetRealHeight (58), UnSelectedImagePath = "MusicIcon/add.png", X = Application.GetRealWidth (525), Gravity = Gravity.CenterVertical, }; topFrameLayout.AddChidren (add); var back = new Button { Width = Application.GetRealWidth (82), Height = Application.GetRealHeight (89), X = Application.GetRealWidth (10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/HomepageBack.png", }; topFrameLayout.AddChidren (back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent (); }; var middle = new VerticalScrolViewLayout (); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight (1136 - 130-80); middle.BackgroundColor = 0xff2F2F2F; this.AddChidren (middle); ///添加点击事件 add.MouseUpEventHandler += (sender, e) => { localdata (); MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); var localSceneListPage = new LocalSceneListPage (); MainPage.MainFrameLayout.AddChidren (localSceneListPage); localSceneListPage.Show (() => { sceneview (middle); }, localSceneList,yipanel); }); }); }; if (yipanel.yIPanelSceneList.Count == 0) { refreshsecenelist (() => { Application.RunOnMainThread (() => { sceneview (middle); }); }); } else { sceneview (middle); } var btnText = new Button { Y = middle.Bottom, Height = Application.GetRealHeight (80), TextID = MyInternationalizationString.synchronizepaneldata, TextSize = 16, }; this.AddChidren (btnText); btnText.MouseUpEventHandler += (sender, e) => { var alert = new Alert (Language.StringByID (MyInternationalizationString.prompt), Language.StringByID (MyInternationalizationString.synchronizepaneldata), Language.StringByID (MyInternationalizationString.cancel), Language.StringByID (MyInternationalizationString.confirm)); alert.ResultEventHandler += (sender1, e1) => { if (e1) { syncscenedata (); } }; alert.Show (); }; } /// /// 更新本地场景最新数据 /// void localdata(){ localSceneList.Clear (); try { var filesList = Shared.IO.FileUtils.ReadFiles ().FindAll ((obj) => { string [] str = obj.Split ('_'); return obj.StartsWith ("RoomScene_") || obj.StartsWith ("GlobalScene_"); }); foreach (var file in filesList) { var scenestring = System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (file)); if (scenestring == null) { continue; } var jObject = JObject.Parse (scenestring); if (jObject == null) { continue; } YiPanelScene yiPanelScene = new YiPanelScene (); yiPanelScene.Name = jObject ["Name"]?.ToString (); var deviceFilePathList = JArray.Parse (jObject ["DeviceFilePathList"]?.ToString ()); foreach (var filepath in deviceFilePathList) { var devicefilepath = filepath.ToString (); var devicestring = System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (devicefilepath)); if (devicestring == null) { continue; } var jObject1 = Newtonsoft.Json.Linq.JObject.Parse (devicestring); if (jObject1 == null) { continue; } switch ((DeviceType)jObject1.Value ("Type")) { case DeviceType.LightSwitch: { YiPanelLightSwitch lightSwitch = new YiPanelLightSwitch (); lightSwitch.large = 1; lightSwitch.Name = jObject1 ["Name"]?.ToString (); lightSwitch.SubnetID = jObject1.Value ("SubnetID"); lightSwitch.DeviceID = jObject1.Value ("DeviceID"); lightSwitch.LoopID = jObject1.Value ("LoopID"); lightSwitch.CurrentBrightness = jObject1.Value ("CurrentBrightness"); for (int i = 1; i <= 64; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 1) && (c.channelnumber == (byte)i)); if (devicenumber == null) { lightSwitch.channelnumber = (byte)i; break; } } var dev = lightSwitch as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.LightDimming: { YiPanelLightDimming lightDimming = new YiPanelLightDimming (); lightDimming.large = 1; lightDimming.Name = jObject1 ["Name"]?.ToString (); lightDimming.SubnetID = jObject1.Value ("SubnetID"); lightDimming.DeviceID = jObject1.Value ("DeviceID"); lightDimming.LoopID = jObject1.Value ("LoopID"); lightDimming.CurrentBrightness = jObject1.Value ("CurrentBrightness"); for (int i = 1; i <= 64; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 1) && (c.channelnumber == (byte)i)); if (devicenumber == null) { lightDimming.channelnumber = (byte)i; break; } } var dev = lightDimming as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.CurtainModel: { YiPanelCurtainModel curtainModel = new YiPanelCurtainModel (); curtainModel.large =2; curtainModel.Name = jObject1 ["Name"]?.ToString (); curtainModel.SubnetID = jObject1.Value ("SubnetID"); curtainModel.DeviceID = jObject1.Value ("DeviceID"); curtainModel.LoopID = jObject1.Value ("LoopID"); curtainModel.Status = (CurtainStatus)jObject1.Value ("Status"); for (int i = 1; i <= 8; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 2) && (c.channelnumber == (byte)i)); if (devicenumber == null) { curtainModel.channelnumber = (byte)i; break; } } var dev = curtainModel as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.CurtainRoller: { YiPanelCurtainRoller curtainRoller = new YiPanelCurtainRoller (); curtainRoller.large = 2; curtainRoller.Name = jObject1 ["Name"]?.ToString (); curtainRoller.SubnetID = jObject1.Value ("SubnetID"); curtainRoller.DeviceID = jObject1.Value ("DeviceID"); curtainRoller.LoopID = jObject1.Value ("LoopID"); curtainRoller.CurtainProress = jObject1.Value ("CurtainProress"); for (int i = 1; i <= 8; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 2) && (c.channelnumber == (byte)i)); if (devicenumber == null) { curtainRoller.channelnumber = (byte)i; break; } } var dev = curtainRoller as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.FreshAir: { //device.typevalue = 4; //b = 8; //var freshAir = device as FreshAir; } break; case DeviceType.HVAC: { YiPanelHVAC hvac = new YiPanelHVAC (); hvac.large = 7; hvac.Name = jObject1 ["Name"]?.ToString (); hvac.SubnetID = jObject1.Value ("SubnetID"); hvac.DeviceID = jObject1.Value ("DeviceID"); hvac.LoopID = jObject1.Value ("LoopID"); hvac.Power = jObject1.Value ("Power"); hvac.SetFanSpeed = jObject1.Value ("SetFanSpeed"); hvac.SetMode = jObject1.Value ("SetMode"); hvac.SetTemperature = jObject1.Value ("SetTemperature"); for (int i = 1; i <= 8; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 7) && (c.channelnumber == (byte)i)); if (devicenumber == null) { hvac.channelnumber = (byte)i; break; } } var dev = hvac as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.FoolHeat: { YiPanelFoolHeat foolHeat = new YiPanelFoolHeat (); foolHeat.large = 8; foolHeat.Name = jObject1 ["Name"]?.ToString (); foolHeat.SubnetID = jObject1.Value ("SubnetID"); foolHeat.DeviceID = jObject1.Value ("DeviceID"); foolHeat.LoopID = jObject1.Value ("LoopID"); foolHeat.PWDStatus = jObject1.Value ("PWDStatus"); foolHeat.TemperatureType = jObject1.Value ("TemperatureType"); foolHeat.TemperatureTypeValue = jObject1.Value ("TemperatureTypeValue"); for (int i = 1; i <= 8; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 8) && (c.channelnumber == (byte)i)); if (devicenumber == null) { foolHeat.channelnumber = (byte)i; break; } } var dev = foolHeat as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; case DeviceType.MusicModel: { YiPanelMusicModel musicModel = new YiPanelMusicModel (); musicModel.large = 9; musicModel.Name = jObject1 ["Name"]?.ToString (); musicModel.SubnetID = jObject1.Value ("SubnetID"); musicModel.DeviceID = jObject1.Value ("DeviceID"); musicModel.LoopID = jObject1.Value ("LoopID"); musicModel.CurVol = jObject1 ["CurVol"]?.ToString (); musicModel.playMode = jObject1.Value ("PlayMode"); musicModel.PlayStatus = (YiPanelMusicModel.Status)jObject1.Value ("PlayStatus"); for (int i = 1; i <= 9; i++) { var devicenumber = yiPanelScene.scenedevicelist.Find ((c) => (c.large == 8) && (c.channelnumber == (byte)i)); if (devicenumber == null) { musicModel.channelnumber = (byte)i; break; } } var dev = musicModel as YiPanelCommon; yiPanelScene.scenedevicelist.Add (dev); } break; } } localSceneList.Add (yiPanelScene); } foreach (var localscene in localSceneList) { var currscene = yipanel.yIPanelSceneList.Find ((c) => c.Name == localscene.Name); if (currscene != null) { foreach (var device in localscene.scenedevicelist) { var dev = currscene.scenedevicelist.Find ((c) => (c.Type == device.Type) && (c.CommonLoopID == device.CommonLoopID)); if (dev == null) { int b = 0; switch (device.Type) { case DeviceType.LightSwitch: case DeviceType.LightDimming: { device.large = 1; b = 64; } break; case DeviceType.CurtainModel: case DeviceType.CurtainRoller: { device.large = 2; b = 8; } break; case DeviceType.FreshAir: { //device.large = 4; //b = 8; } break; case DeviceType.HVAC: { device.large = 7; b = 8; } break; case DeviceType.FoolHeat: { device.large = 8; b = 8; } break; case DeviceType.MusicModel: { device.large = 9; b = 8; } break; } for (int i = 1; i <= b; i++) { var devicenumber = currscene.scenedevicelist.Find ((c) => (c.large == device.large) && (c.channelnumber == (byte)i)); if (devicenumber == null) { device.channelnumber = (byte)i; currscene.scenedevicelist.Add (device); break; } } } else { device.channelnumber = dev.channelnumber; currscene.scenedevicelist.Remove (dev); currscene.scenedevicelist.Add (device); } } } } } catch(Exception e) { var s = e.Message; } } /// /// 同步数据到面板 /// void syncscenedata () { var scenelist = new List (); scenelist.Clear (); localdata (); ///只同步本地场景; foreach (var yIPanelscene in yipanel.yIPanelSceneList) { var currscene = localSceneList.Find ((c) => c.Name == yIPanelscene.Name); if (currscene != null) { scenelist.Add (yIPanelscene); } } MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.insync)+"..."); new System.Threading.Thread (() => { try { for (int j = 0; j < scenelist.Count; j++) { var sceneifon = scenelist [j]; var bytes = new byte [24]; bytes [0] = sceneifon.LargeClass; bytes [1] = 1; bytes [2] = sceneifon.Channelnumber; bytes [3] = 0; var pathBytes = System.Text.Encoding.UTF8.GetBytes (sceneifon.Name); Array.Copy (pathBytes, 0, bytes, 4, pathBytes.Length > 20 ? 20 : pathBytes.Length); var returnBytes = Control.ControlBytesSendHasReturn (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, bytes); if (returnBytes == null) { return; } var bytes1 = new byte [5]; bytes1 [0] = sceneifon.LargeClass; bytes1 [1] = 1; bytes1 [2] = sceneifon.Channelnumber; bytes1 [3] = 1; bytes1 [4] = 1; var data = Control.ControlBytesSendHasReturn (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, bytes1); var iconbytes= new byte [5]; iconbytes [0] = sceneifon.LargeClass; iconbytes [1] = 1; iconbytes [2] = sceneifon.Channelnumber; iconbytes [3] = 8; iconbytes [4] = sceneifon.IconIndex; var iocndata = Control.ControlBytesSendHasReturn (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, iconbytes); int b = 0; for (int targetIndex = 0; targetIndex < sceneifon.scenedevicelist.Count; targetIndex++) { var common = sceneifon.scenedevicelist [targetIndex]; var devicebytes = new byte [9]; devicebytes [0] = sceneifon.Channelnumber; devicebytes [3] = common.SubnetID; devicebytes [4] = common.DeviceID; switch (common.Type) { case DeviceType.CurtainModel: { var curtainModel = common as YiPanelCurtainModel; devicebytes [1] = (byte)++b; devicebytes [2] = 92; devicebytes [5] = common.LoopID; devicebytes [6] = (byte)curtainModel.Status; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.CurtainRoller: { var curtainRoller = common as YiPanelCurtainRoller; devicebytes [1] = (byte)++b; devicebytes [2] = 92; devicebytes [5] = common.LoopID; devicebytes [6] = curtainRoller.CurtainProress; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.LightSwitch: { var lightSwitch = common as YiPanelLightSwitch; devicebytes [1] = (byte)++b; devicebytes [2] = 89; devicebytes [5] = common.LoopID; devicebytes [6] = lightSwitch.CurrentBrightness; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.LightDimming: { var lightDimming = common as YiPanelLightDimming; devicebytes [1] = (byte)++b; devicebytes [2] = 89; devicebytes [5] = common.LoopID; devicebytes [6] = lightDimming.CurrentBrightness; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.HVAC: { var hVAC = common as YiPanelHVAC; devicebytes [1] = (byte)++b; devicebytes [2] = 95; devicebytes [7] = hVAC.LoopID; devicebytes [5] = 3; devicebytes [6] = hVAC.Power; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); devicebytes [1] = (byte)++b; devicebytes [5] = 5; devicebytes [6] = hVAC.SetFanSpeed; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); devicebytes [1] = (byte)++b; devicebytes [5] = 6; devicebytes [6] = hVAC.SetMode; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); //0 制冷 1制热,2通风(没有温度值),3自动,4除湿 switch (hVAC.SetMode) { case 0: { devicebytes [5] = 4; } break; case 1: { devicebytes [5] = 7; } break; case 3: { devicebytes [5] = 8; } break; case 4: { devicebytes [5] = 19; } break; } devicebytes [1] = (byte)++b; devicebytes [6] = hVAC.SetTemperature; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.FoolHeat: { var foolHeat = common as YiPanelFoolHeat; devicebytes [1] = (byte)++b; devicebytes [2] = 95; devicebytes [7] = foolHeat.LoopID; devicebytes [5] = 20; devicebytes [6] = foolHeat.PWDStatus; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); devicebytes [1] = (byte)++b; devicebytes [5] = 21; devicebytes [6] = foolHeat.TemperatureType; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); switch (foolHeat.TemperatureType) { case 1: { devicebytes [5] = 25; } break; case 2: { devicebytes [5] = 26; } break; case 3: { devicebytes [5] = 27; } break; case 4: { devicebytes [5] = 28; } break; } devicebytes [1] = (byte)++b; devicebytes [6] = foolHeat.TemperatureTypeValue; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; case DeviceType.MusicModel: { var music = common as YiPanelMusicModel; devicebytes [1] = (byte)++b; devicebytes [2] = 103; devicebytes [7] = music.LoopID; devicebytes [5] = 2; devicebytes [6] = (byte)music.playMode; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); devicebytes [1] = (byte)++b; devicebytes [5] = 4; devicebytes [6] = (byte)music.PlayStatus; Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); devicebytes [1] = (byte)++b; devicebytes [5] = 5; devicebytes [6] = Convert.ToByte (music.CurVol); Control.ControlBytesSendHasReturn (Command.WriteWirelessPanelButtonKey, yipanel.SubnetID, yipanel.DeviceID, devicebytes); } break; } } //int dddd = 00; /// } } catch { } finally { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); }); } }) { IsBackground = true }.Start (); } /// /// 读取面板场景 /// /// Action. void refreshsecenelist (Action action) { var type = yipanel.DeviceTypeList.Find ((obj) => { return obj.largeclass == 4; }); if (type == null) { return; } yipanel.yIPanelSceneList.Clear (); List intlist = new List (); intlist.Clear(); MainPage.Loading.Start (); new System.Threading.Thread (() => { try { var validBytes = Shared.Control.ControlBytesSendHasReturn (Command.YIPanelDevice, yipanel.SubnetID, yipanel.DeviceID, new byte [2] { type.largeclass, type.subclass }); if (validBytes != null) { string len = ""; if (validBytes [1] == 1) { for (int i = 3; i <= 6; i++) { var bytes = validBytes [i]; var stringlen = System.Convert.ToString (bytes, 2); var str = stringlen.Insert (0, new string ('0', 8 - stringlen.Length)); if (str.Length == 8) { for (int j = 7; j >= 0; j--) { len += str.Substring (j, 1); } } } for (int j = 0; j < len.Length; j++) { var strvalue = len.Substring (j, 1); if (strvalue == "1") { intlist.Add (j + 1); } } } } for (int i = 0; i < intlist.Count; i++) { var value = (byte)intlist [i]; var scene = new YiPanelScene (); scene.LargeClass = type.largeclass; scene.sub = type.subclass; scene.Channelnumber = value; ///发送获取场景的名称指令 var nameBytes = Shared.Control.ControlBytesSendHasReturn (Command.YIPanelDeviceInof, yipanel.SubnetID, yipanel.DeviceID, new byte [4] { type.largeclass, type.subclass, value, 0 }); if (nameBytes != null) { var bytes = new byte [20]; for (int j = 0; j < 20; j++) { bytes [j] = nameBytes [j + 4]; } scene.Name = System.Text.Encoding.UTF8.GetString (bytes).Replace ("\0", ""); } ///发送获取场景的图标索引指令 var iconBytes = Shared.Control.ControlBytesSendHasReturn (Command.YIPanelDeviceInof, yipanel.SubnetID, yipanel.DeviceID, new byte [4] { type.largeclass, type.subclass, value, 8 }); if (iconBytes != null) { scene.IconIndex = iconBytes [4]; } yipanel.yIPanelSceneList.Add (scene); } } catch { } finally { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); action (); }); } }){IsBackground=true}.Start(); } /// ///加载场景列表界面 /// void sceneview (VerticalScrolViewLayout middle) { middle.RemoveAll (); foreach (var scene in yipanel.yIPanelSceneList) { var sceneRowLayout = new RowLayout { Height = Application.GetRealHeight (100), BackgroundColor = 0xff323232, }; middle.AddChidren (sceneRowLayout); var sceneicon = new Button { Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (83), UnSelectedImagePath = $"Yipanel/{scene.IconIndex}.png", Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (10), }; //sceneRowLayout.AddChidren (sceneicon); var scenetypename = new Button { Width = Application.GetRealWidth (350), Text = scene.Name, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (30), //X = Application.GetRealWidth (10)+sceneicon.Width +Application.GetRealWidth (10), }; sceneRowLayout.AddChidren (scenetypename); var editorscenename = new Button { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (70), UnSelectedImagePath = "Item/Editor.png", SelectedImagePath = "Item/EditorSelected.png", Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (525), }; sceneRowLayout.AddChidren (editorscenename); ///删除 var del = new Button { //TextID = MyInternationalizationString.Musicdel, BackgroundColor = 0xFFFF0000, Text = Language.StringByID (MyInternationalizationString.del), }; sceneRowLayout.AddRightView (del); editorscenename.MouseUpEventHandler += (sender, e) => { MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); var etid = new Etid (); MainPage.MainFrameLayout.AddChidren (etid); etid.Show (yipanel, scene, () => { scenetypename.Text = scene.Name; }); }); }); }; del.MouseUpEventHandler += (sender, e) => { yipanel.yIPanelSceneList.RemoveAll ((c) => c.Channelnumber == scene.Channelnumber); System.Threading.Tasks.Task.Run (() => { try { var bytes = new byte [10]; bytes [0] = scene.LargeClass; bytes [1] = scene.sub; bytes [2] = scene.Channelnumber; bytes [3] = 1; bytes [4] = 0; Shared.Control.ControlBytesSend (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, bytes); } catch { } finally { Application.RunOnMainThread (() => { sceneview (middle); }); } }); }; } } } }