From f500e14c0a994487070380c50c85e0929cbc8e63 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 05 一月 2021 10:48:04 +0800 Subject: [PATCH] 2021-01-05 1.更新 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs | 121 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 110 insertions(+), 11 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs index 0ea98e1..82dc84f 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs @@ -265,7 +265,7 @@ uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, DeviceName = device.Name, DeviceType = "CurtainModule", LoopId = device.LoopID, - DataString = device.Status.ToString () + DataString = ((byte)device.Status).ToString () }); } } else if (common.Type == DeviceType.CurtainRoller) { @@ -274,7 +274,7 @@ uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, DeviceName = device.Name, DeviceType = "CurtainRoller", LoopId = device.LoopID, - DataString = (device.Status + 3).ToString () + DataString = ((byte)device.CurtainProress + 3).ToString () }); } } else if (common.Type == DeviceType.CurtainTrietex) { @@ -283,7 +283,7 @@ uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, DeviceName = device.Name, DeviceType = "CurtainRoller", LoopId = device.LoopID, - DataString = (device.Status + 3).ToString () + DataString = ((byte)device.CurtainProress + 3).ToString () }); } } else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared) { @@ -317,6 +317,15 @@ Command = (int)Command.SetScene, SubnetId = device.SubnetID, DeviceId = device.DeviceID, DeviceName = device.Name, DeviceType = "SceneControl", LoopId = device.AreaID, DataString = device.AreaSceneID.ToString () + }); + } + } else if (common.Type == DeviceType.UniversalDevice) {//2020-09-02 鏂板閫氱敤寮�鍏� + var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); + if (device != null) { + uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { + Command = (int)Command.SetCommonSwitch, SubnetId = device.SubnetID, DeviceId = device.DeviceID, + DeviceName = device.Name, DeviceType = "UniversalDevice", LoopId = device.LoopID, + DataString = device.SendBytes[1].ToString(), }); } } @@ -414,6 +423,7 @@ } } + alexaDeviceLista = ReadDeviceList (); Application.RunOnMainThread (() => { @@ -717,11 +727,53 @@ #endregion /// <summary> + /// + /// </summary> + /// <param name="bodyView"></param> + /// <param name="isScene"></param> + void AddTopTitleView (VerticalScrolViewLayout bodyView, bool isScene = false) { + var chooseTypeView = new RowLayout () { + Height = Application.GetRealHeight (80), + BackgroundColor = SkinStyle.Current.TitileView, + }; + bodyView.AddChidren (chooseTypeView); + Button btnEquipmentIcon = new Button () { + Width = Application.GetRealHeight (65), + Height = Application.GetRealHeight (65), + UnSelectedImagePath = "Item/LogicModule.png", + X = Application.GetRealWidth (30), + Gravity = Gravity.CenterVertical, + }; + chooseTypeView.AddChidren (btnEquipmentIcon); + + Button btnEquipmentType = new Button () { + Width = Application.GetRealHeight (460), + X = btnEquipmentIcon.Right, + TextAlignment = TextAlignment.CenterLeft, + Text = Language.StringByID (R.MyInternationalizationString.Device), + TextColor = SkinStyle.Current.TextColor1, + SelectedTextColor = SkinStyle.Current.DialogTextColor + }; + chooseTypeView.AddChidren (btnEquipmentType); + + if (isScene) { + btnEquipmentIcon.UnSelectedImagePath = "Scene/Scene.png"; + btnEquipmentType.Text = Language.StringByID (R.MyInternationalizationString.Scenes); + } + } + + /// <summary> /// 娣诲姞璁惧鐣岄潰 /// </summary> public void InitDevcieRow (List<UpdateDeviceObj> list, VerticalScrolViewLayout bodyView) { bodyView.RemoveAll (); + + if (list.Count > 0) { + //娣诲姞鏍囬 + AddTopTitleView (bodyView); + } + foreach (var device in list) { var rowView = new RowLayout () { Height = Application.GetRealHeight (110), @@ -747,10 +799,31 @@ alert.Show (); alert.ResultEventHandler += (s, dd) => { if (dd) { - if (DelDevice (device.Id)) { - rowView.RemoveFromParent (); - list.Remove (device); - } + //if (DelDevice (device.Id)) { + // rowView.RemoveFromParent (); + // list.Remove (device); + //} + + System.Threading.Tasks.Task.Run (() => { + Application.RunOnMainThread (() => { + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + }); + try { + var result = DelDevice (device.Id); + Application.RunOnMainThread (() => { + if (result) { + rowView.RemoveFromParent (); + list.Remove (device); + } + }); + + } catch { } finally { + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); } }; }; @@ -762,6 +835,11 @@ /// </summary> public void InitSceneRow (List<SceneByRegion> list, VerticalScrolViewLayout bodyView) { + if (list.Count > 0) { + //娣诲姞鏍囬 + AddTopTitleView (bodyView, true); + } + foreach (var scene in list) { var rowView = new RowLayout () { Height = Application.GetRealHeight (110), @@ -793,10 +871,31 @@ alert.Show (); alert.ResultEventHandler += (s, dd) => { if (dd) { - if (DelScene (scene.SceneId)) { - rowView.RemoveFromParent (); - list.Remove (scene); - } + //if (DelScene (scene.SceneId)) { + // rowView.RemoveFromParent (); + // list.Remove (scene); + //} + + System.Threading.Tasks.Task.Run (() => { + Application.RunOnMainThread (() => { + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + }); + try { + var result = DelScene (scene.SceneId); + Application.RunOnMainThread (() => { + if (result) { + rowView.RemoveFromParent (); + list.Remove (scene); + } + }); + + } catch { } finally { + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); } }; }; -- Gitblit v1.8.0