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/MainPage/UnallocatedRoomForm.cs |  247 ++++++++++++++++++++++++++-----------------------
 1 files changed, 131 insertions(+), 116 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs b/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs
index a238bb8..b50d6ec 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs
@@ -1,20 +1,24 @@
-锘縰sing System;
-using System.Collections.Generic;
-using Shared.Common;
-using Shared.Phone.Device.CommonForm;
+锘縰sing System;
+using System.Collections.Generic;
+using Shared.Common;
+using Shared.Phone.Device.CommonForm;
 using Shared.Phone.UserCenter;
-using Shared.Phone.UserView;
-using ZigBee.Device;
-
-namespace Shared.Phone.MainPage
-{
+using Shared.Phone.UserView;
+using ZigBee.Device;
+
+namespace Shared.Phone.MainPage
+{
     /// <summary>
     /// 鏈垎閰嶇殑绠$悊鐣岄潰
-    /// </summary>
-    public class UnallocatedRoomForm : EditorCommonForm
+    /// </summary>
+    public class UnallocatedRoomForm : EditorCommonForm
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
+        /// <summary>
+        /// 鐣岄潰鍏抽棴浜嬩欢
+        /// </summary>
+        public Action FormCloseEvent = null;
         /// <summary>
         /// 娣诲姞鍒� 鐨勮儗鏅浘鎺т欢
         /// </summary>
@@ -22,7 +26,7 @@
         /// <summary>
         /// 鍔熻兘鐨勬甯冩帶浠�
         /// </summary>
-        private FrameLayout DeviceBodyTableControl = null;
+        private NormalFrameLayout DeviceBodyTableControl = null;
         /// <summary>
         /// 鍦烘櫙鐨勫垪琛ㄦ帶浠�
         /// </summary>
@@ -34,7 +38,7 @@
         /// <summary>
         /// 鍦烘櫙鐨勬甯冩帶浠�
         /// </summary>
-        private FrameLayout SceneBodyTableControl = null;
+        private NormalFrameLayout SceneBodyTableControl = null;
         /// <summary>
         /// 鍏ㄩ�夋帶浠�
         /// </summary>
@@ -54,7 +58,7 @@
         /// <summary>
         /// 鍏ㄩ儴鍒嗙粍鐨勮澶囦俊鎭�
         /// </summary>
-        private Dictionary<int, DeviceRowInfo> dicGroupDevice = null;
+        private Dictionary<string, DeviceRowInfo> dicGroupDevice = null;
         /// <summary>
         /// 鏄惁宸茬粡鏀瑰彉浜嗘暟鎹�
         /// </summary>
@@ -68,46 +72,46 @@
 
         #region 鈻� 鍒濆鍖朹____________________________
 
-        /// <summary>
-        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
-        /// </summary>
-        public void ShowForm()
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        public void ShowForm()
         {
             //鍒濆鍖栧ご閮ㄦ帶浠�
-            this.InitTopFrameLayout();
-            //鍒濆鍖栦腑閮ㄦ帶浠�
-            this.InitBodyFrameLayout();
-
-            //璁剧疆澶撮儴淇℃伅
-            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.Unallocated));
-
-            //鍒濆鍖栧叏閫夋帶浠�
-            this.InitAllSelectControl();
-
-            //鍒濆鍖栦腑閮ㄤ俊鎭�
-            this.InitMiddleFrame();
-        }
-
-        /// <summary>
-        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
-        /// </summary>
-        private void InitMiddleFrame()
+            this.InitTopFrameLayout();
+            //鍒濆鍖栦腑閮ㄦ帶浠�
+            this.InitBodyFrameLayout();
+
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.Unallocated));
+
+            //鍒濆鍖栧叏閫夋帶浠�
+            this.InitAllSelectControl();
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
         {
             var tabControl = new SceneFunctionSwitchControl();
             tabControl.Y = Application.GetRealHeight(40);
             bodyFrameLayout.AddChidren(tabControl);
 
             //鍒濆鍖栧満鏅甯�
-            this.SceneBodyTableControl = new FrameLayout();
-            SceneBodyTableControl.Y = tabControl.Bottom;
-            SceneBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
+            this.SceneBodyTableControl = new NormalFrameLayout();
+            SceneBodyTableControl.Y = tabControl.Bottom;
+            SceneBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
             bodyFrameLayout.AddChidren(SceneBodyTableControl);
             //鍒濆鍖栬澶囨甯�
-            this.DeviceBodyTableControl = new FrameLayout();
-            DeviceBodyTableControl.Y = tabControl.Bottom;
-            DeviceBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
-            bodyFrameLayout.AddChidren(DeviceBodyTableControl);
-
+            this.DeviceBodyTableControl = new NormalFrameLayout();
+            DeviceBodyTableControl.Y = tabControl.Bottom;
+            DeviceBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
+            bodyFrameLayout.AddChidren(DeviceBodyTableControl);
+
             tabControl.SelectTabEvent += (index) =>
             {
                 //鍦烘櫙
@@ -126,17 +130,17 @@
                     //妫�娴嬪悇鎺т欢鐘舵��
                     this.CheckControlsStatu(this.nowSelectDeviceInfo);
                 }
-            };
-
+            };
+
             //寮�濮嬪垵濮嬪寲鍦烘櫙鍔熻兘鍒囨崲鎺т欢
             var listTitle = new List<string>();
             listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
             listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
-            //浠栦細鑷姩鍥炶皟浜嬩欢
-            tabControl.InitControl(listTitle);
+            //浠栦細鑷姩鍥炶皟浜嬩欢
+            tabControl.InitControl(listTitle);
         }
 
-        #endregion
+        #endregion
 
         #region 鈻� 鍦烘櫙鍒嗘敮___________________________
 
@@ -176,13 +180,13 @@
                 SceneBodyTableControl.AddChidren(listSceneView);
 
                 var listScene = HdlSceneLogic.Current.GetUnalloctedScenes();
-                if (listScene == null || listScene.Count == 0) { return; }
+                if (listScene.Count == 0) { return; }
 
                 foreach (var data in listScene)
                 {
                     //鍦烘櫙鍥剧墖
                     var frameContr = new ScenePictrueControl();
-                    listSceneView.AddChidrenFrame(frameContr);
+                    listSceneView.AddChidren(frameContr);
                     frameContr.InitControl(data);
 
                     //娣诲姞閫夋嫨鎺т欢
@@ -193,7 +197,7 @@
                     frameContr.CollectEvent += (collect) =>
                     {
                         //濡傛灉褰撳墠鏄敹钘忔埧闂�,鍒欓渶瑕佸埛鏂颁富椤�
-                        if (HdlRoomLogic.Current.CurrentRoom.IsLove == true)
+                        if (HdlRoomLogic.Current.NowMainPageRoom.IsLove == true)
                         {
                             this.dataHadChanged = true;
                         }
@@ -218,7 +222,7 @@
                 //淇冧娇瀹冭秴杩囨椂,鑳藉寰�涓婃粦
                 var frameTemp = new FrameLayout();
                 frameTemp.Height = Application.GetRealHeight(202 + 23);
-                listSceneView.AddChidrenFrame(frameTemp);
+                listSceneView.AddChidren(frameTemp);
             });
         }
 
@@ -267,7 +271,7 @@
 
                 //璁惧鐨勮儗鏅鍣�
                 var frameDeviceBack = new FrameLayout();
-                frameDeviceBack.X = ControlCommonResourse.XXLeft;
+                frameDeviceBack.X = HdlControlResourse.XXLeft;
                 frameDeviceBack.Y = Application.GetRealHeight(369);
                 frameDeviceBack.BackgroundColor = UserCenterColor.Current.White;
                 frameDeviceBack.Width = bodyFrameLayout.Width;
@@ -296,7 +300,7 @@
         {
             //澶撮儴鐨勭櫧鑹茶儗鏅�
             var functionBack1 = new FrameLayout();
-            functionBack1.X = ControlCommonResourse.XXLeft;
+            functionBack1.X = HdlControlResourse.XXLeft;
             functionBack1.Y = Application.GetRealHeight(55);
             functionBack1.Height = Application.GetRealHeight(160);
             functionBack1.Width = Application.GetRealWidth(1028);
@@ -304,7 +308,7 @@
             DeviceBodyTableControl.AddChidren(functionBack1);
             functionBack1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
             var functionBack2 = new FrameLayout();
-            functionBack2.X = ControlCommonResourse.XXLeft;
+            functionBack2.X = HdlControlResourse.XXLeft;
             functionBack2.Y = functionBack1.Bottom - Application.GetRealHeight(50);
             functionBack2.Height = Application.GetRealHeight(279 - 160 + 50);
             functionBack2.Width = Application.GetRealWidth(1028);
@@ -314,17 +318,17 @@
 
             //宸﹀彸婊戝姩鐨勬帶浠�
             var HorizontalView = new HorizontalScrolViewLayout();
-            HorizontalView.X = Application.GetRealWidth(CommonFormResouce.X_Left);
+            HorizontalView.X = HdlControlResourse.XXLeft;
             HorizontalView.Y = Application.GetRealHeight(55);
             HorizontalView.Height = Application.GetRealHeight(279);
             HorizontalView.Width = Application.GetRealWidth(1028);
             DeviceBodyTableControl.AddChidren(HorizontalView);
 
             //涓婁竴娆¢�夋嫨鐨勮彍鍗�
-            Controls.DeviceFunctionUnallocatedControl oldSelectContr = null;
-            foreach (int Textid in this.dicGroupDevice.Keys)
+            Controls.DeviceFunctionMenuControl oldSelectContr = null;
+            foreach (string strText in this.dicGroupDevice.Keys)
             {
-                var rowInfo = dicGroupDevice[Textid];
+                var rowInfo = dicGroupDevice[strText];
 
                 //璁惧绫诲瀷鐨勫鍣�
                 var devieFrame = new FrameLayout();
@@ -332,13 +336,13 @@
                 HorizontalView.AddChidren(devieFrame);
 
                 //鑿滃崟鍥剧墖鎺т欢
-                var deviceObjContr = new Controls.DeviceFunctionUnallocatedControl();
+                var deviceObjContr = new Controls.DeviceFunctionMenuControl();
                 devieFrame.AddChidren(deviceObjContr);
-                deviceObjContr.InitControl(Language.StringByID(Textid), rowInfo.IconPath, rowInfo.IconPathSelected, rowInfo.listDeviceKeys);
+                deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected);
                 deviceObjContr.ButtonClickEvent += (sender, e) =>
                 {
                     //閫夋嫨鐨勬槸鍚屼竴涓笢瑗跨殑璇�,涓嶅鐞�
-                    if (this.nowSelectDeviceInfo.TextId != rowInfo.TextId)
+                    if (this.nowSelectDeviceInfo.Text != rowInfo.Text)
                     {
                         //涓婁竴娆$殑鑿滃崟鍙栨秷,鏈鑿滃崟閫夋嫨
                         oldSelectContr.SetSelectStatu(false);
@@ -387,7 +391,7 @@
             //鍒濆鍖栬澶囧垪琛ㄦ帶浠�
             foreach (var deviceKey in rowInfo.listDeviceKeys)
             {
-                var device = LocalDevice.Current.GetDevice(deviceKey);
+                var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKey);
                 var deviceRow = new Controls.DeviceSelectUnallocatedControl(listDeviceView.rowSpace / 2);
                 listDeviceView.AddChidren(deviceRow);
                 deviceRow.InitControl(device);
@@ -485,12 +489,12 @@
                             if (this.canSelectAll == true)
                             {
                                 //娣诲姞缂撳瓨
-                                dicSelectDevice[LocalDevice.Current.GetDeviceMainKeys(device)] = device;
+                                dicSelectDevice[HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device)] = device;
                             }
                             else
                             {
                                 //绉婚櫎缂撳瓨
-                                dicSelectDevice.Remove(LocalDevice.Current.GetDeviceMainKeys(device));
+                                dicSelectDevice.Remove(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
                             }
                         }
                     }
@@ -500,49 +504,56 @@
             };
         }
 
-        #endregion
+        #endregion
 
-        #region 鈻� [娣诲姞鍒癩鎺т欢_______________________
-
+        #region 鈻� [娣诲姞鍒癩鎺т欢_______________________
+
         /// <summary>
         /// 鍒濆鍖栨坊鍔犲埌鎺т欢
-        /// </summary>
+        /// </summary>
         private void InitAddToControl()
         {
-            //娣诲姞鍒� 鐨勮儗鏅浘鎺т欢
-            this.frameAddBackGroud = new FrameLayoutStatuControl();
-            frameAddBackGroud.UseClickStatu = false;
-            frameAddBackGroud.Height = Application.GetRealHeight(202);
-            frameAddBackGroud.Gravity = Gravity.BottomCenter;
-            frameAddBackGroud.BackgroundImagePath = "Room/AddBackground.png";
-            bodyFrameLayout.AddChidren(frameAddBackGroud);
-            frameAddBackGroud.Visible = false;
-
-            //娣诲姞鍒� 鎸夐挳
-            var btnAdd = new NormalViewControl(1034, 156, true);
-            btnAdd.Gravity = Gravity.Center;
+            //娣诲姞鍒� 鐨勮儗鏅浘鎺т欢
+            this.frameAddBackGroud = new FrameLayoutStatuControl();
+            frameAddBackGroud.UseClickStatu = false;
+            frameAddBackGroud.Height = Application.GetRealHeight(202);
+            frameAddBackGroud.Gravity = Gravity.BottomCenter;
+            frameAddBackGroud.BackgroundImagePath = "Room/AddBackground.png";
+            bodyFrameLayout.AddChidren(frameAddBackGroud);
+            frameAddBackGroud.Visible = false;
+
+            //娣诲姞鍒� 鎸夐挳
+            var btnAdd = new NormalViewControl(1034, 156, true);
+            btnAdd.Gravity = Gravity.Center;
             btnAdd.BackgroundColor = UserCenterColor.Current.White;
-            btnAdd.TextColor = ZigbeeColor.Current.GXCTextSelectedColor4;
-            btnAdd.TextAlignment = TextAlignment.Center;
-            btnAdd.TextID = R.MyInternationalizationString.AddTo;
-            btnAdd.TextSize = 17;
-            btnAdd.Radius = (uint)Application.GetRealHeight(35);
-            frameAddBackGroud.AddChidren(btnAdd, ChidrenBindMode.BindEventOnly);
+            btnAdd.TextColor = ZigbeeColor.Current.GXCTextSelectedColor4;
+            btnAdd.TextAlignment = TextAlignment.Center;
+            btnAdd.TextID = R.MyInternationalizationString.AddTo;
+            btnAdd.TextSize = 17;
+            btnAdd.Radius = (uint)Application.GetRealHeight(35);
+            frameAddBackGroud.AddChidren(btnAdd, ChidrenBindMode.BindEvent);
             frameAddBackGroud.ButtonClickEvent += (sender, e) =>
             {
-                var selectZone = new SelectZone();
-                selectZone.title = Language.StringByID(R.MyInternationalizationString.AddTo);
-                selectZone.Init();
-                selectZone.ZoneAction += (selectRoom) =>
-                {
-                    //鍙樻洿浜嗗綋鍓嶆埧闂寸殑涓滆タ,涓婚〉闇�瑕佸埛鏂�
-                    if (HdlRoomLogic.Current.CurrentRoom.Id == selectRoom.Id)
+                HdlControlLogic.Current.ShowBottomListRoomView(string.Empty, Language.StringByID(R.MyInternationalizationString.AddTo), (selectId, selectName) =>
+                {
+                    if (selectId == string.Empty)
+                    {
+                        //閫夋嫨鐨勬槸鏈垎閰�
+                        return;
+                    }
+                    //鍙樻洿浜嗗綋鍓嶆埧闂寸殑涓滆タ,涓婚〉闇�瑕佸埛鏂�
+                    if (HdlRoomLogic.Current.NowMainPageRoom.Id == selectId)
                     {
                         this.dataHadChanged = true;
-                    }
-                    //淇濆瓨閫夋嫨鐨勮澶囧拰鍦烘櫙
-                    this.SaveSelectDeviceAndScene(selectRoom);
-                };
+                    }
+                    //淇濆瓨閫夋嫨鐨勮澶囧拰鍦烘櫙
+                    var room = HdlRoomLogic.Current.GetRoomById(selectId);
+                    this.SaveSelectDeviceAndScene(room);
+                    //鍒嗙被鐣岄潰闇�瑕佸埛鏂�
+                    UserPage.Instance.RefreshCategoryForm = true;
+                    //涓婁紶绌洪棿鍖哄煙淇℃伅
+                    HdlRoomLogic.Current.SetRoomInfoToGateway();
+                });
             };
         }
 
@@ -618,29 +629,29 @@
         /// 鑾峰彇鍒嗙粍鍚庣殑璁惧
         /// </summary>
         /// <returns></returns>
-        private Dictionary<int, DeviceRowInfo> GetAllGroupDevice()
+        private Dictionary<string, DeviceRowInfo> GetAllGroupDevice()
         {
             //鍏ㄩ儴鐨勮澶�
             var listDevice = HdlRoomLogic.Current.GetUnalloctedDevice();
             //鏍规嵁璁惧鎵�灞炵被鍨嬫帓搴�
-            listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice);
-            var dic = new Dictionary<int, DeviceRowInfo>();
+            listDevice = HdlDeviceCommonLogic.Current.SortDeviceByBelongType(listDevice);
+            var dic = new Dictionary<string, DeviceRowInfo>();
             foreach (var device in listDevice)
             {
-                var typeInfo = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
+                var typeInfo = HdlDeviceCommonLogic.Current.GetDeviceBelongEnumInfo(device);
                 //鎸夋墍灞濱D鍒嗙粍
-                if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
+                if (dic.ContainsKey(typeInfo.BeloneText) == false)
                 {
-                    dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
+                    dic[typeInfo.BeloneText] = new DeviceRowInfo();
                     string path1 = string.Empty;
                     string path2 = string.Empty;
                     //鑾峰彇鍥剧墖
-                    Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2);
-                    dic[typeInfo.BeloneTextId].IconPath = path1;
-                    dic[typeInfo.BeloneTextId].IconPathSelected = path2;
-                    dic[typeInfo.BeloneTextId].TextId = typeInfo.BeloneTextId;
+                    HdlDeviceCommonLogic.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
+                    dic[typeInfo.BeloneText].IconPath = path1;
+                    dic[typeInfo.BeloneText].IconPathSelected = path2;
+                    dic[typeInfo.BeloneText].Text = typeInfo.BeloneText;
                 }
-                dic[typeInfo.BeloneTextId].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
+                dic[typeInfo.BeloneText].listDeviceKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
             }
             return dic;
         }
@@ -654,12 +665,16 @@
         /// </summary>
         public override void CloseFormBefore()
         {
+            //璋冪敤鍥炶皟浜嬩欢
+            this.FormCloseEvent?.Invoke();
+            this.FormCloseEvent = null;
+
             if (this.dataHadChanged == true)
             {
                 HdlThreadLogic.Current.RunMainInThread(() =>
                 {
                     //鍒锋柊涓婚〉
-                    this.LoadFormMethodByName("HomeMainPageForm", "RefreshBodyView");
+                    HomeMainPageForm.Instance?.RefreshBodyView();
                 });
             }
             base.CloseFormBefore();
@@ -742,9 +757,9 @@
         private class DeviceRowInfo
         {
             /// <summary>
-            /// 鏂囨湰ID,鐩墠鐢ㄦ潵鍋氫富閿�
+            /// 鏂囨湰,鐩墠鐢ㄦ潵鍋氫富閿�
             /// </summary>
-            public int TextId = 0;
+            public string Text = string.Empty;
             /// <summary>
             /// 鍥炬爣
             /// </summary>
@@ -759,6 +774,6 @@
             public List<string> listDeviceKeys = new List<string>();
         }
 
-        #endregion
-    }
-}
+        #endregion
+    }
+}

--
Gitblit v1.8.0