From 965290476c027deb96891cde1095d9a100581a6b Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 20 二月 2020 09:13:32 +0800 Subject: [PATCH] 2020-02-20 1.优化更新。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs | 35 +++++++++++++++++++++++++---------- 1 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs index 39d63af..1ce1687 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs @@ -335,10 +335,18 @@ public void ControlScene (string sceneFilePath) { + if (CommonPage.IsRemote) { + if (!SmartHome.MqttCommon.IsGatewayOnline) { + new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); + return; + } + } var tempScene = Scene.GetSceneByFilePath (sceneFilePath); if (tempScene == null) return; showTip = true; + MainPage.Loading.Start ("Sending..."); + System.Threading.Tasks.Task.Run (() => { int sceneDeviceCount = tempScene.DeviceFilePathList.Count; int controlDeviceIndex = 0; @@ -371,7 +379,7 @@ replyBytes = Control.ControlBytesSendHasReturn (Command.SetLogicLoopColor, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 254, device.DelayTimeHeigh,device.DelayTimeLow, 3,device.RStatus,device.GStatus,device.BStatus,0,0}); } - } else if (common.Type == DeviceType.LightSwitch ) { + } else if (common.Type == DeviceType.LightSwitch) { var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); if (device == null) { continue; @@ -437,10 +445,11 @@ replyBytes = Control.ControlBytesSendHasReturn (Command.SetScene, device.SubnetID, device.DeviceID, new byte [] { device.AreaID,device.AreaSceneID}); } - Application.RunOnMainThread (() => { - try { - if (showTip) { - if (replyBytes == null) { + + try { + if (showTip) { + if (replyBytes == null) { + Application.RunOnMainThread (() => { string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); var btnTip = new Button () { Height = Application.GetRealHeight (140), @@ -450,20 +459,22 @@ MainPage.MainFrameLayout.AddChidren (btnTip); btnTip.MouseUpEventHandler += (sender, e) => { btnTip.RemoveFromParent (); + showTip = false; //MainPage.MainFrameLayout.Remove (btnTip); }; System.Threading.Tasks.Task.Run (() => { System.Threading.Thread.Sleep (3000); Application.RunOnMainThread (() => { - btnTip.RemoveFromParent (); + btnTip.RemoveFromParent (); //MainPage.MainFrameLayout.Remove (btnTip); - showTip = false; + //showTip = false; }); }); - } + }); } - } catch { } - }); + } + } catch { } + } } else { foreach (var common in tempScene.GlobalSceneDeviceList) { @@ -517,6 +528,10 @@ } } } + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); }); } -- Gitblit v1.8.0