From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs |  795 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 438 insertions(+), 357 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs
index 28e2981..c793d2b 100755
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs
@@ -1,357 +1,438 @@
-锘縰sing System;
-using Shared.Common;
-namespace Shared.Phone.Device.CommonForm
-{
-    public class SceneCategoryView : FrameLayout
-    {
-        /// <summary>
-        /// scene
-        /// </summary>
-        public SceneUI scene;
-        /// <summary>
-        /// room
-        /// </summary>
-        public Shared.Common.Room room;
-        /// <summary>
-        /// delayTimeBtn
-        /// </summary>
-        private Button delayTimeBtn;
-        /// <summary>
-        /// delayImgBtn
-        /// </summary>
-        private Button delayImgBtn;
-        /// <summary>
-        /// sceneImg
-        /// </summary>
-        private Button sceneImg;
-
-        /// <summary>
-        /// SceneCategoryView
-        /// </summary>
-        /// <param name="x"></param>
-        /// <param name="y"></param>
-        public SceneCategoryView(int x, int y)
-        {
-            X = Application.GetRealWidth(x);
-            Y = Application.GetRealHeight(y);
-            Width = Application.GetRealWidth(1080);
-            Height = Application.GetRealHeight(446);
-            BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
-        }
-
-        /// <summary>
-        /// init
-        /// </summary>
-        public void Init(SceneUI sceneUI,Common.Room curRoom)
-        {
-            this.scene = sceneUI;
-            this.room = curRoom;
-
-            InitFrame();
-            InitStatu();
-        }
-
-        /// <summary>
-        /// InitFrame
-        /// </summary>
-        private void InitFrame()
-        {
-            var sceneRowLayout = new RowLayout
-            {
-                Y = Application.GetRealHeight(46),
-                Height = Application.GetRealHeight(446 - 46),
-                LineColor = ZigbeeColor.Current.GXCGrayBackgroundColor
-            };
-            AddChidren(sceneRowLayout);
-
-            sceneImg = new Button()
-            {
-                X = Application.GetRealWidth(179),
-                Width = Application.GetRealWidth(844),
-                Height = Application.GetRealHeight(400),
-                UnSelectedImagePath = scene.IconPath,
-                Radius = (uint)Application.GetRealHeight(17)
-            };
-            sceneRowLayout.AddChidren(sceneImg);
-
-            var leftFL = new FrameLayout
-            {
-                X = Application.GetRealWidth(CommonFormResouce.X_Left),
-                Y = Application.GetRealHeight(58),
-                Width = Application.GetRealWidth(251),
-                Height = Application.GetRealHeight(282),
-                BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2,
-                Radius = (uint)Application.GetRealHeight(17)
-            };
-            sceneRowLayout.AddChidren(leftFL);
-
-            var collectionBtn = new Button
-            {
-                X = Application.GetRealWidth(23),
-                Y = Application.GetRealHeight(23),
-                Width = Application.GetMinRealAverage(65),
-                Height = Application.GetMinRealAverage(65),
-                UnSelectedImagePath = "Item/Collection.png",
-                SelectedImagePath = "Item/CollectionSelected.png",
-                IsSelected = Common.Room.CurrentRoom.GetLoveRoom().SceneUIFilePathList.Contains(scene.FileName),
-                Tag = scene
-            };
-            leftFL.AddChidren(collectionBtn);
-
-            var sceneNameBtn = new Button()
-            {
-                Width = Application.GetRealWidth(176),
-                Height = Application.GetRealHeight(150),
-                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
-                Text = scene.Name,
-                Gravity = Gravity.Center,
-                IsMoreLines = true
-            };
-            leftFL.AddChidren(sceneNameBtn);
-
-            var collection = new Button
-            {
-                Tag = scene
-            };
-            leftFL.AddChidren(collection);
-            collection.MouseUpEventHandler += (sender, e) =>
-            {
-                if (room.IsLove)
-                {
-                    Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene);
-                    RemoveViewByTag(collectionBtn.Tag);
-                }
-                else
-                {
-                    collectionBtn.IsSelected = !collectionBtn.IsSelected;
-                    if (collectionBtn.IsSelected)
-                    {
-                        Common.Room.CurrentRoom.GetLoveRoom().AddScene(scene);
-                    }
-                    else
-                    {
-                        Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene);
-                    }
-                }
-            };
-
-            delayTimeBtn = new Button
-            {
-                X = Application.GetRealWidth(780),
-                Y = Application.GetRealHeight(317),
-                Width = Application.GetRealWidth(200),
-                Height = Application.GetRealHeight(58),
-                Text = CommonFormResouce.GetTimeString(scene.SceneDelayTime),
-                TextAlignment = TextAlignment.CenterRight,
-                TextColor = ZigbeeColor.Current.GXCTextSelectedColor3
-            };
-            sceneRowLayout.AddChidren(delayTimeBtn);
-
-            delayImgBtn = new Button
-            {
-                X = Application.GetRealWidth(900),
-                Y = Application.GetRealHeight(30),
-                Width = Application.GetMinRealAverage(52),
-                Height = Application.GetMinRealAverage(52),
-                UnSelectedImagePath = "Scene/Delaying.png",
-                Visible=false
-            };
-            sceneRowLayout.AddChidren(delayImgBtn);
-
-            //瀹氭椂
-            var delayBtn = new RowLayoutDeleteButton
-            {
-                TextID = R.MyInternationalizationString.Delay,
-                Tag = scene.SceneDelayTime
-            };
-            sceneRowLayout.AddLeftView(delayBtn);
-            //缂栬緫
-            var settingBtn = new Device.CommonForm.RowLayoutEditButton()
-            {
-                TextID = R.MyInternationalizationString.Editor,
-                Tag = scene.SceneDelayTime
-            };
-            //鍒犻櫎
-            var deleteBtn = new Device.CommonForm.RowLayoutDeleteButton
-            {
-                Tag = scene
-            };
-
-            if (room.IsSharedRoom)
-            {
-
-            }
-            else
-            {
-                if (room.IsLove)
-                {
-                    sceneRowLayout.AddRightView(deleteBtn);
-                }
-                else
-                {
-                    sceneRowLayout.AddRightView(settingBtn);
-                    sceneRowLayout.AddRightView(deleteBtn);
-                }
-            }
-
-            //鍒犻櫎鍦烘櫙
-            EventHandler<MouseEventArgs> delEvent = (sender, e) =>
-            {
-                if (room.IsLove)
-                {
-                    Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene);
-                    RemoveViewByTag((sender as Button).Tag);
-                }
-                else
-                {
-                    var tip = new CustomAlert { };
-                    AddChidren(tip);
-                    tip.Show(Language.StringByID(R.MyInternationalizationString.ConfirmDelete));
-
-                    tip.ResultEventHandler += async (e1) =>
-                    {
-                        if (e1)
-                        {
-                            //0 绉婚櫎澶辫触 1 绉婚櫎鎴愬姛 2 娌℃湁璇ュ満鏅�
-                            var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id);
-                            if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null)
-                            {
-                                CommonPage.Instance.FailureToServer();
-                                return;
-                            }
-                            //1鎴愬姛
-                            if (removeSceneAllData.removeSceneData.Result == 1)
-                            {
-                                room.RemoveScene(scene);
-                                //RefreshBodyView();
-                                RemoveViewByTag((sender as Button).Tag);
-                            }
-                            //0 绉婚櫎澶辫触
-                            else if (removeSceneAllData.removeSceneData.Result == 0)
-                            {
-                                CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
-                                return;
-                            }
-                            //2 娌℃湁璇ュ満鏅�
-                            else if (removeSceneAllData.removeSceneData.Result == 2)
-                            {
-                                room.RemoveScene(scene);
-                                //RefreshBodyView();
-                                RemoveViewByTag((sender as Button).Tag);
-                                CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneIsNull);
-                                return;
-                            }
-                        }
-                    };
-                }
-            };
-            deleteBtn.MouseUpEventHandler += delEvent;
-            //缂栬緫鍦烘櫙
-            settingBtn.MouseUpEventHandler += (sender, e) =>
-            {
-                SceneUI.EditScene(scene, room);
-            };
-            //缂栬緫寤舵椂
-            delayBtn.MouseUpEventHandler += (sender, e) =>
-            {
-                if (scene.RemainTime > 0)
-                {
-                    CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
-                    return;
-                }
-                var timeSelect = new SelectTime();
-                CommonPage.Instance.AddChidren(timeSelect);
-                timeSelect.TempTime = scene.SceneDelayTime;
-                timeSelect.Init();
-                timeSelect.TimeAction = (t) =>
-                {
-                    scene.SceneDelayTime = t;
-                    delayTimeBtn.Text = CommonFormResouce.GetTimeString(t);
-                };
-            };
-        }
-
-        /// <summary>
-        /// InitStatu
-        /// </summary>
-        private void InitStatu()
-        {
-            sceneImg.MouseUpEventHandler += SceneUpHandler;
-        }
-
-        /// <summary>
-        /// SceneUpHandler
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="args"></param>
-        private async void SceneUpHandler(object sender, MouseEventArgs args)
-        {
-            if (scene.RemainTime > 0 && scene.SceneDelayTime == 0)
-            {
-                CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
-                return;
-            }
-            //1鎴愬姛 0澶辫触
-            //鍚庨潰琛ヤ笂鐩稿叧鎻愮ず
-            // Error鍙傛暟鍚箟
-            //<para>1锛氱綉鍏虫棤娉曡В鏋愬懡浠ゆ暟鎹��</para>
-            //<para>2锛氬崗璋冨櫒姝e湪鍗囩骇鎴栧浠�/鎭㈠鏁版嵁
-            //<para>3锛氭搷浣滆澶�/缁�/鍦烘櫙涓嶅瓨鍦�</para>
-            //<para>4锛氬叾浠栭敊璇�</para>
-            //<para>5锛氭暟鎹紶杈撻敊璇紙鍦ㄦ煇娆″鎴风鍚戠綉鍏冲彂閫佹暟鎹殑杩囩▼涓紝缃戝叧鍦ㄥ悎鐞嗘椂闂磋寖鍥村唴鎺ユ敹瀹㈡埛绔暟鎹笉瀹屾暣瀵艰嚧璇ラ敊璇彂鐢熴�傚瀹㈡埛绔悜缃戝叧涓�娆″彂閫�100涓瓧鑺傜殑鏁版嵁锛屼絾缃戝叧绛夊緟鎺ユ敹浜嗕竴绉掑彧鎺ユ敹浜�80涓瓧鑺傘�傚彂鐢熻閿欒锛岀綉鍏冲皢涓诲姩鍏抽棴瀹㈡埛绔繛鎺ワ級</para>
-            var sceneOpenAllData = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime);
-
-            if (sceneOpenAllData == null || sceneOpenAllData.sceneOpenData == null)
-            {
-                return;
-            }
-            if (sceneOpenAllData.sceneOpenData.Result == 0)
-            {
-                if (sceneOpenAllData.errorResponData == null)
-                {
-                    return;
-                }
-                CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ControlSceneFail);
-            }
-
-            scene.RemainTime = scene.SceneDelayTime;
-            scene.SceneDelayTime = 0;
-            new System.Threading.Thread(() =>
-            {
-                while (scene.RemainTime > 0)
-                {
-                    System.Threading.Thread.Sleep(1000);
-                    Application.RunOnMainThread(() =>
-                    {
-                        SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime));
-                    });
-                    scene.RemainTime -= 1;
-                }
-                Application.RunOnMainThread(() =>
-                {
-                    SetTimeImage();
-                });
-            })
-            { IsBackground = true }.Start();
-        }
-
-        /// <summary>
-        /// SetTimeText
-        /// </summary>
-        /// <param name="name"></param>
-        public void SetTimeText(string name)
-        {
-            delayImgBtn.Visible = true;
-            delayTimeBtn.Text = name;
-        }
-
-        /// <summary>
-        /// SetTimeImage
-        /// </summary>
-        public void SetTimeImage()
-        {
-            delayImgBtn.Visible = false;
-            delayTimeBtn.Text = string.Empty;
-        }
-    }
-}
+锘縰sing System;
+using System.Collections.Generic;
+using Shared.Common;
+using Shared.Phone.UserCenter;
+
+namespace Shared.Phone.Device.CommonForm
+{
+    public class SceneCategoryView : RowLayoutBase
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// scene
+        /// </summary>
+        public SceneUI scene;
+        /// <summary>
+        /// room
+        /// </summary>
+        private Common.Room room;
+        /// <summary>
+        /// 寤舵椂鏃堕棿
+        /// </summary>
+        private NormalViewControl btnDelayTime;
+        /// <summary>
+        /// 寤舵椂鍥炬爣
+        /// </summary>
+        private IconViewControl btnDelayIcon;
+        /// <summary>
+        /// 鍦烘櫙鍥剧墖鎺т欢
+        /// </summary>
+        private ScenePictrueControl sceneContr = null;
+        /// <summary>
+        /// 鏄惁宸茬粡瀹屾垚鎺т欢鍒濆鍖栫粨鏉�
+        /// </summary>
+        private bool isInitControlFinish = false;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// SceneCategoryView
+        /// </summary>
+        public SceneCategoryView()
+        {
+            this.Width = Application.GetRealWidth(1080);
+            this.Height = Application.GetRealHeight(397 + 46);
+            this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
+            this.IsUseSameSubViewWidth = false;
+        }
+
+        /// <summary>
+        /// 鍒濆鍖�
+        /// </summary>
+        /// <param name="i_scene"></param>
+        public void InitControl(SceneUI i_scene, Common.Room i_room)
+        {
+            this.RemoveAll();
+
+            this.LineColor = UserCenterColor.Current.Transparent;
+
+            this.scene = i_scene;
+            this.room = i_room;
+
+            //鑷畾涔夌殑鍦烘櫙鍥剧墖鎺т欢
+            this.sceneContr = new ScenePictrueControl();
+            this.AddChidren(sceneContr);
+            sceneContr.InitControl(this.scene);
+
+            //鍦烘櫙鐐瑰嚮
+            sceneContr.ButtonClickEvent += (sender, e) =>
+            {
+                //涓嶈兘鍙嶅鐐瑰嚮
+                sceneContr.CanClick = false;
+                this.SceneUpHandler(sceneContr);
+            };
+
+            //鏀惰棌
+            sceneContr.AddCollectionControl();
+            sceneContr.CollectEvent += (collect) =>
+            {
+                if (room.IsLove)
+                {
+                    this.RemoveFromParent();
+                }
+            };
+            
+            //寤舵椂鏃堕棿
+            this.btnDelayTime = new NormalViewControl(400, 58, true);
+            btnDelayTime.X = Application.GetRealWidth(580);
+            btnDelayTime.Y = Application.GetRealHeight(317);
+            btnDelayTime.Text = this.GetTimeString(scene.SceneDelayTime);
+            btnDelayTime.TextAlignment = TextAlignment.CenterRight;
+            btnDelayTime.TextColor = ZigbeeColor.Current.GXCTextSelectedColor3;
+            btnDelayTime.IsBold = true;
+            this.AddChidren(btnDelayTime);
+
+            //寤舵椂鍥炬爣
+            this.btnDelayIcon = new IconViewControl(52);
+            btnDelayIcon.X = Application.GetRealWidth(900);
+            btnDelayIcon.Y = Application.GetRealHeight(30);
+            btnDelayIcon.Width = this.GetPictrueRealSize(52);
+            btnDelayIcon.Height = this.GetPictrueRealSize(52);
+            btnDelayIcon.UnSelectedImagePath = "Scene/Delaying.png";
+            this.AddChidren(btnDelayIcon);
+            btnDelayIcon.Visible = false;
+
+            if (isInitControlFinish == true)
+            {
+                //缂栬緫鍦烘櫙鐨勫洖璋冨嚱鏁颁細閲嶆柊鍒锋柊鎺т欢
+                //鎵�浠ヨ繖閲屼笉鍐嶅垵濮嬪寲
+                return;
+            }
+            this.isInitControlFinish = true;
+
+            //娣诲姞宸﹁竟鐨勭┖鐧藉尯鍩�
+            var btnTemp1 = new NormalViewControl(Application.GetRealWidth(58), sceneContr.btnScenePic.Height, false);
+            this.AddLeftView(btnTemp1);
+            //瀹氭椂
+            var btnDelay = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
+            btnDelay.BackgroundColor = ZigbeeColor.Current.GXCTextSelectedColor;
+            btnDelay.TextID = R.MyInternationalizationString.Delay;
+            btnDelay.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+            btnDelay.TextAlignment = TextAlignment.Center;
+            btnDelay.Tag = scene.SceneDelayTime;
+            btnDelay.Radius = (uint)Application.GetRealHeight(17);
+            btnDelay.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight |
+                HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
+            this.AddLeftView(btnDelay);
+            //鍙樻洿鎸夐挳鐨勯珮搴�
+            btnDelay.Height = sceneContr.btnScenePic.Height;
+            btnDelay.Y = 0;
+
+            //缂栬緫
+            var btnEditor = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
+            btnEditor.BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor;
+            btnEditor.TextID = R.MyInternationalizationString.Edit;
+            btnEditor.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+            btnEditor.TextAlignment = TextAlignment.Center;
+            btnEditor.Tag = scene.SceneDelayTime;
+            btnEditor.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerTopLeft);
+
+            //鍒犻櫎
+            var btnDelete = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
+            btnDelete.Tag = scene;
+            btnDelete.BackgroundColor = ZigbeeColor.Current.GXCRedColor;
+            btnDelete.TextID = R.MyInternationalizationString.Delete;
+            btnDelete.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+            btnDelete.TextAlignment = TextAlignment.Center;
+            btnDelete.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
+
+            if (room.IsSharedRoom == false && room.IsLove == false)
+            {
+                //涓嶆槸鍒嗕韩,骞朵笖涓嶆槸鏀惰棌
+                this.AddRightView(btnEditor);
+                this.AddRightView(btnDelete);
+                //鍙樻洿鎸夐挳鐨勯珮搴�
+                btnEditor.Height = sceneContr.btnScenePic.Height;
+                btnEditor.Y = 0;
+                btnDelete.Height = sceneContr.btnScenePic.Height;
+                btnDelete.Y = 0;
+                //娣诲姞鍙宠竟绌虹櫧鍖哄煙
+                var btnTemp2 = new NormalViewControl(Application.GetRealWidth(58), sceneContr.btnScenePic.Height, false);
+                this.AddRightView(btnTemp2);
+            }
+
+            //鍒犻櫎鍦烘櫙
+            btnDelete.ButtonClickEvent += (sender, e) =>
+            {
+                var alert = new ShowMsgControl(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.ConfirmDelete));
+                alert.Show();
+                alert.ConfirmClickEvent += async () =>
+                {
+                    //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+                    if (Common.Config.Instance.Home.IsVirtually == true)
+                    {
+                        //绉婚櫎缂撳瓨
+                        HdlSceneLogic.Current.DeleteLocalScene(scene);
+                        RemoveFromParent();
+                        return;
+                    }
+                    //0 绉婚櫎澶辫触 1 绉婚櫎鎴愬姛 2 娌℃湁璇ュ満鏅�
+                    var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id);
+                    if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null)
+                    {
+                        HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.RequestServerFailed));
+                        return;
+                    }
+                    //1鎴愬姛
+                    if (removeSceneAllData.removeSceneData.Result == 1)
+                    {
+                        HdlSceneLogic.Current.DeleteLocalScene(scene);
+                        RemoveFromParent();
+                    }
+                    //0 绉婚櫎澶辫触
+                    else if (removeSceneAllData.removeSceneData.Result == 0)
+                    {
+                        HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain));
+                        return;
+                    }
+                    //2 娌℃湁璇ュ満鏅�
+                    else if (removeSceneAllData.removeSceneData.Result == 2)
+                    {
+                        HdlSceneLogic.Current.DeleteLocalScene(scene);
+                        RemoveFromParent();
+                        return;
+                    }
+                };
+            };
+
+            //缂栬緫鍦烘櫙
+            btnEditor.ButtonClickEvent += (sender, e) =>
+            {
+                //鍏抽棴宸︽粦鑿滃崟
+                this.HideMenu();
+                //缂栬緫鍦烘櫙
+                var form = new Phone.Category.AddOrEditorSceneForm();
+                form.AddForm(i_scene);
+                form.SceneChangedEvent = (myScene, roomId) =>
+                {
+                    if (roomId != room.Id)
+                    {
+                        //瀹冨彉鏇翠簡鎴块棿
+                        this.RemoveFromParent();
+                    }
+                    else
+                    {
+                        this.InitControl(myScene, room);
+                    }
+                };
+            };
+            //缂栬緫寤舵椂
+            btnDelay.ButtonClickEvent += (sender, e) =>
+            {
+                if (scene.RemainTime > 0)
+                {
+                    HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
+                    return;
+                }
+                var timeSelect = new SelectTime();
+                CommonPage.Instance.AddChidren(timeSelect);
+                timeSelect.TempTime = scene.SceneDelayTime;
+                timeSelect.Init();
+                timeSelect.TimeAction = (t) =>
+                {
+                    //闅愯棌鍙冲垝鑿滃崟
+                    this.HideMenu();
+                    if (t != 0)
+                    {
+                        scene.SceneDelayTime = t;
+                        btnDelayTime.Text = this.GetTimeString(t);
+                        //缂栬緫寤舵椂鏃�,闇�瑕佸埛鏂颁富椤�
+                        UserView.UserPage.Instance.RefreshAllForm = true;
+                    }
+                };
+            };
+        }
+
+        #endregion
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="sceneContr"></param>
+        private async void SceneUpHandler(ScenePictrueControl sceneContr)
+        {
+            if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0)
+            {
+                //濡傛灉娌℃湁寤惰繜鐨勮瘽,鐩存帴寮�鍚疞oading鐗规晥
+                this.StartLoadingApreal();
+            }
+            //璋冪敤鍦烘櫙
+            var result = await HdlSceneLogic.Current.ControlScene(scene);
+            if (result == false)
+            {
+                sceneContr.CanClick = true;
+                return;
+            }
+            
+            scene.RemainTime = scene.SceneDelayTime;
+            scene.SceneDelayTime = 0;
+            if (scene.RemainTime <= 0)
+            {
+                sceneContr.CanClick = true;
+                return;
+            }
+            //璋冪敤鏈夊欢鏃剁殑鍦烘櫙,闇�瑕佸埛鏂颁富椤�
+            UserView.UserPage.Instance.RefreshAllForm = true;
+
+            int myRemainTime = scene.RemainTime;
+            //寮�鍚唴閮ㄥ欢鏃舵椂闂寸嚎绋�(鏃ㄥ湪鍏ㄩ儴鍦版柟鐨勫悓涓�鍦烘櫙鏃堕棿鍚屾)
+            HdlSceneLogic.Current.StartDelayTimeThread(scene);
+
+            new System.Threading.Thread(() =>
+            {
+                while (myRemainTime > 0 && this.Parent != null)
+                {
+                    System.Threading.Thread.Sleep(1000);
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                        SetTimeText(this.GetTimeString(scene.RemainTime));
+                    }, ShowErrorMode.NO);
+                    myRemainTime--;
+                }
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    if (this.Parent != null)
+                    {
+                        SetTimeImage();
+                        //鐩存帴寮�鍚疞oading鐗规晥
+                        this.StartLoadingApreal();
+                        sceneContr.CanClick = true;
+                    }
+                }, ShowErrorMode.NO);
+            })
+            { IsBackground = true }.Start();
+        }
+
+        /// <summary>
+        /// SetTimeText
+        /// </summary>
+        /// <param name="name"></param>
+        public void SetTimeText(string name)
+        {
+            btnDelayIcon.Visible = true;
+            btnDelayTime.Text = name;
+        }
+
+        /// <summary>
+        /// SetTimeImage
+        /// </summary>
+        public void SetTimeImage()
+        {
+            btnDelayIcon.Visible = false;
+            btnDelayTime.Text = string.Empty;
+        }
+
+        /// <summary>
+        /// 寮�鍚疞oading鐗规晥
+        /// </summary>
+        public void StartLoadingApreal()
+        {
+            //寮勪釜閬僵閬綇
+            var frameBack1 = new FrameLayout();
+            frameBack1.Y = sceneContr.btnScenePic.Y;
+            frameBack1.X = sceneContr.btnScenePic.X;
+            frameBack1.Width = sceneContr.btnScenePic.Width;
+            frameBack1.Height = sceneContr.btnScenePic.Height;
+            frameBack1.Radius = (uint)Application.GetRealHeight(17);
+            frameBack1.BackgroundColor = 0xb3000000;
+            this.AddChidren(frameBack1);
+
+            var frameBack2 = new FrameLayout();
+            frameBack2.Y = sceneContr.btnSceneName.Y;
+            frameBack2.X = sceneContr.btnSceneName.X;
+            frameBack2.Width = sceneContr.btnSceneName.Width;
+            frameBack2.Height = sceneContr.btnSceneName.Height;
+            frameBack2.Radius = (uint)Application.GetRealHeight(17);
+            frameBack2.BackgroundColor = 0xb3000000;
+            this.AddChidren(frameBack2);
+
+            //鍐嶅姞涓浆鍦堢殑
+            var loadContr = new MyProgressLoading();
+            loadContr.LoadingBackgroundColor = UserCenterColor.Current.Transparent;
+            frameBack1.AddChidren(loadContr);
+            loadContr.StartLoading(1000);
+            loadContr.DisponeEvent += () =>
+            {
+                frameBack1.RemoveFromParent();
+                frameBack2.RemoveFromParent();
+            };
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍦烘櫙寤舵椂瀛楃涓�
+        /// </summary>
+        /// <param name="second"></param>
+        /// <returns></returns>
+        private string GetTimeString(int second)
+        {
+            if (second == 0)
+            {
+                return null;
+            }
+            string timeStr = string.Empty;
+            int hour = second / 3600;
+            int minu = second % 3600 / 60;
+            int sec = second % 60;
+            if (hour > 0)
+            {
+                timeStr += $"{hour}{Language.StringByID(R.MyInternationalizationString.Hour)}";
+                if (minu > 0)
+                {
+                    timeStr += $"{minu}{Language.StringByID(R.MyInternationalizationString.Minute)}";
+                }
+                if (sec > 0)
+                {
+                    timeStr += $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
+                }
+                return timeStr;
+            }
+            else if (minu > 0)
+            {
+                timeStr += $"{minu}{Language.StringByID(R.MyInternationalizationString.Minute)}";
+                if (sec > 0)
+                {
+                    timeStr += $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
+                }
+                return timeStr;
+            }
+            else
+            {
+                return $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
+            }
+        }
+
+        /// <summary>
+        /// 鑷畾涔夋帶浠�(闇�瑕佺殑瀹冪Щ闄や簨浠�)
+        /// </summary>
+        private class MyProgressLoading : ProgressLoading
+        {
+            /// <summary>
+            /// 鎺т欢閿�姣佺殑浜嬩欢
+            /// </summary>
+            public Action DisponeEvent = null;
+            /// <summary>
+            /// 鎺т欢閿�姣�
+            /// </summary>
+            public override void RemoveFromParent()
+            {
+                base.RemoveFromParent();
+
+                this.DisponeEvent?.Invoke();
+                this.DisponeEvent = null;
+            }
+        }
+    }
+}

--
Gitblit v1.8.0