xm
2020-12-14 d6fb0646531172f23648441c224cdcccd721b894
ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomDeviceListForm.cs
New file
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Residence
{
    /// <summary>
    /// 房间设备一览界面
    /// </summary>
    public class LookRoomDeviceListForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="titleName">标题</param>
        /// <param name="detailTile">明细标题</param>
        /// <param name="listDevice">设备列表(主键)</param>
        public void ShowForm(string titleName, string detailTile, List<string> listDevice)
        {
            //设置头部信息
            base.SetTitleText(titleName);
            //初始化中部信息
            this.InitMiddleFrame(detailTile, listDevice);
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame(string detailTile, List<string> listDevice)
        {
            //清空bodyFrame
            this.ClearBodyFrame();
            var frameTitle = new FrameLayout();
            frameTitle.BackgroundColor = UserCenterColor.Current.White;
            frameTitle.Height = Application.GetRealHeight(115);
            bodyFrameLayout.AddChidren(frameTitle);
            var btnTitle = new NormalViewControl(800, 60, true);
            btnTitle.Y = Application.GetRealHeight(49);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.TextSize = 15;
            btnTitle.TextColor = UserCenterColor.Current.TextColor2;
            btnTitle.Text = detailTile;
            frameTitle.AddChidren(btnTitle);
            var listView = new VerticalListControl(23);
            listView.Y = frameTitle.Bottom;
            listView.Height = bodyFrameLayout.Height - frameTitle.Height;
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                for (int i = 0; i < listDevice.Count; i++)
                {
                    //获取设备
                    var device = Common.LocalDevice.Current.GetDevice(listDevice[i]);
                    if (device == null)
                    {
                        continue;
                    }
                    //添加设备行
                    this.AddDeviceRow(listView, device, i != listDevice.Count - 1);
                }
                listView.AdjustRealHeight(Application.GetRealHeight(23));
            });
        }
        #endregion
        #region ■ 添加设备行_________________________
        /// <summary>
        /// 添加设备行
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="device"></param>
        /// <param name="addLine"></param>
        private void AddDeviceRow(VerticalListControl listView, CommonDevice device, bool addLine)
        {
            var frameRow = new FrameRowControl(listView.rowSpace / 2);
            frameRow.UseClickStatu = false;
            listView.AddChidren(frameRow);
            //图标
            var btnIcon = frameRow.AddLeftIcon(81);
            Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
            //设备名字
            var btnName = frameRow.AddLeftCaption(Common.LocalDevice.Current.GetDeviceEpointName(device), 700);
            btnName.TextSize = 15;
            if (Common.LocalDevice.Current.CheckDeviceIsOnline(device) == false)
            {
                btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
            }
            //底线
            if (addLine == true)
            {
                frameRow.AddBottomLine();
            }
        }
        #endregion
    }
}