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/Category/AdjustTargetAddDeviceForm.cs |  167 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 117 insertions(+), 50 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Category/AdjustTargetAddDeviceForm.cs b/ZigbeeApp/Shared/Phone/Category/AdjustTargetAddDeviceForm.cs
index df30573..969c537 100755
--- a/ZigbeeApp/Shared/Phone/Category/AdjustTargetAddDeviceForm.cs
+++ b/ZigbeeApp/Shared/Phone/Category/AdjustTargetAddDeviceForm.cs
@@ -42,6 +42,10 @@
         /// 璁惧鍒楄〃鎺т欢
         /// </summary>
         private VerticalListControl listDeviceView = null;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬ゼ灞�
+        /// </summary>
+        private string nowSelectFloorId = string.Empty;
 
         #endregion
 
@@ -57,6 +61,8 @@
 
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddFunction));
+            //鍒濆鍖栧彸涓婅鐨勬帶浠�
+            this.InitTopRightMenuControl();
             //鍒濆鍖栦腑閮ㄤ俊鎭�
             this.InitMiddleFrame();
         }
@@ -66,8 +72,58 @@
         /// </summary>
         private void InitMiddleFrame()
         {
+            //娓呯┖body
+            this.ClearBodyFrame();
             //鍒濆鍖栨埧闂磋彍鍗曟帶浠�
             this.InitRoomMenuControl();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧彸涓婅鐨勬帶浠�
+        /// </summary>
+        private void InitTopRightMenuControl()
+        {
+            //鑾峰彇妤煎眰
+            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
+            if (dicFloor.Count == 0)
+            {
+                return;
+            }
+            var btnIconContr = new MostRightIconControl(69, 69);
+            btnIconContr.UnSelectedImagePath = "Item/Drop_Down.png";
+            topFrameLayout.AddChidren(btnIconContr);
+            btnIconContr.InitControl();
+
+            var btnFloor = new NormalViewControl(300, 69, true);
+            btnFloor.Gravity = Gravity.CenterVertical;
+            btnFloor.X = btnIconContr.X + btnIconContr.btnIcon.X - Application.GetRealWidth(300);
+            btnFloor.TextAlignment = TextAlignment.CenterRight;
+            topFrameLayout.AddChidren(btnFloor);
+
+            foreach (var floorId in dicFloor.Keys)
+            {
+                //绗竴涓ゼ灞�
+                this.nowSelectFloorId = floorId;
+                btnFloor.Text = dicFloor[floorId];
+                break;
+            }
+
+            btnIconContr.ButtonClickEvent += (sender, e) =>
+            {
+                //妤煎眰鑿滃崟
+                var contr = new TopRightFloorMenuControl(dicFloor.Count, 2, this.nowSelectFloorId, Language.StringByID(R.MyInternationalizationString.SelectFloor));
+                foreach (var floorId in dicFloor.Keys)
+                {
+                    contr.AddRowMenu(floorId, () =>
+                    {
+                        //璁板綍璧烽�夋嫨鐨処D
+                        this.nowSelectFloorId = floorId;
+                        btnFloor.Text = dicFloor[this.nowSelectFloorId];
+                        //鍒濆鍖栦腑閮ㄤ俊鎭�
+                        this.InitMiddleFrame();
+                    });
+                }
+            };
         }
 
         #endregion
@@ -98,7 +154,10 @@
             roomSwitchContr.SelectRoomEvent += (selectRoom) =>
             {
                 //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
-                this.deviceFunctionMenuContr?.RemoveAll();
+                if (this.deviceFunctionMenuContr != null && this.deviceFunctionMenuContr.Parent != null)
+                {
+                    this.deviceFunctionMenuContr.RemoveAll();
+                }
                 this.listDeviceView?.RemoveAll();
 
                 HdlThreadLogic.Current.RunMainInThread(() =>
@@ -116,7 +175,10 @@
             this.btnFinishControl = new BottomClickButton();
             btnFinishControl.TextID = R.MyInternationalizationString.uFinish;
             bodyFrameLayout.AddChidren(btnFinishControl);
-            btnFinishControl.Visible = false;
+            if (this.dicNewListTask == null || this.dicNewListTask.Count == 0)
+            {
+                btnFinishControl.Visible = false;
+            }
             btnFinishControl.ButtonClickEvent += (sender, e) =>
             {
                 //鍥炶皟鍑芥暟
@@ -136,26 +198,30 @@
         /// <returns></returns>
         private List<Room> GetCanShowRoomList()
         {
-            //鍏堝皢鍒楄〃Dictionary鍖�
-            this.dicNewListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
-            this.dicOldListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
-            foreach (var data in this.listAdjustTarget)
+            if (this.dicNewListTask == null)
             {
-                if (data.Type == 0)
+                //鍏堝皢鍒楄〃Dictionary鍖�
+                this.dicNewListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
+                this.dicOldListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
+                foreach (var data in this.listAdjustTarget)
                 {
-                    //鍙璁惧
-                    string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
-                    dicOldListTask[mainkey] = data.TaskList;
+                    if (data.Type == 0)
+                    {
+                        //鍙璁惧
+                        string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
+                        dicOldListTask[mainkey] = data.TaskList;
+                    }
                 }
             }
+          
             //褰撳墠妤煎眰鐨勫叏閮ㄦ埧闂�
-            var lisrRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
+            var lisrRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(this.nowSelectFloorId);
             var listShowRoom = new List<Room>();
             foreach (var room in lisrRoom)
             {
                 foreach (var mainkey in room.ListDevice)
                 {
-                    var device = LocalDevice.Current.GetDevice(mainkey);
+                    var device = HdlDeviceCommonLogic.Current.GetDevice(mainkey);
                     if (this.CheckDeviceCanShow(device) == true)
                     {
                         //杩欎釜璁惧鏈湴瀛樺湪,骞朵笖瀹冭繕娌℃湁鍔犲叆鍒版墽琛岀洰鏍囧垪琛�,鍒欒繖涓埧闂村彲浠ユ樉绀�
@@ -181,18 +247,18 @@
             var dicGroupDevice = this.GetAllGroupDevice(room);
 
             //鍙垵濮嬪寲涓�娆�
-            if (this.deviceFunctionMenuContr == null)
+            if (this.deviceFunctionMenuContr == null || this.deviceFunctionMenuContr.Parent == null)
             {
                 //璁惧鑿滃崟鐨勭櫧鑹茶儗鏅�
                 var functionBack1 = new FrameLayout();
-                functionBack1.X = ControlCommonResourse.XXLeft;
+                functionBack1.X = HdlControlResourse.XXLeft;
                 functionBack1.Height = Application.GetRealHeight(160);
                 functionBack1.Width = Application.GetRealWidth(1028);
                 functionBack1.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
                 functionBodyView.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);
@@ -202,14 +268,14 @@
 
                 //璁惧鑿滃崟鐨勫乏鍙虫粦鍔ㄧ殑鎺т欢
                 this.deviceFunctionMenuContr = new HorizontalScrolViewLayout();
-                deviceFunctionMenuContr.X = ControlCommonResourse.XXLeft;
+                deviceFunctionMenuContr.X = HdlControlResourse.XXLeft;
                 deviceFunctionMenuContr.Height = Application.GetRealHeight(279);
                 deviceFunctionMenuContr.Width = Application.GetRealWidth(1028);
                 functionBodyView.AddChidren(deviceFunctionMenuContr);
 
                 //璁惧鐨勮儗鏅鍣�
                 var frameDeviceBack = new FrameLayout();
-                frameDeviceBack.X = ControlCommonResourse.XXLeft;
+                frameDeviceBack.X = HdlControlResourse.XXLeft;
                 frameDeviceBack.Y = deviceFunctionMenuContr.Bottom + Application.GetRealHeight(35);
                 frameDeviceBack.BackgroundColor = UserCenterColor.Current.White;
                 frameDeviceBack.Width = bodyFrameLayout.Width;
@@ -228,10 +294,10 @@
 
             //涓婁竴娆¢�夋嫨鐨勮彍鍗曞拰鏁版嵁
             DeviceRowInfo nowSelectDeviceInfo = null;
-            MainPage.Controls.DeviceFunctionUnallocatedControl oldSelectContr = null;
-            foreach (int Textid in dicGroupDevice.Keys)
+            MainPage.Controls.DeviceFunctionMenuControl oldSelectContr = null;
+            foreach (string strText in dicGroupDevice.Keys)
             {
-                var rowInfo = dicGroupDevice[Textid];
+                var rowInfo = dicGroupDevice[strText];
 
                 //璁惧绫诲瀷鐨勫鍣�
                 var devieFrame = new FrameLayout();
@@ -239,9 +305,9 @@
                 deviceFunctionMenuContr.AddChidren(devieFrame);
 
                 //鑿滃崟鍥剧墖鎺т欢
-                var deviceObjContr = new MainPage.Controls.DeviceFunctionUnallocatedControl();
+                var deviceObjContr = new MainPage.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) =>
                 {
                     //閫夋嫨鐨勬槸鍚屼竴涓笢瑗跨殑璇�,涓嶅鐞�
@@ -256,7 +322,7 @@
                         HdlThreadLogic.Current.RunMainInThread(() =>
                         {
                             //鍒濆鍖栬澶囧垪琛ㄦ帶浠�
-                            this.InitListDeviceControls(listDeviceView, rowInfo, room);
+                            this.InitListDeviceControls(listDeviceView, rowInfo);
                         });
                     }
                 };
@@ -273,7 +339,7 @@
             if (nowSelectDeviceInfo != null)
             {
                 //鍒濆鍖栭粯璁ょ殑璁惧鍒楄〃鎺т欢
-                this.InitListDeviceControls(listDeviceView, nowSelectDeviceInfo, room);
+                this.InitListDeviceControls(listDeviceView, nowSelectDeviceInfo);
             }
         }
 
@@ -286,7 +352,7 @@
         /// </summary>
         /// <param name="listView"></param>
         /// <param name="rowInfo"></param>
-        private void InitListDeviceControls(VerticalListControl listView, DeviceRowInfo rowInfo, Room i_room)
+        private void InitListDeviceControls(VerticalListControl listView, DeviceRowInfo rowInfo)
         {
             //鍏堟竻绌�
             listView.RemoveAll();
@@ -294,7 +360,7 @@
             var listDevice = new List<CommonDevice>();
             for (int i = 0; i < rowInfo.listDeviceKeys.Count; i++)
             {
-                var device = LocalDevice.Current.GetDevice(rowInfo.listDeviceKeys[i]);
+                var device = HdlDeviceCommonLogic.Current.GetDevice(rowInfo.listDeviceKeys[i]);
                 if (device != null)
                 {
                     listDevice.Add(device);
@@ -325,10 +391,10 @@
         /// <param name="device"></param>
         private void AddDeviceRow(VerticalListControl listView, CommonDevice device)
         {
-            string mainkey = LocalDevice.Current.GetDeviceMainKeys(device);
+            string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
             //璁惧鎺т欢
             var rowDevice = new FrameRowControl(listView.rowSpace / 2);
-            rowDevice.RightOffset = ControlCommonResourse.XXLeft - Application.GetRealWidth(109);
+            rowDevice.RightOffset = HdlControlResourse.XXLeft - Application.GetRealWidth(109);
             listView.AddChidren(rowDevice);
 
             //璁惧鍥炬爣鑳屾櫙鎺т欢
@@ -345,22 +411,22 @@
             //璁惧鍥炬爣鎺т欢
             var btnDeviceIcon = new IconViewControl(78);
             btnDeviceIcon.Gravity = Gravity.Center;
-            Common.LocalDevice.Current.SetDeviceIconToControl(btnDeviceIcon, device);
+            HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnDeviceIcon, device);
             frameIconBackGroud.AddChidren(btnDeviceIcon);
             //閲嶆柊缁戝畾浜嬩欢
-            rowDevice.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEventOnly);
+            rowDevice.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEvent);
 
             //璁惧鍚嶅瓧
             var btnDeviceName = new NormalViewControl(600, 60, true);
             btnDeviceName.X = Application.GetRealWidth(181);
             btnDeviceName.Gravity = Gravity.CenterVertical;
-            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
-            rowDevice.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
+            btnDeviceName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
+            rowDevice.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
             btnDeviceName.Y += rowDevice.chidrenYaxis;
             //搴曠嚎
-            var btnBottomLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
+            var btnBottomLine = new NormalViewControl(Application.GetRealWidth(841), HdlControlResourse.BottomLineHeight, false);
             btnBottomLine.X = Application.GetRealWidth(181);
-            btnBottomLine.Y = rowDevice.Height - ControlCommonResourse.BottomLineHeight;
+            btnBottomLine.Y = rowDevice.Height - HdlControlResourse.BottomLineHeight;
             btnBottomLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             rowDevice.AddChidren(btnBottomLine, ChidrenBindMode.NotBind);
             //鍙崇澶�
@@ -390,7 +456,7 @@
         /// <param name="btnStatu"></param>
         private void ShowDeviceDetailSettion(CommonDevice device, NormalViewControl btnStatu)
         {
-            string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
+            string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
 
             List<Safeguard.TaskListInfo> listTaskinfo = null;
             if (dicNewListTask.ContainsKey(mainKeys) == true)
@@ -458,7 +524,7 @@
         /// <param name="listInfo"></param>
         private void AddSettionDataToMemory(CommonDevice device, List<Safeguard.TaskListInfo> listInfo)
         {
-            string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
+            string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
             if (listInfo == null || listInfo.Count == 0)
             {
                 //鎸囧畾涓烘棤鍔ㄤ綔妯″紡
@@ -490,7 +556,7 @@
         /// 鑾峰彇鍒嗙粍鍚庣殑璁惧
         /// </summary>
         /// <returns></returns>
-        private Dictionary<int, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
+        private Dictionary<string, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
         {
             //鍏ㄩ儴鐨勮澶�
             var listDeviceTemp = HdlRoomLogic.Current.GetRoomListDevice(room);
@@ -505,24 +571,24 @@
             }
 
             //鏍规嵁璁惧鎵�灞炵被鍨嬫帓搴�
-            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;
                     //鑾峰彇鍥剧墖
-                    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].TextId = typeInfo.BeloneText;
                 }
-                dic[typeInfo.BeloneTextId].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
+                dic[typeInfo.BeloneText].listDeviceKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
             }
             return dic;
         }
@@ -557,9 +623,10 @@
                 device.Type == DeviceType.DimmableLight ||//褰╃伅
                 device.Type == DeviceType.OnOffOutput ||//缁х數鍣�
                 device.Type == DeviceType.Thermostat ||//绌鸿皟
+                device.Type == DeviceType.ColorTemperatureLight ||//鑹叉俯鐏�
                 device.Type == DeviceType.WindowCoveringDevice)//绐楀笜
             {
-                string mainkey = LocalDevice.Current.GetDeviceMainKeys(device);
+                string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
                 return this.dicOldListTask.ContainsKey(mainkey) == false;
             }
             return false;
@@ -575,9 +642,9 @@
         private class DeviceRowInfo
         {
             /// <summary>
-            /// 鏂囨湰ID,鐩墠鐢ㄦ潵鍋氫富閿�
+            /// 鏂囨湰,鐩墠鐢ㄦ潵鍋氫富閿�
             /// </summary>
-            public int TextId = 0;
+            public string TextId = string.Empty;
             /// <summary>
             /// 鍥炬爣
             /// </summary>

--
Gitblit v1.8.0