From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 18 九月 2020 13:58:19 +0800
Subject: [PATCH] 新版本

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

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
index 1f00096..2091089 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
@@ -32,19 +32,18 @@
                 return zbway;
             }
         }
-
-        /// <summary>
-        /// 鍥炬爣鎺т欢
-        /// </summary>
-        public IconViewControl btnIcon = null;
         /// <summary>
         /// 鏄剧ず鏂囨湰鎺т欢
         /// </summary>
         public NormalViewControl btnName = null;
         /// <summary>
-        /// 鍦ㄧ嚎鐘舵�佺殑鎺т欢
+        /// 鍥炬爣鎺т欢
         /// </summary>
-        public NormalViewControl btnOnline = null;
+        public IconViewControl btnIcon = null;
+        /// <summary>
+        /// 鏄剧ずIP鎺т欢
+        /// </summary>
+        public NormalViewControl btnIp = null;
 
         /// <summary>
         /// 鍦ㄧ嚎鐘舵��
@@ -58,9 +57,12 @@
             get { return m_IsOnline; }
             set
             {
-                m_IsOnline = value;
-                //鍙樻洿鐘舵��
-                this.SetOnlineStatu(m_IsOnline);
+                if (m_IsOnline != value)
+                {
+                    m_IsOnline = value;
+                    //鍙樻洿鐘舵��
+                    this.SetOnlineStatu(m_IsOnline);
+                }
             }
         }
 
@@ -72,10 +74,10 @@
         /// 鍋氭垚涓�涓樉绀虹綉鍏充俊鎭殑RowLayout,娣诲姞姝ゆ帶浠跺埌瀹瑰櫒鍚庯紝璋冪敤銆怚nitControl()銆戝畬鎴愬垵濮嬪寲
         /// </summary>
         /// <param name="i_zbGateway">缃戝叧瀵硅薄</param>
-        /// <param name="ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(鏈変簺鐣岄潰闇�瑕佽繖绉嶇壒娈婃搷浣�)</param>
+        /// <param name="ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(銆愬垪琛ㄦ帶浠剁殑rowSpace/2銆戝嵆鍙�,涓嶆噦榛樿涓�0鍗冲彲)</param>
         public GatewayRowControl(ZbGateway i_zbGateway, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
         {
-            this.zbGatewayId = HdlGatewayLogic.Current.GetGatewayId(i_zbGateway);
+            this.zbGatewayId = i_zbGateway.GwId;
         }
 
         /// <summary>
@@ -100,10 +102,45 @@
                 //鏃犳硶璇嗗埆鐨勭綉鍏宠澶�
                 wayName = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice);
             }
-            this.btnName = frameTable.AddLeftCaption(wayName, 700);
-            this.btnName.Text = wayName;
+            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);
 
-            tempWay = null;
+            //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(() =>
+                        {
+                            //鍒锋柊鎺т欢
+                            tempWay.GatewayOnlineFlage = true;
+                            this.RefreshControl(tempWay);
+                        });
+                    }
+                });
+            }
         }
 
         #endregion
@@ -118,40 +155,30 @@
         {
             if (zbway != null)
             {
-                this.zbGatewayId = HdlGatewayLogic.Current.GetGatewayId(zbway);
+                this.zbGatewayId = zbway.GwId;
             }
-            ZbGateway realWay = null;
-            bool bonline = false;
-            if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, this.zbGatewayId) == true)
-            {
-                bonline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(realWay);
-            }
+            bool bonline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway);
 
             this.IsOnline = bonline;
-            this.btnName.Text = HdlGatewayLogic.Current.GetGatewayName(this.zbGateway);
 
-            realWay = null;
+            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>
-        public void AddOnLineControl()
-        {
-            this.btnOnline = frameTable.AddMostRightView(string.Empty, 270);
-
-            ZbGateway realWay = null;
-            bool bonline = false;
-            if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, zbGateway) == true)
-            {
-                bonline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(realWay);
-            }
-            this.SetOnlineStatu(bonline);
-        }
 
         /// <summary>
         /// 璁剧疆鍦ㄧ嚎鐘舵��
@@ -160,23 +187,13 @@
         private void SetOnlineStatu(bool online)
         {
             m_IsOnline = online;
-            if (btnOnline == null)
-            {
-                return;
-            }
             if (online == false)
             {
-                //鍒濆鍊硷細绂荤嚎
-                btnOnline.TextID = R.MyInternationalizationString.uOffLine;
-                //鍒濆鍊硷細鐏拌壊
-                btnOnline.TextColor = UserCenterColor.Current.Gray;
+                btnName.TextColor = UserCenterColor.Current.TextGrayColor2;
             }
             else
             {
-                //鍦ㄧ嚎
-                btnOnline.TextID = R.MyInternationalizationString.uOnline;
-                //缁胯壊
-                btnOnline.TextColor = UserCenterColor.Current.Green;
+                btnName.TextColor = UserCenterColor.Current.TextColor1;
             }
         }
 

--
Gitblit v1.8.0