JLChen
2020-02-20 965290476c027deb96891cde1095d9a100581a6b
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;
@@ -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) {
                                    Application.RunOnMainThread (() => {
                                        string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure);
                                        var btnTip = new Button () {
                                            Height = Application.GetRealHeight (140),
@@ -450,6 +459,7 @@
                                        MainPage.MainFrameLayout.AddChidren (btnTip);
                                        btnTip.MouseUpEventHandler += (sender, e) => {
                                            btnTip.RemoveFromParent ();
                                            showTip = false;
                                            //MainPage.MainFrameLayout.Remove (btnTip);
                                        };
                                        System.Threading.Tasks.Task.Run (() => {
@@ -457,13 +467,14 @@
                                            Application.RunOnMainThread (() => {
                                            btnTip.RemoveFromParent ();
                                                //MainPage.MainFrameLayout.Remove (btnTip);
                                                showTip = false;
                                                //showTip = false;
                                            });
                                            });
                                        });
                                    }
                                }
                            } catch { }
                        });
                    }
                } else {
                    foreach (var common in tempScene.GlobalSceneDeviceList) {
@@ -517,6 +528,10 @@
                        }
                    }
                }
                Application.RunOnMainThread (() => {
                    MainPage.Loading.Hide ();
                });
            });
        }