| | |
| | | /// 网关管理的界面
|
| | | /// </summary>
|
| | | public class GatewayListForm : EditorCommonForm
|
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 列表控件 |
| | | /// </summary> |
| | | private VerticalListControl listview = null; |
| | | /// <summary> |
| | | /// 生成的网关状态控件暂时存入内存中 |
| | | /// </summary> |
| | | private Dictionary<string, GatewayRowControl> dicRowContr = new Dictionary<string, GatewayRowControl>(); |
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listview = null;
|
| | | /// <summary>
|
| | | /// 生成的网关状态控件暂时存入内存中
|
| | | /// </summary>
|
| | | private Dictionary<string, GatewayRowControl> dicRowContr = new Dictionary<string, GatewayRowControl>();
|
| | | /// <summary>
|
| | | /// 关闭设备管理界面(如果解除绑定的网关是当前所选择的网关的话,则关闭设备管理界面)
|
| | | /// </summary> |
| | | /// </summary>
|
| | | private bool closeDeviceManagForm = false;
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | public void ShowForm() |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uGatewayManagement));
|
| | |
| | | //添加图标
|
| | | var btnAdd = new MostRightIconControl(69, 69);
|
| | | btnAdd.UnSelectedImagePath = "Item/Add.png";
|
| | | topFrameLayout.AddChidren(btnAdd); |
| | | btnAdd.InitControl(); |
| | | btnAdd.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var form = new GatewayAdd.NewGateWaySelectForm(); |
| | | form.AddForm(); |
| | | }; |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部控件 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | { |
| | | topFrameLayout.AddChidren(btnAdd);
|
| | | btnAdd.InitControl();
|
| | | btnAdd.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new GatewayAdd.NewGateWaySelectForm();
|
| | | form.AddForm();
|
| | | };
|
| | |
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | |
| | | bodyFrameLayout.AddChidren(listview);
|
| | |
|
| | | //设定中部信息
|
| | | this.SetMiddleFrameInfo(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设定中部信息 |
| | | /// </summary> |
| | | private void SetMiddleFrameInfo() |
| | | this.SetMiddleFrameInfo();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设定中部信息
|
| | | /// </summary>
|
| | | private void SetMiddleFrameInfo()
|
| | | {
|
| | | this.dicRowContr.Clear();
|
| | | this.listview.RemoveAll();
|
| | | |
| | | //获取本地全部网关对象 |
| | |
|
| | | //获取本地全部网关对象
|
| | | List<ZbGateway> listway = HdlGatewayLogic.Current.GetAllLocalGateway();
|
| | | if (listway.Count == 0)
|
| | | {
|
| | |
| | | //设置接受在线状态推送
|
| | | this.AddGatewayOnlinePush();
|
| | | //开启网关在线监测的线程
|
| | | this.StartGatewayOnlieCheckThread(listway); |
| | | this.StartGatewayOnlieCheckThread(listway);
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 添加网关行_________________________
|
| | |
|
| | | /// <summary> |
| | | /// 添加行 |
| | | /// </summary> |
| | | /// <param name="strWayId">String way.</param> |
| | | /// <param name="addLine">是否添加底线</param> |
| | | private void AddRowLayout(string strWayId, bool addLine) |
| | | /// <summary>
|
| | | /// 添加行
|
| | | /// </summary>
|
| | | /// <param name="strWayId">String way.</param>
|
| | | /// <param name="addLine">是否添加底线</param>
|
| | | private void AddRowLayout(string strWayId, bool addLine)
|
| | | {
|
| | | //网关控件
|
| | | var Gateway = HdlGatewayLogic.Current.GetLocalGateway(strWayId);
|
| | |
| | | listview.AddChidren(gatewayRow);
|
| | | gatewayRow.InitControl(81);
|
| | | //向右图标
|
| | | gatewayRow.frameTable.AddRightIconControl();
|
| | | gatewayRow.frameTable.AddRightArrow();
|
| | | //添加在线状态
|
| | | gatewayRow.AddOnLineControl();
|
| | | if (addLine == true)
|
| | |
| | | }
|
| | |
|
| | | //编辑按钮
|
| | | var btnEditor = new NormalViewControl(Application.GetRealWidth(177), gatewayRow.Height, false); |
| | | btnEditor.BackgroundColor = UserCenterColor.Current.RowEditorButtonColor; |
| | | btnEditor.TextAlignment = TextAlignment.Center; |
| | | btnEditor.TextColor = UserCenterColor.Current.White; |
| | | 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; |
| | | 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); |
| | | };
|
| | |
|
| | | //解除绑定
|
| | | 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) =>
|
| | | {
|
| | | //如移除网关,该网关绑定的设备列表{0}将清空,确认继续执行该操作?
|
| | |
| | | {
|
| | | this.DeleteGateway(strWayId, gatewayRow);
|
| | | });
|
| | | }; |
| | | |
| | | //单击事件 |
| | | gatewayRow.frameTable.ButtonClickEvent += (sender, e) => |
| | | };
|
| | |
|
| | | //单击事件
|
| | | gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //如果点击的是不在线的网关,则当什么事都没有发生
|
| | | if (gatewayRow.IsOnline == false) |
| | | { |
| | | //指定的网关不在线 |
| | | this.ShowMassage(ShowMsgType.Normal, Language.StringByID(R.MyInternationalizationString.uTheGatewayIsNotOnline)); |
| | | return; |
| | | } |
| | | //如果存在新版本,并且单击他的话 |
| | | 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)
|
| | |
| | | }
|
| | |
|
| | | //是否切换到{0}网关?
|
| | | string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]"); |
| | | 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);
|
| | | }); |
| | | }; |
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 解绑网关___________________________
|
| | |
|
| | |
| | | /// 解绑网关
|
| | | /// </summary>
|
| | | /// <param name="strWayId"></param>
|
| | | /// <param name="row"></param> |
| | | /// <param name="row"></param>
|
| | | private async void DeleteGateway(string strWayId, GatewayRowControl row)
|
| | | {
|
| | | //删除云端网关
|
| | |
| | | }
|
| | | oldGetOnlineTime = DateTime.Now;
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | System.Threading.Thread.Sleep(300);
|
| | | //刷新网关在线状态
|
| | |
| | | }
|
| | | //网关新版本检测
|
| | | this.CheckGatewayNewVersion(listway);
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 网关在线状态变更
|
| | | /// </summary>
|
| | | /// <param name="gateWay">网关对象</param> |
| | | /// <param name="gateWay">网关对象</param>
|
| | | /// <param name="online">在线状态变更后的状态</param>
|
| | | public override void GatewayOnlinePush(ZbGateway gateWay, bool online)
|
| | | {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 网关新版本检测_____________________
|
| | |
|
| | |
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary> |
| | | public override void CloseForm() |
| | | { |
| | | base.CloseForm(); |
| | | |
| | | /// </summary>
|
| | | public override void CloseForm()
|
| | | {
|
| | | base.CloseForm();
|
| | |
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && this.closeDeviceManagForm == true)
|
| | | {
|
| | | //关闭界面
|
| | | HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
|
| | | this.LoadFormMethodByName("DeviceListMainForm", "CloseForm");
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <summary>
|
| | | /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
| | | /// </summary>
|
| | | public override void FormActionAgainEvent()
|
| | | public override int FormActionAgainEvent()
|
| | | {
|
| | | //初始化中部控件 |
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | return 1;
|
| | | }
|
| | |
|
| | | #endregion
|