From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs |  218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 218 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
new file mode 100755
index 0000000..c9d2fb6
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
@@ -0,0 +1,218 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter
+{
+    public class GatewayRowControl : RowLayoutControl
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 缃戝叧ID
+        /// </summary>
+        private string zbGatewayId = string.Empty;
+        /// <summary>
+        /// 缃戝叧瀵硅薄(浼樺厛缂撳瓨鐨勭綉鍏冲璞★紝鍏舵鎵嶆槸鐪熷疄缃戝叧)
+        /// </summary>
+        public ZbGateway zbGateway
+        {
+            get
+            {
+                //鑾峰彇鏈湴缃戝叧瀵硅薄
+                ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
+                if (zbway != null)
+                {
+                    return zbway;
+                }
+                //鑾峰彇鐪熷疄鐗╃悊缃戝叧瀵硅薄
+                HdlGatewayLogic.Current.GetRealGateway(ref zbway, zbGatewayId);
+
+                return zbway;
+            }
+        }
+        /// <summary>
+        /// 鏄剧ず鏂囨湰鎺т欢
+        /// </summary>
+        public NormalViewControl btnName = null;
+        /// <summary>
+        /// 鍥炬爣鎺т欢
+        /// </summary>
+        public IconViewControl btnIcon = null;
+        /// <summary>
+        /// 鏄剧ずIP鎺т欢
+        /// </summary>
+        public NormalViewControl btnIp = null;
+
+        /// <summary>
+        /// 鍦ㄧ嚎鐘舵��
+        /// </summary>
+        private bool m_IsOnline = false;
+        /// <summary>
+        /// 鍦ㄧ嚎鐘舵��
+        /// </summary>
+        public bool IsOnline
+        {
+            get { return m_IsOnline; }
+            set
+            {
+                if (m_IsOnline != value)
+                {
+                    m_IsOnline = value;
+                    //鍙樻洿鐘舵��
+                    this.SetOnlineStatu(m_IsOnline);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鍋氭垚涓�涓樉绀虹綉鍏充俊鎭殑RowLayout,娣诲姞姝ゆ帶浠跺埌瀹瑰櫒鍚庯紝璋冪敤銆怚nitControl()銆戝畬鎴愬垵濮嬪寲
+        /// </summary>
+        /// <param name="i_zbGateway">缃戝叧瀵硅薄</param>
+        /// <param name="ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(銆愬垪琛ㄦ帶浠剁殑rowSpace/2銆戝嵆鍙�,涓嶆噦榛樿涓�0鍗冲彲)</param>
+        public GatewayRowControl(ZbGateway i_zbGateway, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
+        {
+            this.zbGatewayId = i_zbGateway.GwId;
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栧唴閮ㄦ帶浠�
+        /// </summary>
+        /// <param name="iconSize">宸﹁竟鍥炬爣澶у皬(鏈変簺鐣岄潰鍥炬爣澶у皬涓嶄竴鑷�)</param>
+        public void InitControl(int iconSize)
+        {
+            var tempWay = this.zbGateway;
+
+            //鍥炬爣
+            this.btnIcon = frameTable.AddLeftIcon(iconSize);
+            if (tempWay != null)
+            {
+                HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, tempWay);
+            }
+
+            //鏄剧ず鏂囨湰
+            var wayName = tempWay != null ? HdlGatewayLogic.Current.GetGatewayName(tempWay) : string.Empty;
+            if (wayName == string.Empty)
+            {
+                //鏃犳硶璇嗗埆鐨勭綉鍏宠澶�
+                wayName = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice);
+            }
+            else
+            {
+                var value = HdlGatewayLogic.Current.IsMainGateway(this.zbGatewayId);
+                if (value == 1)
+                {
+                    //涓荤綉鍏�
+                    wayName += "(" + Language.StringByID(R.MyInternationalizationString.uMainGateway) + ")";
+                }
+                else if (value == 2)
+                {
+                    //浠庣綉鍏�
+                    wayName += "(" + Language.StringByID(R.MyInternationalizationString.uChidrenGateway) + ")";
+                }
+            }
+            this.btnName = frameTable.AddTopView(wayName, 700);
+
+            //IP
+            this.btnIp = frameTable.AddBottomView(tempWay != null ? tempWay.GwIP : string.Empty, 600);
+
+            //鍒濆鍊煎湪绾�
+            this.IsOnline = true;
+
+            if (tempWay != null)
+            {
+                //鍒锋柊缃戝叧淇℃伅
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    var result = HdlGatewayLogic.Current.GetGatewayInfo(tempWay, false, ShowErrorMode.NO);
+                    if (result != null)
+                    {
+                        HdlThreadLogic.Current.RunMain(() =>
+                        {
+                            //鍒锋柊鎺т欢
+                            this.RefreshControl(tempWay);
+                        });
+                    }
+                });
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒锋柊鎺т欢___________________________
+
+        /// <summary>
+        /// 鍒锋柊鎺т欢
+        /// </summary>
+        /// <param name="zbway">缃戝叧瀵硅薄(涓簄ull鏃�,浣跨敤鎺т欢鍐呴儴鐨勬暟鎹繘琛屽埛鏂�)</param>
+        public void RefreshControl(ZbGateway zbway)
+        {
+            if (zbway != null)
+            {
+                this.zbGatewayId = zbway.GwId;
+            }
+            bool bonline = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbway);
+
+            this.IsOnline = bonline;
+
+            string wayName = HdlGatewayLogic.Current.GetGatewayName(this.zbGateway);
+            var value = HdlGatewayLogic.Current.IsMainGateway(this.zbGatewayId);
+            if (value == 1)
+            {
+                //涓荤綉鍏�
+                wayName += "(" + Language.StringByID(R.MyInternationalizationString.uMainGateway) + ")";
+            }
+            else if (value == 2)
+            {
+                //浠庣綉鍏�
+                wayName += "(" + Language.StringByID(R.MyInternationalizationString.uChidrenGateway) + ")";
+            }
+            this.btnName.Text = wayName;
+        }
+
+        #endregion
+
+        #region 鈻� 鍦ㄧ嚎鐘舵�乢__________________________
+
+        /// <summary>
+        /// 璁剧疆鍦ㄧ嚎鐘舵��
+        /// </summary>
+        /// <param name="online"></param>
+        private void SetOnlineStatu(bool online)
+        {
+            m_IsOnline = online;
+            if (online == false)
+            {
+                btnName.TextColor = UserCenterColor.Current.TextGrayColor2;
+            }
+            else
+            {
+                btnName.TextColor = UserCenterColor.Current.TextColor1;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 鏇存敼鎺т欢楂樺害
+        /// </summary>
+        /// <param name="i_height">闈炵湡瀹炲��</param>
+        public void ChangedHight(int i_height)
+        {
+            if (frameTable != null)
+            {
+                frameTable.Height = Application.GetRealHeight(i_height);
+            }
+            this.Height = Application.GetRealHeight(i_height);
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0