From f71e74b5f0d2716fbf05da016cdaa18d64e09f80 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 31 十二月 2020 17:01:18 +0800
Subject: [PATCH] 又换完成最新门锁。空气质量传感器完成数据和基本配置功能。开发图表和自动化的同事可下载此代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs |  306 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 306 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs
new file mode 100755
index 0000000..506c793
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs
@@ -0,0 +1,306 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.DevicePanel
+{
+    /// <summary>
+    /// 鐜闈㈡澘鐨勭洰鏍囩晫闈�
+    /// </summary>
+    public class PanelFangyueEnvironmentTargetForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鍒楄〃鎺т欢
+        /// </summary>
+        private VerticalListControl listView = null;
+        /// <summary>
+        /// 鐩爣璁惧
+        /// </summary>
+        private CommonDevice deviceTarget = null;
+        /// <summary>
+        /// 缁戝畾鐨勭洰鏍囩殑涓婚敭(鍙兘缁戝畾涓�涓�)
+        /// </summary>
+        private string bindTargetKey = null;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬ゼ灞侷D
+        /// </summary>
+        private string nowSelectFloorId = string.Empty;
+        /// <summary>
+        /// 1锛氱┖璋冪洰鏍�  2锛氬湴鏆栫洰鏍�  3锛氭柊椋庣洰鏍�
+        /// </summary>
+        private int deviceDiv = -1;
+        /// <summary>
+        /// 鍙互鏄剧ず鐨勮澶囧璞� (Keys:鎴块棿ID)
+        /// </summary>
+        private Dictionary<string, List<CommonDevice>> dicShowDevice = new Dictionary<string, List<CommonDevice>>();
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_deviceTarget">鐩爣璁惧</param>
+        /// <param name="i_bindTargetKey">缁戝畾鐨勭洰鏍囩殑涓婚敭(鍙兘缁戝畾涓�涓�)</param>
+        /// <param name="i_div">1锛氱┖璋冪洰鏍�  2锛氬湴鏆栫洰鏍�  3锛氭柊椋庣洰鏍�</param>
+        public void ShowForm(CommonDevice i_deviceTarget, string i_bindTargetKey, int i_div)
+        {
+            this.deviceTarget = i_deviceTarget;
+            this.bindTargetKey = i_bindTargetKey;
+            this.deviceDiv = i_div;
+
+            if (i_div == 1)
+            {
+                //璁剧疆澶撮儴淇℃伅
+                base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAirConditionerTarget));
+            }
+            else if (i_div == 2)
+            {
+                //璁剧疆澶撮儴淇℃伅
+                base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFloorHeatingTarget));
+            }
+            else if (i_div == 3)
+            {
+                //璁剧疆澶撮儴淇℃伅
+                base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uNewWindTarget));
+            }
+
+            //鍒濆鍖栧彸涓婅鐨勬帶浠�
+            this.InitTopRightMenuControl();
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.nowSelectFloorId, false);
+                var listDataRoom = new List<Common.Room>();
+                for (int i = 0; i < listRoom.Count; i++)
+                {
+                    //妫�娴嬭兘鍚︽樉绀鸿鎴块棿
+                    if (this.CheckCanShowRoom(listRoom[i]) == true)
+                    {
+                        listDataRoom.Add(listRoom[i]);
+                    }
+                }
+
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    if (listDataRoom.Count > 0)
+                    {
+                        //鍒濆鍖栨埧闂村拰璁惧鍒楄〃
+                        this.InitRoomAndDeviceRow(listDataRoom);
+                    }
+                    else
+                    {
+                        //濡傛灉娌℃湁鍙互娣诲姞鐨勭洰鏍�
+                        bodyFrameLayout.RemoveAll();
+                        this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uNotHadAddTarget), "Item/NotShardPic.png", 383, 279);
+                    }
+                });
+            });
+        }
+
+        /// <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 TopRightMenuControl(dicFloor.Count, 2, Language.StringByID(R.MyInternationalizationString.SelectFloor));
+                foreach (var floorId in dicFloor.Keys)
+                {
+                    contr.AddRowMenu(dicFloor[floorId], "Floor/Floor.png", "Floor/FloorSelected.png", () =>
+                    {
+                        //璁板綍璧烽�夋嫨鐨処D
+                        this.nowSelectFloorId = floorId;
+                        this.bindTargetKey = string.Empty;
+
+                        btnFloor.Text = dicFloor[this.nowSelectFloorId];
+                        //鍒濆鍖栦腑閮ㄤ俊鎭�
+                        this.InitMiddleFrame();
+                    });
+                }
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 鎴块棿鍜岃澶囧垪琛╛____________________
+
+        /// <summary>
+        /// 鍒濆鍖栨埧闂村拰璁惧鍒楄〃
+        /// </summary>
+        /// <param name="listRoom">鍙互鏄剧ず鐨勬埧闂村璞�</param>
+        private void InitRoomAndDeviceRow(List<Common.Room> listRoom)
+        {
+            //鎴块棿鍒楄〃鎺т欢
+            var roomContr = new RoomDeviceGroupMenuControl(listRoom);
+            bodyFrameLayout.AddChidren(roomContr);
+
+            //鍒楄〃鎺т欢
+            this.listView = new VerticalListControl(23);
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            listView.Height = bodyFrameLayout.Height - roomContr.Height;
+            listView.Y = roomContr.Bottom;
+            bodyFrameLayout.AddChidren(listView);
+
+            //淇濆瓨
+            var btnSave = new BottomClickButton();
+            btnSave.TextID = R.MyInternationalizationString.uSave;
+            bodyFrameLayout.AddChidren(btnSave);
+            btnSave.ButtonClickEvent += (sender, e) =>
+            {
+                //淇濆瓨鐩爣璁惧
+                this.SaveTargetDevice();
+            };
+
+            roomContr.SelectRoomEvent += (selectRoom) =>
+            {
+                HdlThreadLogic.Current.RunMainInThread(() =>
+                {
+                    //娣诲姞璁惧琛�
+                    this.AddDeviceRow(selectRoom.Id);
+                });
+            };
+            //鎵ц鍒濆鍖栨埧闂存帶浠�
+            roomContr.InitControl();
+        }
+
+        /// <summary>
+        /// 娣诲姞璁惧琛�
+        /// </summary>
+        /// <param name="roomId"></param>
+        private void AddDeviceRow(string roomId)
+        {
+            //鍏堟竻绌�
+            this.listView.RemoveAll();
+            listView.RecoverHeight();
+
+            DeviceSimpleSelectControl oldSelectContr = null;
+            var listDevice = this.dicShowDevice[roomId];
+            for (int i = 0; i < listDevice.Count; i++)
+            {
+                string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(listDevice[i]);
+                var contr = new DeviceSimpleSelectControl(listDevice[i], false, this.listView.rowSpace / 2);
+                listView.AddChidren(contr);
+                contr.InitControl();
+                if (i != listDevice.Count - 1)
+                {
+                    //搴曠嚎
+                    contr.AddBottomLine();
+                }
+                contr.ButtonClickEvent += (sender, e) =>
+                {
+                    contr.IsSelected = !contr.IsSelected;
+                    //閫夋嫨浜嗗埆鐨勮澶�
+                    if (contr.IsSelected == true)
+                    {
+                        if (oldSelectContr != null)
+                        {
+                            oldSelectContr.IsSelected = false;
+                        }
+                        oldSelectContr = contr;
+                        this.bindTargetKey = mainKey;
+                    }
+                    //鍙栨秷閫夋嫨
+                    else
+                    {
+                        oldSelectContr = null;
+                        this.bindTargetKey = string.Empty;
+                    }
+                };
+                if (this.bindTargetKey == mainKey)
+                {
+                    //杩欎釜鏄畠涔嬪墠缁戝畾鐨勮澶�
+                    contr.ButtonClickEvent(null, null);
+                }
+            }
+            //璋冩暣鐪熷疄楂樺害
+            listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
+        }
+
+        #endregion
+
+        #region 鈻� 淇濆瓨鏁版嵁___________________________
+
+        /// <summary>
+        /// 淇濆瓨鐩爣璁惧
+        /// </summary>
+        private void SaveTargetDevice()
+        {
+            this.CloseForm();
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 妫�娴嬭鎴块棿鑳藉惁鏄剧ず
+        /// </summary>
+        /// <param name="room"></param>
+        /// <param name="i_div"></param>
+        /// <returns></returns>
+        private bool CheckCanShowRoom(Common.Room room)
+        {
+            bool canShow = false;
+            //鍏堟竻绌�
+            this.dicShowDevice[room.Id] = new List<CommonDevice>();
+
+            foreach (var deviceKeys in room.ListDevice)
+            {
+                var device = Common.LocalDevice.Current.GetDevice(deviceKeys);
+                if (device != null)
+                {
+                    canShow = true;
+                    //鏀堕泦鍙互鏄剧ず鐨勮澶�
+                    this.dicShowDevice[room.Id].Add(device);
+                }
+            }
+            return canShow;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0