| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.GatewayManage
|
| | |
| | | btnAdd.InitControl();
|
| | | btnAdd.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new GatewayAdd.NewGateWaySelectForm();
|
| | | var form = new GatewayAdd.NewGateWayMenuSelectForm();
|
| | | form.AddForm();
|
| | | };
|
| | |
|
| | |
| | | listview.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listview);
|
| | |
|
| | | //设定中部信息
|
| | | this.SetMiddleFrameInfo();
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | //设定中部信息
|
| | | this.SetMiddleFrameInfo();
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | List<ZbGateway> listway = HdlGatewayLogic.Current.GetAllLocalGateway();
|
| | | if (listway.Count == 0)
|
| | | {
|
| | | //还没有绑定网关哦
|
| | | var btnPic = new PicViewControl(683, 392);
|
| | | btnPic.UnSelectedImagePath = "Item/NoFunction.png";
|
| | | btnPic.Y = (int)(bodyFrameLayout.Height * 0.382) - Application.GetRealHeight(392 / 2);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | |
|
| | | var btnView = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
|
| | | btnView.Y = btnPic.Bottom + Application.GetRealHeight(32);
|
| | | btnView.TextID = R.MyInternationalizationString.uHadNotBindGatewayMsg;
|
| | | btnView.TextAlignment = TextAlignment.Center;
|
| | | btnView.TextSize = 12;
|
| | | btnView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | bodyFrameLayout.AddChidren(btnView);
|
| | | return;
|
| | | }
|
| | |
|
| | | int count = listway.Count - 1;
|
| | | for (int i = 0; i < listway.Count; i++)
|
| | | {
|
| | | //添加行
|
| | | var gwId = HdlGatewayLogic.Current.GetGatewayId(listway[i]);
|
| | | this.AddRowLayout(gwId, i != count);
|
| | | this.AddRowLayout(gwId, i != listway.Count - 1);
|
| | | }
|
| | |
|
| | | //调整列表控件的高度
|
| | | var realHeight = listview.ChildrenCount * listview.GetChildren(listview.ChildrenCount - 1).Height;
|
| | | realHeight += Application.GetRealHeight(23);
|
| | | if (realHeight < listview.Height)
|
| | | {
|
| | | //缩小控件高度
|
| | | listview.Height = realHeight;
|
| | | }
|
| | | this.listview.AdjustRealHeight(Application.GetRealHeight(23));
|
| | |
|
| | | //设置接受在线状态推送
|
| | | this.AddGatewayOnlinePush();
|
| | |
| | | private void AddRowLayout(string strWayId, bool addLine)
|
| | | {
|
| | | //网关控件
|
| | | var Gateway = HdlGatewayLogic.Current.GetLocalGateway(strWayId);
|
| | | var gatewayRow = new GatewayRowControl(Gateway, listview.rowSpace / 2);
|
| | | var gateway = HdlGatewayLogic.Current.GetLocalGateway(strWayId);
|
| | | var gatewayRow = new GatewayRowControl(gateway, listview.rowSpace / 2);
|
| | | listview.AddChidren(gatewayRow);
|
| | | gatewayRow.InitControl(81);
|
| | | //向右图标
|
| | | gatewayRow.frameTable.AddRightArrow();
|
| | | //添加在线状态
|
| | | gatewayRow.AddOnLineControl();
|
| | | if (addLine == true)
|
| | | {
|
| | | gatewayRow.frameTable.AddBottomLine();
|
| | | }
|
| | |
|
| | | //提示有新版本
|
| | | var btnNew = new InformationTipView(gatewayRow.btnIcon);
|
| | | var btnNew = new RowNewVersionTipView();
|
| | | btnNew.Visible = false;
|
| | | gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly);
|
| | | gatewayRow.AddTag("btnNew", btnNew);
|
| | |
|
| | | this.dicRowContr[strWayId] = gatewayRow;
|
| | |
|
| | | //设置一个选择网关的默认值
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && gatewayRow.IsOnline == true)
|
| | | //单击事件
|
| | | gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.SaveGatewayIdToLocation(strWayId);
|
| | | }
|
| | |
|
| | | //编辑按钮
|
| | | var btnEditor = new NormalViewControl(Application.GetRealWidth(177), gatewayRow.Height, false);
|
| | | btnEditor.BackgroundColor = UserCenterColor.Current.RowEditorButtonColor;
|
| | | btnEditor.TextAlignment = TextAlignment.Center;
|
| | | btnEditor.TextColor = UserCenterColor.Current.White;
|
| | | btnEditor.TextID = R.MyInternationalizationString.uEditor;
|
| | | gatewayRow.AddRightView(btnEditor);
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //如果点击的是不在线的网关,则当什么事都没有发生
|
| | | if (gatewayRow.IsOnline == false)
|
| | | {
|
| | | //指定的网关不在线
|
| | | this.ShowMassage(ShowMsgType.Normal, Language.StringByID(R.MyInternationalizationString.uTheGatewayIsNotOnline));
|
| | | return;
|
| | | }
|
| | | //点击编辑的话,直接隐藏
|
| | | btnNew.Visible = false;
|
| | |
|
| | | var form = new GatewayInfoEditorForm();
|
| | | form.AddForm(Gateway);
|
| | | };
|
| | |
|
| | | //解除绑定
|
| | | var btnUnBind = new NormalViewControl(Application.GetRealWidth(177), gatewayRow.Height, false);
|
| | | btnUnBind.BackgroundColor = UserCenterColor.Current.RowDeleteButtonColor;
|
| | | btnUnBind.TextAlignment = TextAlignment.Center;
|
| | | btnUnBind.TextColor = UserCenterColor.Current.White;
|
| | | btnUnBind.TextID = R.MyInternationalizationString.uUnBinded;
|
| | | gatewayRow.AddRightView(btnUnBind);
|
| | | btnUnBind.ButtonClickEvent += (sender, e) =>
|
| | | //切换
|
| | | var btnSwitch = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
|
| | | btnSwitch.BackgroundColor = 0xfffb744a;
|
| | | btnSwitch.TextAlignment = TextAlignment.Center;
|
| | | btnSwitch.TextColor = UserCenterColor.Current.White;
|
| | | btnSwitch.TextSize = 12;
|
| | | btnSwitch.TextID = R.MyInternationalizationString.uSwitch1;
|
| | | if (strWayId == GatewayResourse.AppOldSelectGatewayId)
|
| | | {
|
| | | btnSwitch.TextID = R.MyInternationalizationString.uRefresh;
|
| | | }
|
| | | gatewayRow.AddRightView(btnSwitch);
|
| | | btnSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //是否切换到{0}网关?
|
| | | string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
|
| | | if (strWayId == GatewayResourse.AppOldSelectGatewayId)
|
| | | {
|
| | | //是否重新刷新{0}网关?
|
| | | msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
|
| | | }
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //执行切换网关操作
|
| | | this.DoSwitchGateway(strWayId, gatewayRow.IsOnline);
|
| | | });
|
| | | };
|
| | |
|
| | | //定位
|
| | | var btnPosition = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
|
| | | btnPosition.BackgroundColor = 0xff4a4a4a;
|
| | | btnPosition.TextAlignment = TextAlignment.Center;
|
| | | btnPosition.TextColor = UserCenterColor.Current.White;
|
| | | btnPosition.TextSize = 12;
|
| | | btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
|
| | | gatewayRow.AddRightView(btnPosition);
|
| | | btnPosition.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //发送定位命令
|
| | | HdlGatewayLogic.Current.SetFixedPositionCommand(gateway);
|
| | | };
|
| | |
|
| | | //删除
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
|
| | | btnDelete.BackgroundColor = 0xfff75858;
|
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.TextColor = UserCenterColor.Current.White;
|
| | | btnDelete.TextSize = 12;
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete;
|
| | | gatewayRow.AddLeftView(btnDelete);
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //如移除网关,该网关绑定的设备列表{0}将清空,确认继续执行该操作?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uUnBindedMsg);
|
| | |
| | | });
|
| | | };
|
| | |
|
| | | //单击事件
|
| | | gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | this.dicRowContr[strWayId] = gatewayRow;
|
| | | //设置一个选择网关的默认值
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && gatewayRow.IsOnline == true)
|
| | | {
|
| | | //如果点击的是不在线的网关,则当什么事都没有发生
|
| | | if (gatewayRow.IsOnline == false)
|
| | | {
|
| | | //指定的网关不在线
|
| | | this.ShowMassage(ShowMsgType.Normal, Language.StringByID(R.MyInternationalizationString.uTheGatewayIsNotOnline));
|
| | | return;
|
| | | }
|
| | | //如果存在新版本,并且单击他的话
|
| | | if (btnNew.Visible == true)
|
| | | {
|
| | | if (sender is InformationTipView || sender is IconViewControl)
|
| | | {
|
| | | //打开编辑界面
|
| | | btnNew.Visible = false;
|
| | | var form = new GatewayInfoEditorForm();
|
| | | form.AddForm(Gateway);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | //是否切换到{0}网关?
|
| | | string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
|
| | | if (strWayId == GatewayResourse.AppOldSelectGatewayId)
|
| | | {
|
| | | //是否重新刷新{0}网关?
|
| | | msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
|
| | | }
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //执行切换网关操作
|
| | | this.DoSwitchGateway(strWayId);
|
| | | });
|
| | | };
|
| | | this.SaveGatewayIdToLocation(strWayId);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 执行切换网关操作
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | private async void DoSwitchGateway(string gatewayId)
|
| | | /// <param name="online"></param>
|
| | | private async void DoSwitchGateway(string gatewayId,bool online)
|
| | | {
|
| | | if (online == true)
|
| | | {
|
| | | //重新获取在线网关的信息
|
| | | var result = await this.GetOnlineGatewayInfo(gatewayId);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | }
|
| | | //切换网关,保存缓存
|
| | | this.SaveGatewayIdToLocation(gatewayId);
|
| | | //如果选择了刷新的网关,则不关闭管理界面
|
| | | this.closeDeviceManagForm = false;
|
| | |
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false)
|
| | | {
|
| | | //刷新主画面
|
| | | var form = new Device.DeviceListMainForm();
|
| | | this.AddFromAndRemoveNowForm(form);
|
| | | }
|
| | | else
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | //刷新主画面(不重新获取设备状态)
|
| | | this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取在线网关信息
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> GetOnlineGatewayInfo(string gatewayId)
|
| | | {
|
| | | //显示进度条
|
| | | this.ShowProgressBar();
|
| | |
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | return false;
|
| | | }
|
| | | //重新绑定网关里面已经重新获取了网关信息
|
| | | getGatewayInfo = false;
|
| | |
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | return false;
|
| | | }
|
| | |
|
| | | //切换网关,保存缓存
|
| | | this.SaveGatewayIdToLocation(gatewayId);
|
| | | //如果选择了刷新的网关,则不关闭管理界面
|
| | | this.closeDeviceManagForm = false;
|
| | |
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false)
|
| | | {
|
| | | //刷新主画面
|
| | | var form = new Device.DeviceListMainForm();
|
| | | this.AddFromAndRemoveNowForm(form);
|
| | | }
|
| | | else
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | //刷新主画面(不重新获取设备状态)
|
| | | this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false);
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="listway"></param>
|
| | | private void StartGatewayOnlieCheckThread(List<ZbGateway> listway)
|
| | | {
|
| | | var timeValue = (DateTime.Now - oldGetOnlineTime).Milliseconds;
|
| | | if (timeValue <= 10000)
|
| | | if (oldGetOnlineTime.Year != 1900)
|
| | | {
|
| | | //最少要间隔十秒,才去重新获取
|
| | | return;
|
| | | var timeValue = (DateTime.Now - oldGetOnlineTime).TotalSeconds;
|
| | | if (timeValue < 10)
|
| | | {
|
| | | //最少要间隔十秒,才去重新获取
|
| | | return;
|
| | | }
|
| | | }
|
| | | oldGetOnlineTime = DateTime.Now;
|
| | |
|
| | |
| | | {
|
| | | if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
|
| | | {
|
| | | var btnNew = (InformationTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
|
| | | var btnNew = (RowNewVersionTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
|
| | | if (btnNew != null)
|
| | | {
|
| | | btnNew.Visible = true;
|