黄学彪
2020-09-18 c7df85937f73fb347ee0b19e9c052d2d00a6df6c
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,添加此控件到容器后,调用【InitControl()】完成初始化
        /// </summary>
        /// <param name="i_zbGateway">网关对象</param>
        /// <param name="ChidrenYaxis">子控件Y轴偏移量(有些界面需要这种特殊操作)</param>
        /// <param name="ChidrenYaxis">子控件Y轴偏移量(【列表控件的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;
            }
        }