New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.GatewayManage |
| | | { |
| | | /// <summary> |
| | | /// 网关替换界面 |
| | | /// </summary> |
| | | public class GatewayReplaceForm : EditorCommonForm |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 当前网关对象 |
| | | /// </summary> |
| | | private ZbGateway nowZbGateway = null; |
| | | /// <summary> |
| | | /// 列表控件 |
| | | /// </summary> |
| | | private VerticalListControl listView = null; |
| | | /// <summary> |
| | | /// 确认按钮 |
| | | /// </summary> |
| | | private BottomClickButton btnConfirm = null; |
| | | /// <summary> |
| | | /// 当前选择的状态控件 MainKey是网关ID |
| | | /// </summary> |
| | | private MostRightIconControl btnSelectIcon = null; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | /// <param name="i_zbGateway">当前网关对象</param> |
| | | public void ShowForm(ZbGateway i_zbGateway) |
| | | { |
| | | this.nowZbGateway = i_zbGateway; |
| | | |
| | | //设置标题信息 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uReplaceGateway)); |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部控件 |
| | | /// </summary> |
| | | 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(); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设定中部信息 |
| | | /// </summary> |
| | | private void SetMiddleFrameInfo() |
| | | { |
| | | //获取本地全部网关对象 |
| | | List<ZbGateway> listway = HdlGatewayLogic.Current.GetAllLocalGateway(); |
| | | var listShowWay = new List<ZbGateway>(); |
| | | 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 ■ 添加网关行_________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加行 |
| | | /// </summary> |
| | | /// <param name="localWay">本地网关</param> |
| | | /// <param name="addLine">是否添加底线</param> |
| | | 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(); |
| | | } |
| | | frameRow.ButtonClickEvent += (sender, e) => |
| | | { |
| | | if (this.btnSelectIcon != null) { this.btnSelectIcon.Visible = false; } |
| | | |
| | | btnSelect.Visible = true; |
| | | this.btnSelectIcon = btnSelect; |
| | | this.btnSelectIcon.MainKey = localWay.GwId; |
| | | this.btnConfirm.CanClick = true; |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 执行网关替换操作___________________ |
| | | |
| | | /// <summary> |
| | | /// 执行网关替换操作 |
| | | /// </summary> |
| | | private void DoReplaceGateway() |
| | | { |
| | | if (this.btnSelectIcon == null) { return; } |
| | | |
| | | ZbGateway realGateway = null; |
| | | if (HdlGatewayLogic.Current.GetRealGateway(ref realGateway, this.nowZbGateway.GwId) == false) |
| | | { |
| | | //错误:网关对象丢失 |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg)); |
| | | return; |
| | | } |
| | | |
| | | var targetGw = HdlGatewayLogic.Current.GetLocalGateway(this.btnSelectIcon.MainKey); |
| | | //确认替换掉网关:{0}? |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uReplaceGatewayConfirmMsg).Replace("{0}", HdlGatewayLogic.Current.GetGatewayName(targetGw)); |
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () => |
| | | { |
| | | var form = new GatewayReplaceBackUpListForm(); |
| | | form.AddForm(realGateway, this.btnSelectIcon.MainKey); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |