From bba578c2f0acf2eca747edcb69426771e0cadd32 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 18:20:50 +0800
Subject: [PATCH] 2020-03-23-3

---
 ZigbeeApp/Shared/Phone/MainPage/Controls/SceneCardControl.cs |   91 ++++++++++++++++++++++++++-------------------
 1 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/Controls/SceneCardControl.cs b/ZigbeeApp/Shared/Phone/MainPage/Controls/SceneCardControl.cs
index def39fb..7290a4b 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/Controls/SceneCardControl.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/Controls/SceneCardControl.cs
@@ -59,8 +59,6 @@
 
             this.ButtonClickEvent += (sender, e) =>
             {
-                //寮�鍚疞oading鐗规晥
-                this.StartLoadingApreal();
                 //璋冪敤鍦烘櫙
                 this.SetSceneAction();
             };
@@ -73,6 +71,9 @@
         public void InitControl(Common.SceneUI i_scene)
         {
             this.SceneId = i_scene.Id;
+            string hourText = Language.StringByID(R.MyInternationalizationString.Hour);
+            string minuText = Language.StringByID(R.MyInternationalizationString.Minute);
+            string secondText = Language.StringByID(R.MyInternationalizationString.Second);
 
             //鍦烘櫙鍥剧墖鎺т欢
             this.btnScenePic = new ImageView();
@@ -93,6 +94,10 @@
             btnTimeView.Y = Application.GetMinRealAverage(10);
             btnTimeView.TextColor = 0xffffb400;
             btnTimeView.IsBold = true;
+            if (i_scene.SceneDelayTime > 0)
+            {
+                btnTimeView.Text= this.GetTimeString(i_scene.SceneDelayTime, hourText, minuText, secondText);
+            }
             this.AddChidren(btnTimeView, ChidrenBindMode.BindEventOnly);
 
             //鏃堕棿鍥炬爣鎺т欢
@@ -100,7 +105,34 @@
             btnTimeIcon.X = Application.GetMinRealAverage(37);
             btnTimeIcon.Y = Application.GetMinRealAverage(20);
             btnTimeIcon.UnSelectedImagePath = "Item/Time.png";
-            this.AddChidren(btnTimeIcon, ChidrenBindMode.BindEventOnly);
+            this.AddChidren(btnTimeIcon, ChidrenBindMode.NotBind);
+            if (i_scene.SceneDelayTime > 0)
+            {
+                btnTimeIcon.Visible = false;
+            }
+            btnTimeIcon.ButtonClickEvent += (sender, e) =>
+            {
+                if (i_scene.RemainTime > 0)
+                {
+                    //璇ュ満鏅鍦ㄥ欢鏃讹紝璇风◢鍚�
+                    var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
+                    msgContr.Show();
+                    return;
+                }
+                var timeSelect = new Device.CommonForm.SelectTime();
+                Common.CommonPage.Instance.AddChidren(timeSelect);
+                timeSelect.TempTime = i_scene.SceneDelayTime;
+                timeSelect.Init();
+                timeSelect.TimeAction = (time) =>
+                {
+                    i_scene.SceneDelayTime = time;
+
+                   //鏃堕棿鍥炬爣涓嶆樉绀�
+                   this.btnTimeIcon.Visible = false;
+                   //鏄剧ず鍓╀綑鐨勬椂闂�
+                   this.btnTimeView.Text = this.GetTimeString(time, hourText, minuText, secondText);
+                };
+            };
 
             //鏀惰棌鎺т欢
             var btnCollect = new IconViewControl(107);
@@ -154,38 +186,22 @@
         {
             //杩欎釜鍦烘櫙涓嶈鐨勬儏鍐靛簲璇ヤ笉鍙兘
             var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(this.SceneId);
-            if (scene.RemainTime > 0 )
+            if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0)
             {
-                //璇ュ満鏅鍦ㄥ欢鏃讹紝璇风◢鍚�
-                var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
-                msgContr.Show();
-                return;
+                //濡傛灉娌℃湁寤惰繜鐨勮瘽,鐩存帴寮�鍚疞oading鐗规晥
+                this.StartLoadingApreal();
             }
             //鎵ц璋冪敤鍦烘櫙
-            var result = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime);
-            if (result == null || result.sceneOpenData == null)
+            var result = await HdlSceneLogic.Current.ControlScene(scene);
+            if (result == false)
             {
-                //鎺у埗鍦烘櫙澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.ControlSceneFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-                var msgContr = new ShowMsgControl(ShowMsgType.Tip, msg);
-                msgContr.Show();
-                return;
-            }
-            if (result.sceneOpenData.Result == 0)
-            {
-                //鎺у埗鍦烘櫙澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.ControlSceneFail);
-                var msgContr = new ShowMsgControl(ShowMsgType.Tip, msg);
-                msgContr.Show();
                 return;
             }
             //淇敼鏃堕棿
             scene.RemainTime = scene.SceneDelayTime;
             scene.SceneDelayTime = 0;
             //寮�鍚欢鏃跺�掕鏃剁壒鏁�
-            this.StartRemainTimeApreal(scene, true);
+            this.StartRemainTimeApreal(scene);
         }
 
         #endregion
@@ -218,7 +234,7 @@
             }
 
             //寮�鍚欢鏃跺�掕鏃剁壒鏁�
-            this.StartRemainTimeApreal(i_scene, false);
+            this.StartRemainTimeApreal(i_scene);
         }
 
         #endregion
@@ -229,8 +245,7 @@
         /// 寮�鍚欢鏃跺�掕鏃剁壒鏁�
         /// </summary>
         /// <param name="i_scene"></param>
-        /// <param name="setTime">鏄惁鏇存敼鍦烘櫙瀵硅薄閲岄潰鐨勯偅涓椂闂�,鏃ㄥ湪瀵瑰簲鍚屼竴涓満鏅湪澶氫釜鍦版柟鏄剧ず鐨勫悓姝ラ棶棰�</param>
-        private void StartRemainTimeApreal(Common.SceneUI i_scene, bool setTime)
+        private void StartRemainTimeApreal(Common.SceneUI i_scene)
         {
             if (i_scene.RemainTime <= 0)
             {
@@ -246,29 +261,27 @@
             //鏄剧ず鍓╀綑鐨勬椂闂�
             this.btnTimeView.Text = this.GetTimeString(i_scene.RemainTime, hourText, minuText, secondText);
 
+            //寮�鍚唴閮ㄥ欢鏃舵椂闂寸嚎绋�(鏃ㄥ湪鍏ㄩ儴鍦版柟鐨勫悓涓�鍦烘櫙鏃堕棿鍚屾)
+            HdlSceneLogic.Current.StartDelayTimeThread(i_scene);
+
             new System.Threading.Thread(() =>
             {
-                while (remainTine > 0)
+                while (remainTine > 0 && this.Parent != null)
                 {
                     System.Threading.Thread.Sleep(1000);
                     Application.RunOnMainThread(() =>
                     {
                         this.btnTimeView.Text = this.GetTimeString(remainTine, hourText, minuText, secondText);
                     });
-                    if (setTime == true)
-                    {
-                        //瑕嗙洊鍓╀綑鏃堕棿
-                        i_scene.RemainTime = remainTine;
-                    }
+                    remainTine--;
                 }
                 Application.RunOnMainThread(() =>
                 {
-                    //鏃犳潯浠惰鐩栧墿浣欐椂闂�
-                    i_scene.RemainTime = 0;
-
                     //鍊掕鏃剁粨鏉熸椂锛屾椂闂村浘鏍囨樉绀�
                     this.btnTimeIcon.Visible = true;
                     this.btnTimeView.Text = string.Empty;
+                    //鐩存帴寮�鍚疞oading鐗规晥
+                    this.StartLoadingApreal();
                 });
             })
             { IsBackground = true }.Start();
@@ -291,7 +304,7 @@
             var loadContr = new MyProgressLoading();
             loadContr.LoadingBackgroundColor = UserCenterColor.Current.Transparent;
             frameBack.AddChidren(loadContr);
-            loadContr.StartLoading();
+            loadContr.StartLoading(1000);
             loadContr.DisponeEvent += () =>
             {
                 frameBack.RemoveFromParent();
@@ -330,7 +343,7 @@
             int hour = second / 3600;
             int minu = second % 3600 / 60;
             int sec = second % 60;
-            if (hour >= 0)
+            if (hour > 0)
             {
                 timeStr += hour + hourText;
             }

--
Gitblit v1.8.0