using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter.Gateway { /// /// 网关替换界面 /// public class GatewayReplaceForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 当前网关对象 /// private ZbGateway nowZbGateway = null; /// /// 列表控件 /// private VerticalListControl listView = null; /// /// 确认按钮 /// private BottomClickButton btnConfirm = null; /// /// 当前选择的状态控件 MainKey是网关ID /// private MostRightIconControl btnSelectIcon = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 当前网关对象 public void ShowForm(ZbGateway i_zbGateway) { this.nowZbGateway = i_zbGateway; //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uReplaceGateway)); //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //确定按钮 this.btnConfirm = new BottomClickButton(); btnConfirm.TextID = R.MyInternationalizationString.uConfirm1; btnConfirm.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor; bodyFrameLayout.AddChidren(btnConfirm); btnConfirm.CanClick = false; btnConfirm.ButtonClickEvent += (sender, e) => { //执行网关替换操作 this.DoReplaceGateway(); }; //请选择被替换的网关 var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false); btnMsg.Y = btnConfirm.Yaxis - Application.GetRealHeight(50 + 35); btnMsg.TextSize = 12; btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; btnMsg.TextAlignment = TextAlignment.Center; btnMsg.TextID = R.MyInternationalizationString.uPleaseSelectGatewayToBeReplaced; bodyFrameLayout.AddChidren(btnMsg); this.listView = new VerticalListControl(29); listView.Height = btnMsg.Y - Application.GetRealHeight(23); listView.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(listView); HdlThreadLogic.Current.RunMainInThread(() => { //设定中部信息 this.SetMiddleFrameInfo(); }); } /// /// 设定中部信息 /// private void SetMiddleFrameInfo() { //获取本地全部网关对象 List listway = HdlGatewayLogic.Current.GetAllLocalGateway(); var listShowWay = new List(); for (int i = 0; i < listway.Count; i++) { //只有类型相同的网关,才能显示 if (listway[i].GwId != this.nowZbGateway.GwId && listway[i].LinuxImageType == this.nowZbGateway.LinuxImageType) { listShowWay.Add(listway[i]); } } for (int i = 0; i < listShowWay.Count; i++) { //添加行 this.AddRowLayout( listShowWay[i], i != listShowWay.Count - 1); } //调整列表控件的高度 this.listView.AdjustRealHeight(Application.GetRealHeight(23)); } #endregion #region ■ 添加网关行_________________________ /// /// 添加行 /// /// 本地网关 /// 是否添加底线 private void AddRowLayout(ZbGateway localWay, bool addLine) { var frameRow = new FrameRowControl(this.listView.rowSpace / 2); this.listView.AddChidren(frameRow); //图标 var btnIcon = frameRow.AddLeftIcon(); HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, localWay); //显示文本 var wayName = HdlGatewayLogic.Current.GetGatewayName(localWay); if (wayName == string.Empty) { //无法识别的网关设备 wayName = Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice); } frameRow.AddTopView(wayName, 700); //房间 var room = HdlRoomLogic.Current.GetRoomByGateway(localWay.GwId); var roomName = HdlRoomLogic.Current.GetRoomName(room); frameRow.AddBottomView(roomName, 700); //选择状态 var btnSelect = frameRow.AddMostRightEmptyIcon(58, 58); btnSelect.MainKey = localWay.GwId; btnSelect.Visible = false; btnSelect.UnSelectedImagePath = "Item/ItemSelected.png"; if (addLine == true) { //底线 frameRow.AddBottomLine(); } btnSelect.ButtonClickEvent += (sender, e) => { if (this.btnSelectIcon != null) { this.btnSelectIcon.IsSelected = false; } btnSelect.IsSelected = true; this.btnSelectIcon = btnSelect; this.btnConfirm.CanClick = true; }; } #endregion #region ■ 执行网关替换操作___________________ /// /// 执行网关替换操作 /// private void DoReplaceGateway() { } #endregion } }