From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs | 1250 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,250 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs b/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
new file mode 100644
index 0000000..a425f9a
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
@@ -0,0 +1,1250 @@
+锘縰sing Shared.Common;
+using Shared.Phone.Device.CommonForm;
+using Shared.Phone.UserCenter;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.MainPage
+{
+    /// <summary>
+    /// 涓婚〉(娉ㄦ剰,BodyFrameLyout鏄満鏅拰鍔熻兘鐨勬甯�)
+    /// </summary>
+    public class HomeMainPageForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// The instance.
+        /// </summary>
+        public static HomeMainPageForm Instance;
+        /// <summary>
+        /// 鏁翠釜鐣岄潰鐨勪笂涓嬫粦鍔ㄦ帶浠�
+        /// </summary>
+        private VerticalFrameControl listBodyContr = null;
+        /// <summary>
+        /// 鎴块棿鐨勬粦鍔ㄥ鍣ㄦ帶浠�
+        /// </summary>
+        private HorizontalPages roomPageView = null;
+        /// <summary>
+        /// 璁惧鍗$墖鎺т欢(涓婚敭涓�:璁惧涓婚敭)
+        /// </summary>
+        private Dictionary<string, Controls.DeviceCardCommon> dicDeviceCardControl = new Dictionary<string, Controls.DeviceCardCommon>();
+        /// <summary>
+        /// 鍦烘櫙鍗$墖鎺т欢(涓婚敭涓�:鍦烘櫙ID)
+        /// </summary>
+        private Dictionary<int, Controls.SceneCardControl> dicSceneCardControl = new Dictionary<int, Controls.SceneCardControl>();
+        /// <summary>
+        /// 妤煎眰鍚嶅瓧鎺т欢
+        /// </summary>
+        private NormalViewControl btnFloorName = null;
+        /// <summary>
+        /// 鎴块棿姝e湪鍙樻洿涓�
+        /// </summary>
+        private bool isRoomChanging = false;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐣岄潰鏄剧ず
+        /// </summary>
+        public void ShowForm()
+        {
+            this.FormID = "HomeMainPageForm";
+            Instance = this;
+
+            //鍏堝垵濮嬪寲宸︽粦鎴块棿鍒楄〃鐣岄潰(鍦ㄥ弽灏勯噷闈㈠垵濮嬪寲)
+            if (LeftListRoomViewFrom.Instance == null) { }
+
+            //鏁翠釜鑳屾櫙鐨勪笂涓嬫粦鍔ㄦ帶浠�
+            if (this.listBodyContr == null)
+            {
+                this.listBodyContr = new VerticalFrameControl();
+                listBodyContr.Height = this.Height;
+                listBodyContr.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
+                this.AddChidren(listBodyContr);
+            }
+            else
+            {
+                //娓呴櫎鍏ㄩ儴
+                this.listBodyContr.frameTable.RemoveAll();
+                listBodyContr.RecoverTableHeight();
+            }
+
+            //鍒濆鍖栭粯璁ゆゼ灞侷D
+            this.InitDefultFloorId();
+
+            //鍒濆鍖栧ご閮ㄦ帶浠�
+            this.InitTopFrameLayoutControl();
+            //鍒濆鍖栦腑闂存帶浠�
+            this.InitMidFrameLayoutControl();
+            //娣诲姞璁惧鐘舵�佷笂鎶ヤ簨浠�
+            this.AddNormalDeviceReportEvent();
+            //娣诲姞浼犳劅鍣ㄧ姸鎬佷笂鎶ヤ簨浠�
+            this.AddSensorDeviceReportEvent();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧ご閮ㄦ帶浠�
+        /// </summary>
+        private void InitTopFrameLayoutControl()
+        {
+            //澶撮儴瀹瑰櫒
+            base.topFrameLayout = new NormalFrameLayout();
+            topFrameLayout.Y = Application.GetRealHeight(60);
+            topFrameLayout.Height = Application.GetRealHeight(127);
+            topFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
+            listBodyContr.frameTable.AddChidren(topFrameLayout);
+
+            //妤煎眰鍥炬爣
+            var btnFloorIcon = new IconViewControl(69);
+            btnFloorIcon.X = ControlCommonResourse.XXLeft;
+            btnFloorIcon.Gravity = Gravity.CenterVertical;
+            btnFloorIcon.UnSelectedImagePath = "Item/Floor.png";
+            topFrameLayout.AddChidren(btnFloorIcon);
+
+            //鎷ユ湁妤煎眰
+            this.btnFloorName = null;
+            if (Config.Instance.Home.FloorDics.Count > 0)
+            {
+                //鎷ユ湁妤煎眰鐨勬椂鍊�,鐐瑰嚮鎵嶆湁鏁�
+                btnFloorIcon.ButtonClickEvent += (sender, e) =>
+                {
+                    //鏄剧ず閫夋嫨妤煎眰鐨勭晫闈�
+                    this.ShowSelectFloorForm(btnFloorName);
+                };
+
+                //妤煎眰鍚�
+                this.btnFloorName = new NormalViewControl(500, 100, true);
+                btnFloorName.X = btnFloorIcon.Right;
+                btnFloorName.Gravity = Gravity.CenterVertical;
+                btnFloorName.TextColor = ZigbeeColor.Current.GXCTextColor;
+                btnFloorName.Text = Config.Instance.Home.GetCurrentFloorName;
+                btnFloorName.IsBold = true;
+                btnFloorName.Width = btnFloorName.GetRealWidthByText() + Application.GetRealWidth(20);
+                topFrameLayout.AddChidren(btnFloorName);
+                btnFloorName.ButtonClickEvent += (sender, e) =>
+                {
+                    //鏄剧ず閫夋嫨妤煎眰鐨勭晫闈�
+                    this.ShowSelectFloorForm(btnFloorName);
+                };
+            }
+
+            //鍙瀵硅蹇嵎鏂瑰紡
+            //Shared.Phone.Device.VideoIntercom.VideoMachine.AccountSupportVideo(topFrameLayout);
+            //瀹夐槻蹇嵎鏂瑰紡
+            if (UserCenterResourse.ResidenceOption.SafetyShortcut)
+            {
+                var btnSafety = new Controls.SafetyShortcutControl();
+                btnSafety.X = Application.GetRealWidth(860);
+                btnSafety.Gravity = Gravity.CenterVertical;
+                topFrameLayout.AddChidren(btnSafety);
+            }
+            //娑堟伅鍥炬爣
+            var btnMessage = new MessageManagementControl();
+            btnMessage.X = Application.GetRealWidth(953);
+            btnMessage.Gravity = Gravity.CenterVertical;
+            btnMessage.UnSelectedImagePath = "Item/Message.png";
+            btnMessage.SelectedImagePath = "Item/MessageSelected.png";
+            topFrameLayout.AddChidren(btnMessage);
+
+            //浣忓畢鍚嶅瓧
+            var btnHouseName = new NormalViewControl(700, 95, true);
+            btnHouseName.X = ControlCommonResourse.XXLeft;
+            btnHouseName.Y = Application.GetRealHeight(161);
+            btnHouseName.TextSize = 24;
+            btnHouseName.TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor;
+            btnHouseName.IsBold = true;
+            btnHouseName.Text = Config.Instance.Home.Name;
+            btnHouseName.Width = btnHouseName.GetRealWidthByText();
+            this.listBodyContr.frameTable.AddChidren(btnHouseName);
+
+            //鍒囨崲浣忓畢
+            btnHouseName.MouseLongEventHandler += (sender, e) =>
+            {
+                if (Config.Instance.HomeFilePathList.Count == 0)
+                {
+                    //褰撳墠浣忓畢涓虹┖锛岃鍏堝缓绔嬩綇瀹�
+                    this.ShowMassage(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst));
+                }
+                else
+                {
+                    var selectHouse = new Category.SelectHouseForm();
+                    selectHouse.Init();
+                    selectHouse.HouseAction = (houseId) =>
+                    {
+                        //鍒囨崲浣忓畢
+                        this.ChangeResidence(HdlResidenceLogic.Current.GetHouseByHouseId(houseId));
+                    };
+                }
+            };
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑闂存帶浠�
+        /// </summary>
+        private void InitMidFrameLayoutControl()
+        {
+            //鎴愬憳韬唤涓嶅厑璁告坊鍔犵綉鍏�
+            if (UserCenterResourse.UserInfo.AuthorityNo == 3)
+            {
+                //鍒濆鍖栧満鏅�,鍔熻兘鐨勫垏鎹㈡帶浠�
+                this.InitSceneFunctionSwitchControl();
+                //鍒濆鍖栨埧闂存粦鍔ㄦ帶浠�
+                this.InitRoomHorizontalPagesControl();
+                return;
+            }
+
+            //妫�娴嬫槸鍚︾粦瀹氭湁缃戝叧
+            if (Common.Config.Instance.Home.IsVirtually == false && this.CheckHadBindGateway() == false)
+            {
+                //鏄剧ず娌℃湁缁戝畾杩囩綉鍏崇殑鐣岄潰
+                this.ShowNoGatewayTip();
+            }
+            else
+            {
+                //鍒濆鍖栧満鏅�,鍔熻兘鐨勫垏鎹㈡帶浠�
+                this.InitSceneFunctionSwitchControl();
+                //鍒濆鍖栨埧闂存粦鍔ㄦ帶浠�
+                this.InitRoomHorizontalPagesControl();
+            }
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧満鏅�,鍔熻兘鐨勫垏鎹㈡帶浠�
+        /// </summary>
+        private void InitSceneFunctionSwitchControl()
+        {
+            //鍔熻兘鍜屽満鏅殑鑳屾櫙鍥�
+            var functionSceneView = new FrameLayout();
+            functionSceneView.Y = Application.GetRealHeight(861);
+            functionSceneView.Width = Application.GetRealWidth(832);
+            functionSceneView.Height = Application.GetRealHeight(167);
+            functionSceneView.Gravity = Gravity.CenterHorizontal;
+            functionSceneView.BackgroundImagePath = "Item/SceneFunctionBG.png";
+            this.listBodyContr.frameTable.AddChidren(functionSceneView);
+
+            //鍦烘櫙
+            var btnScene = new NormalViewControl(350, 100, true);
+            btnScene.X = Application.GetRealWidth(30);
+            btnScene.Y = Application.GetRealHeight(12);
+            btnScene.TextColor = ZigbeeColor.Current.GXCTextGrayColor3;
+            btnScene.SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+            btnScene.TextID = R.MyInternationalizationString.Scence;
+            btnScene.TextSize = 15;
+            btnScene.TextAlignment = TextAlignment.Center;
+            functionSceneView.AddChidren(btnScene);
+
+            //鍔熻兘
+            var btnFunction = new NormalViewControl(360, 100, true);
+            btnFunction.X = Application.GetRealWidth(430);
+            btnFunction.Y = Application.GetRealHeight(12);
+            btnFunction.TextColor = ZigbeeColor.Current.GXCTextGrayColor3;
+            btnFunction.SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+            btnFunction.TextSize = 15;
+            btnFunction.TextID = R.MyInternationalizationString.Function;
+            btnFunction.TextAlignment = TextAlignment.Center;
+            functionSceneView.AddChidren(btnFunction);
+            if (UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex == 1)
+            {
+                btnScene.IsSelected = true;
+                btnScene.TextSize = 17;
+                btnScene.IsBold = true;
+            }
+            else if (UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex == 2)
+            {
+                btnFunction.IsSelected = true;
+                btnFunction.TextSize = 17;
+                btnFunction.IsBold = true;
+            }
+
+            //鍔熻兘鍜屽満鏅痓odyView
+            this.bodyFrameLayout = new NormalFrameLayout();
+            bodyFrameLayout.Y = functionSceneView.Bottom;
+            bodyFrameLayout.Height = this.listBodyContr.frameTable.Height - functionSceneView.Bottom;
+            bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
+            this.listBodyContr.frameTable.AddChidren(bodyFrameLayout);
+
+            //閫夋嫨鍔熻兘鍒嗘爮
+            btnFunction.ButtonClickEvent += (sender, e) =>
+            {
+                if (btnFunction.IsSelected == true)
+                {
+                    return;
+                }
+                //鍔熻兘鍒嗘敮閫夋嫨
+                UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 2;
+
+                btnScene.IsSelected = false;
+                btnScene.TextSize = 15;
+                btnScene.IsBold = false;
+
+                btnFunction.IsSelected = true;
+                btnFunction.TextSize = 17;
+                btnFunction.IsBold = true;
+                //鍒锋柊璁惧妗屽竷鎺т欢
+                this.RefreshBodyView();
+            };
+            //閫夋嫨鍦烘櫙鍒嗘爮
+            btnScene.ButtonClickEvent += (sender, e) =>
+            {
+                if (btnScene.IsSelected == true)
+                {
+                    return;
+                }
+                //鍦烘櫙鍒嗘敮閫夋嫨
+                UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 1;
+
+                btnScene.IsSelected = true;
+                btnScene.TextSize = 17;
+                btnScene.IsBold = true;
+
+                btnFunction.IsSelected = false;
+                btnFunction.TextSize = 15;
+                btnFunction.IsBold = false;
+                //鍒锋柊璁惧妗屽竷鎺т欢
+                this.RefreshBodyView();
+            };
+        }
+
+        /// <summary>
+        /// 鎻愮ず鐢ㄦ埛娌℃湁缃戝叧锛屽苟蹇�熻烦杞埌娣诲姞缃戝叧鐣岄潰
+        /// </summary>
+        private void ShowNoGatewayTip()
+        {
+            var bg = new PicViewControl(717, 478);
+            bg.Y = Application.GetRealHeight(302);
+            bg.Gravity = Gravity.CenterHorizontal;
+            bg.UnSelectedImagePath = "Item/NoBindGW.png";
+            this.listBodyContr.frameTable.AddChidren(bg);
+
+            var tip = new NormalViewControl(this.GetPictrueRealSize(717), this.GetPictrueRealSize(58), false);
+            tip.Y = Application.GetRealHeight(815);
+            tip.Gravity = Gravity.CenterHorizontal;
+            tip.TextID = R.MyInternationalizationString.NewAccountNeedBingGW;
+            tip.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
+            tip.TextAlignment = TextAlignment.Center;
+            this.listBodyContr.frameTable.AddChidren(tip);
+
+            var addBG = new PicViewControl(971, 366);
+            addBG.Y = Application.GetRealHeight(1048);
+            addBG.UnSelectedImagePath = "Item/VirtualFrame.png";
+            addBG.Gravity = Gravity.CenterHorizontal;
+            this.listBodyContr.frameTable.AddChidren(addBG);
+
+            var addGatewayBtn = new IconViewControl(89);
+            addGatewayBtn.Y = Application.GetRealHeight(1143);
+            addGatewayBtn.UnSelectedImagePath = "Item/Add_GW.png";
+            addGatewayBtn.Gravity = Gravity.CenterHorizontal;
+            this.listBodyContr.frameTable.AddChidren(addGatewayBtn);
+            addGatewayBtn.ButtonClickEvent += (sender, e) =>
+            {
+                var form = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm();
+                form.AddForm();
+            };
+
+            var addTip = new PicViewControl(717, 58);
+            addTip.Y = Application.GetRealHeight(1256);
+            addTip.Gravity = Gravity.CenterHorizontal;
+            addTip.TextID = R.MyInternationalizationString.AddSmartGW;
+            addTip.TextColor = ZigbeeColor.Current.GXCTextBlackColor;
+            addTip.TextAlignment = TextAlignment.Center;
+            this.listBodyContr.frameTable.AddChidren(addTip);
+
+            addTip.ButtonClickEvent += (sender, e) =>
+            {
+                var form = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm();
+                form.AddForm();
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖栨埧闂存粦鍔ㄦ帶浠禵________________
+
+        /// <summary>
+        /// 鍒濆鍖栨埧闂存粦鍔ㄦ帶浠�
+        /// </summary>
+        private void InitRoomHorizontalPagesControl()
+        {
+            //宸﹀彸婊戝姩鎺т欢鐨勮儗鏅鍣�
+            var frameBack = new FrameLayout();
+            frameBack.Y = Application.GetRealHeight(302);
+            frameBack.Width = this.Width;
+            frameBack.Height = Application.GetRealHeight(478);
+            this.listBodyContr.frameTable.AddChidren(frameBack);
+
+            //鎴块棿婊戝姩鎺т欢宸﹁竟鐨勮櫄鎷熷浘鐗�
+            var mLeftImageView = new ImageView();
+            mLeftImageView.ImagePath = "RoomIcon/19.jpg";
+            mLeftImageView.Radius = (uint)Application.GetRealHeight(17);
+            mLeftImageView.Width = Application.GetRealWidth(717);
+            mLeftImageView.Height = Application.GetRealHeight(478);
+            //鎴块棿婊戝姩鎺т欢鍙宠竟鐨勮櫄鎷熷浘鐗�
+            var mRightImageView = new ImageView();
+            mRightImageView.ImagePath = "RoomIcon/19.jpg";
+            mRightImageView.Radius = (uint)Application.GetRealHeight(17);
+            mRightImageView.Width = mLeftImageView.Width;
+            mRightImageView.Height = mLeftImageView.Height;
+
+            this.roomPageView = new HorizontalPages();
+            roomPageView.Width = frameBack.Width;
+            roomPageView.Height = frameBack.Height;
+            frameBack.AddChidren(roomPageView);
+            //绐佸嚭杈硅窛
+            roomPageView.TCBJ = Application.GetRealWidth(124);
+            //涓や釜page涔嬮棿鐨勯棿璺�
+            roomPageView.JMBJ = Application.GetRealWidth(58);
+            //鍦ㄨ繖涓帶浠剁殑涓嬮潰娣诲姞闃村奖鏁堟灉
+            var btnRoomBottomShadow = new NormalViewControl(717, 81, true);
+            btnRoomBottomShadow.Y = frameBack.Bottom;
+            btnRoomBottomShadow.Gravity = Gravity.CenterHorizontal;
+            btnRoomBottomShadow.UnSelectedImagePath = "Room/RoomCardShadow.png";
+            this.listBodyContr.frameTable.AddChidren(btnRoomBottomShadow);
+
+            //璁剧疆鎺у埗鏈�宸﹀拰鏈�鍙�2杈瑰~鍏呯殑鍋囪儗鏅疺iew锛屼笉璁剧疆涓嶆樉绀猴紝闇�瑕佸湪AddChidren 鍓嶈皟鐢ㄨ鏂规硶
+            roomPageView.SetLeftAndRightImageView(mLeftImageView, mRightImageView);
+
+            //褰撳墠鎴块棿
+            var listRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId);
+            if (HdlRoomLogic.Current.NowMainPageRoom == null)
+            {
+                HdlRoomLogic.Current.NowMainPageRoom = listRoom[0];
+            }
+            var curIndex = 0;
+            for (int i = 0; i < listRoom.Count; i++)
+            {
+                var roomView = new RoomView(0, 0);
+                roomPageView.AddChidren(roomView);
+                roomView.Init(listRoom[i]);
+
+                if (listRoom[i].Id == HdlRoomLogic.Current.NowMainPageRoom.Id)
+                {
+                    //褰撳墠鎴块棿,鍒欐樉绀洪偅浜涙暟鎹嚭鏉�
+                    roomView.HideName(false);
+                    //褰撳墠绱㈠紩
+                    curIndex = i;
+                }
+                else
+                {
+                    roomView.HideName(true);
+                }
+            }
+
+            //鍦ㄦ埧闂村崱鐗囧乏杈规坊鍔犻伄缃�
+            var btnRoomLeftShadow = new FrameLayout();
+            btnRoomLeftShadow.Width = Application.GetRealWidth(124);
+            btnRoomLeftShadow.Height = roomPageView.Height - roomPageView.JMBJ * 2;
+            btnRoomLeftShadow.Gravity = Gravity.CenterVertical;
+            btnRoomLeftShadow.BackgroundColor = 0x1c000000;
+            btnRoomLeftShadow.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
+            //frameBack.AddChidren(btnRoomLeftShadow);//鏆傛椂涓嶅姞閬僵
+
+            //鍦ㄦ埧闂村崱鐗囧彸杈规坊鍔犻伄缃�
+            var btnRoomRightShadow = new FrameLayout();
+            btnRoomRightShadow.Width = btnRoomLeftShadow.Width;
+            btnRoomRightShadow.Height = btnRoomLeftShadow.Height;
+            btnRoomRightShadow.X = Application.GetRealWidth(956);
+            btnRoomRightShadow.Gravity = Gravity.CenterVertical;
+            btnRoomRightShadow.BackgroundColor = btnRoomLeftShadow.BackgroundColor;
+            btnRoomRightShadow.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft);
+            //frameBack.AddChidren(btnRoomRightShadow);//鏆傛椂涓嶅姞閬僵
+
+            //鎺т欢寮�濮嬫粦鍔ㄧ殑浜嬩欢
+            roomPageView.StartScrollAction += () =>
+            {
+                this.isRoomChanging = true;
+                //寮�濮嬫粦鍔ㄦ椂,闅愯棌褰撳墠鐨勬暟鎹樉绀�
+                (roomPageView.GetChildren(roomPageView.PageIndex) as RoomView).HideName(true);
+                btnRoomLeftShadow.Visible = false;
+                btnRoomRightShadow.Visible = false;
+                btnRoomBottomShadow.Visible = false;
+            };
+            roomPageView.EndScrollAction += () =>
+            {
+                curIndex = roomPageView.PageIndex;
+                //鍓嶄竴寮犲崱鐗�
+                if (roomPageView.GetChildren(curIndex - 1) != null)
+                {
+                    (roomPageView.GetChildren(curIndex - 1) as RoomView).HideName(true);
+                }
+                //褰撳墠鍗$墖
+                if (roomPageView.GetChildren(curIndex) != null)
+                {
+                    (roomPageView.GetChildren(curIndex) as RoomView).HideName(false);
+                }
+                //涓嬩竴寮犲崱鐗�
+                if (roomPageView.GetChildren(curIndex + 1) != null)
+                {
+                    (roomPageView.GetChildren(curIndex + 1) as RoomView).HideName(true);
+                }
+
+                btnRoomLeftShadow.Visible = true;
+                btnRoomRightShadow.Visible = true;
+                btnRoomBottomShadow.Visible = true;
+                //鍒囨崲褰撳墠鎴块棿
+                HdlRoomLogic.Current.NowMainPageRoom = listRoom[curIndex];
+                //鍒锋柊璁惧妗屽竷鎺т欢
+                this.isRoomChanging = false;
+                this.RefreshBodyView();
+            };
+            //璁剧疆鎴块棿鐨勫垵濮嬮�夋嫨
+            roomPageView.PageIndex = curIndex;
+            //濡傛灉绱㈠紩鏄涓�涓椂锛屽畠瑙﹀彂涓嶄簡浜嬩欢,闇�瑕佹墜鍔ㄨЕ鍙�
+            if (curIndex == 0)
+            {
+                roomPageView.EndScrollAction();
+            }
+        }
+
+        /// <summary>
+        /// 璁剧疆鎴块棿鐨勬粦鍔ㄥ鍣ㄦ帶浠堕�夋嫨鎸囧畾鐨勬埧闂�(渚涘閮ㄨ皟鐢�)
+        /// </summary>
+        /// <param name="room"></param>
+        public void SetRoomPageViewSelect(Room room)
+        {
+            if (roomPageView == null)
+            {
+                //褰撴病鏈夌粦瀹氭湁缃戝叧,宸︽粦鏃�,鐐瑰嚮鎴块棿鍒楄〃,鍒欎笉楦熷畠
+                return;
+            }
+            var listRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId);
+            for (int i = 0; i < listRoom.Count; i++)
+            {
+                if (room.Id == listRoom[i].Id)
+                {
+                    if (roomPageView.PageIndex != i)
+                    {
+                        //涓嶇浉鍚屾椂鎵嶅埛鏂�
+                        roomPageView.PageIndex = i;
+                    }
+                    break;
+                }
+            }
+            //閲嶇疆涓�涓嬫ゼ灞傚悕瀛�
+            if (this.btnFloorName != null)
+            {
+                btnFloorName.Text = Config.Instance.Home.GetCurrentFloorName;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍔熻兘鍒嗘敮___________________________
+
+        /// <summary>
+        /// 鏄剧ず鍔熻兘
+        /// </summary>
+        private void ShowFunction()
+        {
+            //鍏堟竻绌虹紦瀛�
+            bodyFrameLayout.RemoveAll();
+            bodyFrameLayout.Height = Application.GetRealHeight(750);
+            this.listBodyContr.RecoverTableHeight();
+            this.dicSceneCardControl.Clear();
+            this.dicDeviceCardControl.Clear();
+
+            var listDevice = new List<CommonDevice>();
+            foreach (var mainkeys in HdlRoomLogic.Current.NowMainPageRoom.ListDevice)
+            {
+                var device = LocalDevice.Current.GetDevice(mainkeys);
+                //鍒ゆ柇璇ヨ澶囪兘鍚︽樉绀哄湪涓婚〉
+                if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false)
+                {
+                    continue;
+                }
+                listDevice.Add(device);
+            }
+
+            //褰撳墠鎴块棿鐨勮澶囨暟
+            if (listDevice.Count == 0)
+            {
+                //杩樻病鏈夊姛鑳藉摝
+                this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.NoFunction_Tip));
+                return;
+            }
+            //璁惧鍒楄〃瀹瑰櫒鎺т欢
+            var listDeviceBackContr = new FrameLayout();
+            listDeviceBackContr.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listDeviceBackContr);
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                //鍒濆鍖栬澶囧崱鐗囧垪琛ㄦ帶浠�
+                this.InitDeviceListCardControl(listDeviceBackContr, listDevice);
+            });
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栬澶囧崱鐗囧垪琛ㄦ帶浠�
+        /// </summary>
+        /// <param name="listDeviceBackContr"></param>
+        private void InitDeviceListCardControl(FrameLayout listDeviceBackContr, List<CommonDevice> listDevice)
+        {
+            //璁惧璁℃暟
+            int contrCount = 0;
+            //X杞村潗鏍�(鍥剧墖宸﹁竟鏈変綑鐧�)
+            int XX = this.GetPictrueRealSize(44);
+            //Y杞村潗鏍�
+            int YY = 0;
+            var listContr = new List<Controls.DeviceCardCommon>();
+            foreach (var device in listDevice)
+            {
+                if (this.isRoomChanging == true || listDeviceBackContr.Parent == null)
+                {
+                    //鏀惧純鍒濆鍖栨帶浠�
+                    return;
+                }
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    Controls.DeviceCardCommon cardContr = null;
+                    //绐楀笜
+                    if (device.Type == DeviceType.WindowCoveringDevice)
+                    {
+                        cardContr = new Controls.DeviceCurtainCardControl();
+                    }
+                    //缁х數鍣�
+                    else if (device.Type == DeviceType.OnOffOutput)
+                    {
+                        cardContr = new Controls.DeviceRelayCardControl();
+                    }
+                    //绌烘皵寮�鍏�
+                    else if (device.Type == DeviceType.AirSwitch)
+                    {
+                        cardContr = new Controls.DeviceAirSwitchCardControl();
+                    }
+                    //绌鸿皟
+                    else if (device.Type == DeviceType.Thermostat)
+                    {
+                        cardContr = new Controls.DeviceAcCardControl();
+                    }
+                    //鏂伴
+                    else if (device.Type == DeviceType.FreshAir)
+                    {
+                        cardContr = new Controls.DeviceFreshAirCardControl();
+                    }
+                    //褰╃伅(璋冨厜鍣�)
+                    else if (device.Type == DeviceType.DimmableLight)
+                    {
+                        cardContr = new Controls.DeviceColorLightCardControl();
+                    }
+                    //浼犳劅鍣�
+                    else if (device.Type == DeviceType.IASZone)
+                    {
+                        cardContr = new Controls.DeviceSensorCardControl();
+                    }
+                    //娓╂箍搴�
+                    else if (device.Type == DeviceType.TemperatureSensor)
+                    {
+                        cardContr = new Controls.DeviceTemperatureCardControl();
+                    }
+                    //闂ㄩ攣
+                    else if (device.Type == DeviceType.DoorLock)
+                    {
+                        cardContr = new Controls.DeviceDoorLockCardControl();
+                    }
+                    //鑹叉俯鐏�
+                    else if (device.Type == DeviceType.ColorTemperatureLight)
+                    {
+                        cardContr = new Controls.DeviceColorTemperatureCardControl();
+                    }
+                    //鏃犳硶璇嗗埆
+                    else
+                    {
+                        cardContr = new Controls.DeviceCardCommon();
+                    }
+
+                    //鍒濆鍖栧崱鐗�
+                    cardContr.X = XX;
+                    cardContr.Y = YY;
+                    listDeviceBackContr.AddChidren(cardContr);
+                    cardContr.InitControl(device, HdlRoomLogic.Current.NowMainPageRoom);
+                    //鍗$墖闇�瑕佽绉婚櫎鐨勪簨浠�
+                    cardContr.CardNeedRemoveEvent += () =>
+                    {
+                        //閲嶇疆璁惧鍗$墖鎺т欢鍧愭爣(鍗$墖闇�瑕佽鍒犻櫎涓撶敤)
+                        this.ResetDeviceCardControlLocation(LocalDevice.Current.GetDeviceMainKeys(device));
+                    };
+                    //璁惧璁℃暟
+                    contrCount++;
+                    //鍗$墖宸﹀彸涓よ竟鏈�14鐨勪綑鐧�,姣忎袱涓悗,X杞撮噸缃�
+                    XX = contrCount % 2 == 0 ? this.GetPictrueRealSize(44) : cardContr.Right + this.GetPictrueRealSize(20);
+                    if (contrCount % 2 == 0)
+                    {
+                        //娌′袱涓箣鍚�,Y杞撮�掑
+                        YY = cardContr.Bottom + this.GetPictrueRealSize(15);
+                    }
+                    //鎺т欢璁板綍鍒扮紦瀛樹腑
+                    this.dicDeviceCardControl[LocalDevice.Current.GetDeviceMainKeys(device)] = cardContr;
+                    //鍔犵紦瀛�,鐒跺悗鍙戝懡浠�
+                    listContr.Add(cardContr);
+
+                    if (contrCount == listDevice.Count)
+                    {
+                        //璋冩暣妗屽竷澶у皬
+                        if (contrCount > 4)
+                        {
+                            bodyFrameLayout.Height = listDeviceBackContr.GetChildren(listDeviceBackContr.ChildrenCount - 1).Bottom;
+                            listDeviceBackContr.Height = bodyFrameLayout.Height;
+                            this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
+                        }
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            for (int i = 0; i < listContr.Count; i++)
+                            {
+                                if (listDeviceBackContr.Parent == null)
+                                {
+                                    return;
+                                }
+                                System.Threading.Thread.Sleep(200);
+                                //鍙戦�佽幏鍙栫姸鎬佺殑鍛戒护
+                                listContr[i].SendStatuComand();
+                            }
+
+                        }, ShowErrorMode.NO);
+                    }
+                });
+                if (contrCount > 6)
+                {
+                    //璁╁畠鍛堢幇涓�绉嶇洿鎺ヤ竴娆℃�у埛鍑烘潵鐨勬晥鏋�
+                    System.Threading.Thread.Sleep(50);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 閲嶇疆璁惧鍗$墖鎺т欢鍧愭爣_______________
+
+        /// <summary>
+        /// 閲嶇疆璁惧鍗$墖鎺т欢鍧愭爣(鍗$墖闇�瑕佽鍒犻櫎涓撶敤)
+        /// </summary>
+        /// <param name="deleteKey">闇�瑕佽鍒犻櫎鐨勫崱鐗囦富閿�</param>
+        private void ResetDeviceCardControlLocation(string deleteKey)
+        {
+            if (this.dicDeviceCardControl.ContainsKey(deleteKey) == false)
+            {
+                //濡傛灉鍒楄〃閲岄潰娌℃湁杩欎釜鎺т欢鐨勮瘽
+                return;
+            }
+            var deleteContr = this.dicDeviceCardControl[deleteKey];
+
+            //璁惧璁℃暟
+            int contrCount = 0;
+
+            bool canMove = false;
+            int YY = 0;
+            foreach (var mainkey in this.dicDeviceCardControl.Keys)
+            {
+                if (deleteKey == mainkey)
+                {
+                    //濡傛灉宸茬粡鍒颁簡瑕佸垹闄ょ殑鍗$墖,鍒犻櫎鎺夊畠,鐒跺悗瀹冧箣鍚庣殑鍗$墖鍏ㄩ儴鍚戜笂绉诲姩
+                    canMove = true;
+                    continue;
+                }
+                //璁惧璁℃暟
+                contrCount++;
+                //鍗$墖宸﹀彸涓よ竟鏈�14鐨勪綑鐧�,姣忎袱涓悗,X杞撮噸缃�
+                int XX = 0;
+                if (contrCount % 2 == 1)
+                {
+                    //绗竴涓浐瀹�44
+                    XX = this.GetPictrueRealSize(44);
+                }
+                else
+                {
+                    //绗簩涓槸44+鎺т欢瀹藉害+20浣欑櫧
+                    XX = this.GetPictrueRealSize(44) + this.dicDeviceCardControl[mainkey].Width + this.GetPictrueRealSize(20);
+                }
+
+                //姣忎袱涓箣鍚�,骞朵笖鏄涓�涓殑鏃跺��,Y杞撮�掑
+                if (contrCount > 2 && contrCount % 2 == 1)
+                {
+                    //姹傚晢
+                    int value = contrCount / 2;
+                    //鎺т欢鐨勫簳閮ㄦ湁15鐨勯棿闅�
+                    YY = value * (this.dicDeviceCardControl[mainkey].Height + this.GetPictrueRealSize(15));
+                }
+                if (canMove == true)
+                {
+                    //绉诲姩鎺т欢
+                    this.dicDeviceCardControl[mainkey].X = XX;
+                    this.dicDeviceCardControl[mainkey].Y = YY;
+                }
+            }
+            //鍘绘壘涓�涓嬭繖涓帶浠剁殑鍒楄〃瀹瑰櫒
+            var listView = deleteContr.Parent as FrameLayout;
+
+            //鍒犻櫎鎺夐偅寮犲崱鐗囩殑涓婚敭
+            deleteContr.RemoveFromParent();
+            this.dicDeviceCardControl.Remove(deleteKey);
+
+            //璋冩暣妗屽竷楂樺害
+            if (listView.ChildrenCount >= 4)
+            {
+                bodyFrameLayout.Height = listView.GetChildren(listView.ChildrenCount - 1).Bottom;
+                listView.Height = bodyFrameLayout.Height;
+                this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍦烘櫙鍒嗘敮___________________________
+
+        /// <summary>
+        /// 鏄剧ず鍦烘櫙
+        /// </summary>
+        private void ShowScene()
+        {
+            //鍏堟竻绌虹紦瀛�
+            bodyFrameLayout.RemoveAll();
+            bodyFrameLayout.Height = Application.GetRealHeight(750);
+            this.listBodyContr.RecoverTableHeight();
+            this.dicSceneCardControl.Clear();
+            this.dicDeviceCardControl.Clear();
+
+            var listScene = new List<SceneUI>();
+            foreach (int sceneId in HdlRoomLogic.Current.NowMainPageRoom.ListSceneId)
+            {
+                var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                if (sceneUi == null)
+                {
+                    //杩欎釜鍦烘櫙涓嶈浜�
+                    continue;
+                }
+                listScene.Add(sceneUi);
+            }
+
+            if (listScene.Count == 0)
+            {
+                //杩樻病鏈夊満鏅摝
+                this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.NoScene_Tip));
+                return;
+            }
+            //鍒楄〃鎺т欢
+            var listSceneBackContr = new FrameLayout();
+            listSceneBackContr.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listSceneBackContr);
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                //鍒濆鍖栧満鏅崱鐗囧垪琛ㄦ帶浠�
+                this.InitSceneListCardControl(listSceneBackContr, listScene);
+            });
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧満鏅崱鐗囧垪琛ㄦ帶浠�
+        /// </summary>
+        /// <param name="listSceneBackContr"></param>
+        private void InitSceneListCardControl(FrameLayout listSceneBackContr, List<SceneUI> listScene)
+        {
+            //鍦烘櫙璁℃暟
+            int contrCount = 0;
+            //X杞村潗鏍�(鍥剧墖宸﹁竟鏈変綑鐧�)
+            int XX = this.GetPictrueRealSize(44);
+            //Y杞村潗鏍�
+            int YY = 0;
+            foreach (var sceneUi in listScene)
+            {
+                if (this.isRoomChanging == true || listSceneBackContr.Parent == null)
+                {
+                    //鏀惧純鍒濆鍖栨帶浠�
+                    return;
+                }
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //鍒濆鍖栧崱鐗�
+                    var cardContr = new Controls.SceneCardControl();
+                    cardContr.X = XX;
+                    cardContr.Y = YY;
+                    listSceneBackContr.AddChidren(cardContr);
+                    cardContr.InitControl(sceneUi);
+                    //鍗$墖闇�瑕佽绉婚櫎鐨勪簨浠�
+                    cardContr.CardNeedRemoveEvent += () =>
+                    {
+                        //閲嶇疆璁惧鍗$墖鎺т欢鍧愭爣(鍗$墖闇�瑕佽鍒犻櫎涓撶敤)
+                        this.ResetSceneCardControlLocation(sceneUi.Id);
+                    };
+                    //璁惧璁℃暟
+                    contrCount++;
+                    //姣忎袱涓悗,X杞撮噸缃�
+                    XX = contrCount % 2 == 0 ? this.GetPictrueRealSize(44) : cardContr.Right + this.GetPictrueRealSize(20);
+                    if (contrCount % 2 == 0)
+                    {
+                        //娌′袱涓箣鍚�,Y杞撮�掑
+                        YY = cardContr.Bottom + this.GetPictrueRealSize(15);
+                    }
+                    //鎺т欢璁板綍鍒扮紦瀛樹腑
+                    this.dicSceneCardControl[sceneUi.Id] = cardContr;
+
+                    if (contrCount == listScene.Count)
+                    {
+                        //璋冩暣妗屽竷楂樺害
+                        if (contrCount > 4)
+                        {
+                            bodyFrameLayout.Height = listSceneBackContr.GetChildren(listSceneBackContr.ChildrenCount - 1).Bottom;
+                            listSceneBackContr.Height = bodyFrameLayout.Height;
+                            this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
+                        }
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            //璁剧疆鐩墠鍦烘櫙鐨勫欢杩熺姸鎬�
+                            this.SetSceneDelayTime(listSceneBackContr);
+                        });
+                    }
+                });
+                if (contrCount > 6)
+                {
+                    //璁╁畠鍛堢幇涓�绉嶄竴娆℃�ф樉绀哄嚭鏉ョ殑鏁堟灉
+                    System.Threading.Thread.Sleep(50);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 璁剧疆鍦烘櫙鐨勫欢杩熺姸鎬�
+        /// </summary>
+        /// <param name="listSceneBackContr"></param>
+        private async void SetSceneDelayTime(FrameLayout listSceneBackContr)
+        {
+            await System.Threading.Tasks.Task.Delay(1500);
+            if (listSceneBackContr.Parent == null)
+            {
+                //鎺т欢宸茬粡琚Щ闄�
+                return;
+            }
+            //绛夊緟1.5绉掍箣鍚�,鑾峰彇寤惰繜鐘舵��
+            var result = await Scene.CatDelaySceneAsync();
+            if (result == null || result.catDelaySceneResponseData == null)
+            {
+                return;
+            }
+            if (listSceneBackContr.Parent == null)
+            {
+                //鎺т欢宸茬粡琚Щ闄�
+                return;
+            }
+            foreach (var data in result.catDelaySceneResponseData.DelayScenesList)
+            {
+                var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(data.ScenesId);
+                if (sceneUi == null)
+                {
+                    continue;
+                }
+                if (this.dicSceneCardControl.ContainsKey(data.ScenesId) == false)
+                {
+                    continue;
+                }
+                //淇敼鍓╀綑寤惰繜鏃堕棿
+                sceneUi.RemainTime = data.RemainTime;
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //鍒锋柊鍗$墖淇℃伅
+                    this.dicSceneCardControl[data.ScenesId].RefreshControlInfo(sceneUi);
+                });
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 閲嶇疆鍦烘櫙鍗$墖鎺т欢鍧愭爣_______________
+
+        /// <summary>
+        /// 閲嶇疆鍦烘櫙鍗$墖鎺т欢鍧愭爣(鍗$墖闇�瑕佽鍒犻櫎涓撶敤)
+        /// </summary>
+        /// <param name="deleteKey">闇�瑕佽鍒犻櫎鐨勫崱鐗囦富閿�</param>
+        private void ResetSceneCardControlLocation(int deleteId)
+        {
+            if (this.dicSceneCardControl.ContainsKey(deleteId) == false)
+            {
+                //濡傛灉鍒楄〃閲岄潰娌℃湁杩欎釜鎺т欢鐨勮瘽
+                return;
+            }
+            var deleteContr = this.dicSceneCardControl[deleteId];
+            //璁惧璁℃暟
+            int contrCount = 0;
+
+            bool canMove = false;
+            int YY = 0;
+            foreach (var sceneId in this.dicSceneCardControl.Keys)
+            {
+                if (deleteId == sceneId)
+                {
+                    //濡傛灉宸茬粡鍒颁簡瑕佸垹闄ょ殑鍗$墖,鍒犻櫎鎺夊畠,鐒跺悗瀹冧箣鍚庣殑鍗$墖鍏ㄩ儴鍚戜笂绉诲姩
+                    canMove = true;
+                    continue;
+                }
+                //璁惧璁℃暟
+                contrCount++;
+                //姣忎袱涓悗,X杞撮噸缃�
+                int XX = 0;
+                if (contrCount % 2 == 1)
+                {
+                    //绗竴涓浐瀹�44
+                    XX = this.GetPictrueRealSize(44);
+                }
+                else
+                {
+                    //绗簩涓槸44+鎺т欢瀹藉害+20浣欑櫧
+                    XX = this.GetPictrueRealSize(44) + this.dicSceneCardControl[sceneId].Width + this.GetPictrueRealSize(20);
+                }
+
+                //姣忎袱涓箣鍚�,骞朵笖鏄涓�涓椂,Y杞撮�掑
+                if (contrCount > 2 && contrCount % 2 == 1)
+                {
+                    //姹傚晢
+                    int value = contrCount / 2;
+                    //鎺т欢鐨勫簳閮ㄦ湁15鐨勯棿闅�
+                    YY = value * (this.dicSceneCardControl[sceneId].Height + this.GetPictrueRealSize(15));
+                }
+                if (canMove == true)
+                {
+                    //绉诲姩鎺т欢
+                    this.dicSceneCardControl[sceneId].X = XX;
+                    this.dicSceneCardControl[sceneId].Y = YY;
+                }
+            }
+            //鍘绘壘涓�涓嬭繖涓帶浠剁殑鍒楄〃瀹瑰櫒
+            var listView = deleteContr.Parent as FrameLayout;
+
+            //鍒犻櫎鎺夐偅寮犲崱鐗囩殑涓婚敭
+            deleteContr.RemoveFromParent();
+            this.dicSceneCardControl.Remove(deleteId);
+
+            //璋冩暣妗屽竷楂樺害
+            if (listView.ChildrenCount >= 4)
+            {
+                bodyFrameLayout.Height = listView.GetChildren(listView.ChildrenCount - 1).Bottom;
+                listView.Height = bodyFrameLayout.Height;
+                this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒锋柊妗屽竷鎺т欢_______________________
+
+        /// <summary>
+        /// 鍒锋柊璁惧妗屽竷鎺т欢
+        /// </summary>
+        public void RefreshBodyView()
+        {
+            bodyFrameLayout.RemoveAll();
+
+            //璁╃晫闈㈠埆闂儊
+            HdlThreadLogic.Current.RunMainInThread(() =>
+            {
+                if (UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex == 2)
+                {
+                    //鍔熻兘
+                    this.ShowFunction();
+                }
+                else
+                {
+                    //鍦烘櫙
+                    this.ShowScene();
+                }
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鍒囨崲浣忓畢___________________________
+        /// <summary>
+        /// 鍒囨崲浣忓畢
+        /// </summary>
+        /// <param name="home">Home.</param>
+        private void ChangeResidence(House home)
+        {
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                this.ShowProgressBar();
+
+                //鍒囨崲浣忓畢
+                HdlResidenceLogic.Current.SwitchResidence(home.Id);
+
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //鍒锋柊鐣岄潰
+                    this.ShowForm();
+
+                    this.CloseProgressBar();
+                });
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸澶囩姸鎬佷笂鎶__________________
+
+        /// <summary>
+        /// 娣诲姞涓�鑸澶囩姸鎬佷笂鎶ヤ簨浠�
+        /// </summary>
+        private void AddNormalDeviceReportEvent()
+        {
+            //璁惧灞炴�т笂鎶�(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceStatus", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //澶勭悊涓�鑸澶囩殑涓婃姤鏁版嵁
+                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    if (this.dicDeviceCardControl.ContainsKey(mainKeys) == true)
+                    {
+                        //鍒锋柊鍗$墖淇℃伅
+                        var locadevice = LocalDevice.Current.GetDevice(mainKeys);
+                        //宸茬粡鎺ユ敹鍒扮綉鍏崇殑鍙嶉 2020.05.09:鍒犻櫎Ack涓婚
+                        this.dicDeviceCardControl[mainKeys].SetHadGetResponeResultStatu();
+                        //鍒锋柊鎺т欢
+                        if (locadevice.Type != DeviceType.IASZone)
+                        {
+                            //浼犳劅鍣ㄤ笉闇�瑕佸睘鎬т笂鎶�(浣嗘槸閭d釜鐞冨瀷浼犳劅鍣ㄥ眳鐒朵細灞炴�т笂鎶�)
+                            this.dicDeviceCardControl[mainKeys].RefreshControlInfo(locadevice);
+                        }
+                    }
+                }, ShowErrorMode.NO);
+            });
+
+            //璁惧鍦ㄧ嚎涓婃姤(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) =>
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    if (this.dicDeviceCardControl.ContainsKey(mainKeys) == true)
+                    {
+                        //鍒锋柊鍗$墖鐘舵��
+                        bool bolOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(report);
+                        this.dicDeviceCardControl[mainKeys].SetCardOnlineStatu(bolOnline);
+                        return;
+                    }
+
+                }, ShowErrorMode.NO);
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 浼犳劅鍣ㄧ姸鎬佷笂鎶____________________
+
+        /// <summary>
+        /// 娣诲姞浼犳劅鍣ㄧ姸鎬佷笂鎶ヤ簨浠�
+        /// </summary>
+        private void AddSensorDeviceReportEvent()
+        {
+            //浼犳劅鍣ㄤ笂鎶�(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (report) =>
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //澶勭悊浼犳劅鍣ㄤ笂鎶ユ暟鎹�
+                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    if (this.dicDeviceCardControl.ContainsKey(mainKeys) == true)
+                    {
+                        //寮�鍚崱鐗囬棯鐑佺壒鏁�
+                        this.dicDeviceCardControl[mainKeys].StartCardLightAppeal();
+                    }
+
+                }, ShowErrorMode.NO);
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鍒囨崲妤煎眰___________________________
+
+        /// <summary>
+        /// 鏄剧ず閫夋嫨妤煎眰鐨勭晫闈�
+        /// </summary>
+        private void ShowSelectFloorForm(NormalViewControl btnFloor)
+        {
+            var floorFL = new Category.SelectFloorForm();
+            floorFL.CurFloorId = Config.Instance.Home.CurrentFloorId;
+            this.AddChidren(floorFL);
+            floorFL.Init(35, 153);
+            floorFL.FloorAction = (floorId) =>
+            {
+                btnFloor.Text = HdlResidenceLogic.Current.GetFloorNameById(floorId);
+                Config.Instance.Home.CurrentFloorId = floorId;
+                HdlRoomLogic.Current.NowMainPageRoom = HdlRoomLogic.Current.GetLoveRoom();
+                //鍒嗙被鐣岄潰闇�瑕佸埛鏂�
+                UserView.UserPage.Instance.RefreshCategoryForm = true;
+                this.ShowForm();
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+        /// <summary>
+        /// 鐣岄潰鍏抽棴
+        /// </summary>
+        public override void CloseFormBefore()
+        {
+            //鎶婇潤鎬佸彉閲忕殑杩欎釜涓滆タ缃┖
+            Instance = null;
+
+            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceOnline");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceStatus");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewSensor");
+
+            base.CloseFormBefore();
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 妫�娴嬫槸鍚︾粦瀹氭湁缃戝叧
+        /// </summary>
+        private bool CheckHadBindGateway()
+        {
+            //鑾峰彇鏈湴宸茬粡缁戝畾鐨勭綉鍏�
+            var gatewayList = HdlGatewayLogic.Current.GetAllLocalGateway();
+            if (gatewayList.Count == 0)
+            {
+                return false;
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栭粯璁ゆゼ灞侷D
+        /// </summary>
+        private void InitDefultFloorId()
+        {
+            if (Config.Instance.Home.CurrentFloorId != string.Empty)
+            {
+                return;
+            }
+            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
+            foreach (var floorId in dicFloor.Keys)
+            {
+                Config.Instance.Home.CurrentFloorId = floorId;
+                break;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+        /// <summary>
+        /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
+        /// </summary>
+        public override int FormActionAgainEvent()
+        {
+            CommonPage.Instance.IsDrawerLockMode = false;
+            return 1;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0