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/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs |  388 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 388 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
new file mode 100755
index 0000000..5d48933
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
@@ -0,0 +1,388 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.DeviceAirConditioner
+{
+    /// <summary>
+    /// 绌鸿皟鐨勫鍐呮満鍒楄〃鐣岄潰
+    /// </summary>
+    public class IndoorUnitListForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 璁惧鍒楄〃
+        /// </summary>
+        private List<CommonDevice> listDevice = null;
+        /// <summary>
+        /// 鎺т欢淇℃伅
+        /// </summary>
+        private Dictionary<string, RowControlInfo> dicControl = new Dictionary<string, RowControlInfo>();
+        /// <summary>
+        /// 婵�娲荤殑璁惧鍦板潃
+        /// </summary>
+        private string actionDeviceKeys = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_diviceMac">璁惧Mac鍦板潃</param>
+        public void ShowForm(string i_diviceMac)
+        {
+            this.listDevice = Common.LocalDevice.Current.GetDevicesByMac(i_diviceMac);
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion));
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var listView = new VerticalFrameControl(14);
+            listView.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listView);
+
+            var frameTemp = new FrameLayout();
+            frameTemp.Height = Application.GetRealHeight(69);
+            listView.AddChidren(frameTemp);
+
+            HdlThreadLogic.Current.RunMainInThread(() =>
+            {
+                for (int i = 0; i < listDevice.Count; i++)
+                {
+                    //娣诲姞绌鸿皟琛�
+                    this.AddAcControlRow(listView, (AC)listDevice[i]);
+                }
+                var frameTemp2 = new FrameLayout();
+                frameTemp2.Height = Application.GetRealHeight(29);
+                listView.AddChidren(frameTemp2);
+
+                //鏁版嵁鎺ユ敹
+                this.StartReceiveDataEvent();
+                //鍙戦�佽鍙栧睘鎬х殑鍛戒护
+                this.SetReadAttributeComand();
+            });
+        }
+
+        /// <summary>
+        /// 娣诲姞绌鸿皟琛�
+        /// </summary>
+        /// <param name="listView"></param>
+        /// <param name="device"></param>
+        private void AddAcControlRow(VerticalFrameControl listView, AC device)
+        {
+            var rowInfo = new RowControlInfo();
+
+            var frameTable = new FrameLayoutStatuControl();
+            frameTable.UseClickStatu = false;
+            frameTable.Width = Application.GetRealWidth(994);
+            frameTable.Height = Application.GetRealHeight(337);
+            frameTable.BackgroundImagePath = "Item/IndoorUnitGround.png";
+            frameTable.Gravity = Gravity.CenterHorizontal;
+            listView.AddChidren(frameTable);
+
+            //璁惧鍥炬爣
+            var btnIconBack = new FrameLayout();
+            btnIconBack.X = Application.GetRealWidth(46);
+            btnIconBack.Y = Application.GetRealHeight(43);
+            btnIconBack.Height = this.GetPictrueRealSize(112);
+            btnIconBack.Width = this.GetPictrueRealSize(112);
+            btnIconBack.Radius = (uint)this.GetPictrueRealSize(112) / 2;
+            btnIconBack.BackgroundColor = 0xfff5f6fa;
+            frameTable.AddChidren(btnIconBack, ChidrenBindMode.NotBind);
+            rowInfo.btnIconBack = btnIconBack;
+
+            var btnIcon = new IconViewControl(78);
+            btnIcon.Gravity = Gravity.Center;
+            Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
+            btnIconBack.AddChidren(btnIcon);
+            frameTable.ChangedChidrenBindMode(btnIconBack, ChidrenBindMode.BindEvent);
+            rowInfo.btnIcon = btnIcon;
+
+            //璁惧鍚嶇О
+            var btnDeviceName = new NormalViewControl(700, 60, true);
+            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+            btnDeviceName.X = Application.GetRealWidth(193);
+            btnDeviceName.Y = Application.GetRealHeight(45);
+            frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
+            rowInfo.btnDeviceName = btnDeviceName;
+            //鎴块棿
+            var btnRoom = new NormalViewControl(400, 50, true);
+            btnRoom.X = btnDeviceName.X;
+            btnRoom.Y = btnDeviceName.Bottom + Application.GetRealHeight(12);
+            btnRoom.TextSize = 12;
+            btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
+            btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device);
+            frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEvent);
+            rowInfo.btnRoom = btnRoom;
+            //鎽勬皬搴�
+            var btnValue = new NormalViewControl(300, 60, true);
+            btnValue.Y = Application.GetRealHeight(58);
+            btnValue.X = frameTable.Width - Application.GetRealWidth(300 + 58);
+            btnValue.TextAlignment = TextAlignment.CenterRight;
+            btnValue.TextID = R.MyInternationalizationString.uGetting;
+            frameTable.AddChidren(btnValue, ChidrenBindMode.BindEvent);
+            rowInfo.btnValue = btnValue;
+            //璀﹀憡鍥炬爣
+            var btnWarningIcon = new IconViewControl(69);
+            btnWarningIcon.X = btnIconBack.X;
+            btnWarningIcon.Y = btnRoom.Bottom + Application.GetRealHeight(43);
+            btnWarningIcon.UnSelectedImagePath = "Item/WarningIcon1.png";
+            frameTable.AddChidren(btnWarningIcon, ChidrenBindMode.NotBind);
+            btnWarningIcon.Visible = false;
+            rowInfo.btnWarningIcon = btnWarningIcon;
+            //璀﹀憡淇℃伅
+            var btnWarningMsg = new NormalViewControl(500, 50, true);
+            btnWarningMsg.X = btnWarningIcon.Right + Application.GetRealWidth(12);
+            btnWarningMsg.Y = btnRoom.Bottom + Application.GetRealHeight(55);
+            btnWarningMsg.TextSize = 12;
+            btnWarningMsg.TextColor = UserCenterColor.Current.TextGrayColor1;
+            frameTable.AddChidren(btnWarningMsg, ChidrenBindMode.NotBind);
+            rowInfo.btnWarningMsg = btnWarningMsg;
+            //寮�鍏�
+            var btnSwitch = new IconViewControl(69);
+            btnSwitch.X = frameTable.Width - Application.GetRealWidth(69 + 46);
+            btnSwitch.Y = btnRoom.Bottom + Application.GetRealHeight(43);
+            btnSwitch.UnSelectedImagePath = "Item/Switch.png";
+            btnSwitch.SelectedImagePath = "Item/SwitchSelected.png";
+            frameTable.AddChidren(btnSwitch, ChidrenBindMode.NotBind);
+            rowInfo.btnSwitch = btnSwitch;
+            btnSwitch.ButtonClickEvent += async (sender, e) =>
+            {
+                if (btnSwitch.IsSelected == false)
+                {
+                    //鎵撳紑绌鸿皟
+                    var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
+                    if (result == false)
+                    {
+                        return;
+                    }
+                    btnIcon.IsSelected = true;
+                    btnIconBack.BackgroundColor = 0xfffef1ed;
+                }
+                else
+                {
+                    //鍏抽棴绌鸿皟
+                    var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
+                    if (result == false)
+                    {
+                        return;
+                    }
+                    btnIcon.IsSelected = false;
+                    btnIconBack.BackgroundColor = 0xfff5f6fa;
+                }
+                btnSwitch.IsSelected = !btnSwitch.IsSelected;
+            };
+
+            frameTable.ButtonClickEvent += (sender, e) =>
+            {
+                this.actionDeviceKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+
+                var form = new IndoorUnitSettionForm();
+                form.AddForm(device);
+            };
+
+            dicControl[Common.LocalDevice.Current.GetDeviceMainKeys(device)] = rowInfo;
+        }
+
+        #endregion
+
+        #region 鈻� 鍙戦�佸懡浠__________________________
+
+        /// <summary>
+        /// 鍙戦�佽鍙栧睘鎬х殑鍛戒护
+        /// </summary>
+        private void SetReadAttributeComand()
+        {
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                for (int i = 0; i < listDevice.Count; i++)
+                {
+                    if (this.Parent == null)
+                    {
+                        return;
+                    }
+                    //璇诲彇鐘舵��
+                    HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
+                    System.Threading.Thread.Sleep(200);
+                }
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鏁版嵁鎺ユ敹___________________________
+
+        /// <summary>
+        /// 鏁版嵁鎺ユ敹
+        /// </summary>
+        private void StartReceiveDataEvent()
+        {
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("IndoorUnitListFormEvent", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) =>
+            {
+                string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+                if (dicControl.ContainsKey(mainkeys) == false || device.DeviceStatusReport.CluterID != 513)
+                {
+                    return;
+                }
+
+                var rowInfo = dicControl[mainkeys];
+                for (int i = 0; i < device.DeviceStatusReport.AttriBute.Count; i++)
+                {
+                    var data = device.DeviceStatusReport.AttriBute[i];
+                    if (data.AttributeId == 0)
+                    {
+                        HdlThreadLogic.Current.RunMain(() =>
+                        {
+                            //瀹ゅ唴娓╁害
+                            if (data.AttriButeData == 0)
+                            {
+                                //0鈩�
+                                rowInfo.btnValue.Text = "0.0鈩�";
+                            }
+                            else if (data.AttriButeData > 32767)
+                            {
+                                //璐熸暟(鐗规畩澶勭悊)
+                                string strValue = (data.AttriButeData - 65536).ToString();
+                                //灏忔暟鐐归渶瑕佷竴浣�
+                                strValue = strValue.Substring(0, strValue.Length - 1);
+                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
+                            }
+                            else
+                            {
+                                //灏忔暟鐐归渶瑕佷竴浣�
+                                string strValue = data.AttriButeData.ToString();
+                                strValue = strValue.Substring(0, strValue.Length - 1);
+                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
+                            }
+                        });
+                    }
+                    else if (data.AttributeId == 28)
+                    {
+                        //姝ゅ睘鎬ф弿杩版亽娓╄澶囨澶勪簬鍝妯″紡
+                        //Off = 0  Auto = 1 Cool = 3 Heat = 4 FanOnly = 7  Dry = 8
+                        if (data.AttriButeData != 0)
+                        {
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                rowInfo.btnSwitch.IsSelected = true;
+                                rowInfo.btnIcon.IsSelected = true;
+                                rowInfo.btnIconBack.BackgroundColor = 0xfffef1ed;
+                            });
+                        }
+                    }
+                    else if (data.AttributeId == 4097)
+                    {
+                        //42:闇�瑕佹竻娲楁护缃�
+                        if (data.AttriButeData == 42)
+                        {
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                rowInfo.btnWarningIcon.Visible = true;
+                                //璇锋敞鎰忔竻娲楁护缃戝摝
+                                rowInfo.btnWarningMsg.TextID = R.MyInternationalizationString.uPleaseClreanACfilter;
+                            });
+                        }
+                    }
+                }
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+        /// <summary>
+        /// 鐣岄潰鍏抽棴
+        /// </summary>
+        public override void CloseFormBefore()
+        {
+            HdlGatewayReceiveLogic.Current.RemoveEvent("IndoorUnitListFormEvent");
+
+            base.CloseFormBefore();
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+        /// <summary>
+        /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
+        /// </summary>
+        public override int FormActionAgainEvent()
+        {
+            if (this.actionDeviceKeys != null && dicControl.ContainsKey(this.actionDeviceKeys) == true)
+            {
+                //鍒锋柊璁惧淇℃伅
+                var device = Common.LocalDevice.Current.GetDevice(this.actionDeviceKeys);
+                if (device != null)
+                {
+                    var contr = dicControl[this.actionDeviceKeys];
+                    contr.btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+                    contr.btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device);
+                }
+            }
+            this.actionDeviceKeys = null;
+
+            return 1;
+        }
+
+        #endregion
+
+        #region 鈻� 缁撴瀯浣揰____________________________
+
+        /// <summary>
+        /// 琛屾暟鎹�
+        /// </summary>
+        private class RowControlInfo
+        {
+            /// <summary>
+            /// 璁惧鍚嶅瓧
+            /// </summary>
+            public NormalViewControl btnDeviceName = null;
+            /// <summary>
+            /// 璁惧鎴块棿
+            /// </summary>
+            public NormalViewControl btnRoom = null;
+            /// <summary>
+            /// 璁惧鍥炬爣鑳屾櫙
+            /// </summary>
+            public FrameLayout btnIconBack = null;
+            /// <summary>
+            /// 璁惧鍥炬爣
+            /// </summary>
+            public IconViewControl btnIcon = null;
+            /// <summary>
+            /// 鎽勬皬搴�
+            /// </summary>
+            public NormalViewControl btnValue = null;
+            /// <summary>
+            /// 璀﹀憡鍥炬爣
+            /// </summary>
+            public IconViewControl btnWarningIcon = null;
+            /// <summary>
+            /// 璀﹀憡淇℃伅
+            /// </summary>
+            public NormalViewControl btnWarningMsg = null;
+            /// <summary>
+            /// 寮�鍏�
+            /// </summary>
+            public IconViewControl btnSwitch = null;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0