黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayInfoEditorForm.cs
@@ -70,6 +70,7 @@
            string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
            string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway);
            var btnNote = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
            btnNote.txtInput.MaxByte = 32;//限制只能输入32个字节
            listview.AddChidren(btnNote);
            btnNote.InitControl();
            //划线
@@ -94,7 +95,7 @@
            //设备类型 (固定智能网关)
            caption = Language.StringByID(R.MyInternationalizationString.uDeviceType);
            var infoContent = Common.LocalDevice.Current.GetDeviceModelIdNameInfo("1");
            var infoContent = HdlDeviceCommonLogic.Current.GetDeviceModelIdNameInfo("1");
            var btnType = new FrameCaptionViewControl(caption, infoContent != null ? infoContent.A类型名字 : string.Empty, listview.rowSpace / 2);
            btnType.UseClickStatu = false;
            listview.AddChidren(btnType);
@@ -111,7 +112,7 @@
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //变更网关房间
                HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway.GwId, roomKeys);
                HdlRoomLogic.Current.ChangedGatewayRoom(this.zbGateway.GwId, roomKeys);
            };
            //如果是展示模板的话,不能编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
@@ -132,12 +133,12 @@
            var linuxImageType = this.zbGateway.LinuxImageType;
            if (linuxImageType == 11)
            {
                var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(this.zbGateway.GwId);
                var listDevice = HdlDeviceCommonLogic.Current.GetDeviceByGatewayID(this.zbGateway.GwId);
                CommonDevice miniDevice = null;
                foreach (var device in listDevice)
                {
                    //获取这个网关下的小夜灯设备
                    if (Common.LocalDevice.Current.IsMiniLight(device) == true)
                    if (HdlDeviceCommonLogic.Current.IsMiniLight(device) == true)
                    {
                        miniDevice = device;
                        break;
@@ -293,8 +294,29 @@
        /// </summary>
        private void ShowTopRightMenu()
        {
            bool flage = UserCenterResourse.DicActionForm.ContainsKey("NewGateWayMenuSelectForm");
            var frame = new TopRightMenuControl(flage == true ? 1 : 3, 1);
            //搜索网关的时候,不能删除,不给他切换,只有定位功能
            bool isSearchGw = HdlFormLogic.Current.IsFormOpen("NewGateWayMenuSelectForm");
            int menuCount = isSearchGw == true ? 1 : 3;
            bool canAddReplaceMenu = false;
            //获取本地网关
            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
            foreach (var gw in listGateway)
            {
                if (gw.GwId != this.zbGateway.GwId && gw.LinuxImageType == this.zbGateway.LinuxImageType)
                {
                    //如果是同一种类型的网关,允许出现替换菜单
                    canAddReplaceMenu = true;
                    break;
                }
            }
            if (canAddReplaceMenu == true
                && Common.Config.Instance.Home.IsShowTemplate == false
                && Common.Config.Instance.Home.IsVirtually == false)
            {
                //menuCount++;
            }
            var frame = new TopRightMenuControl(menuCount, 1);
            //定位
            string MenuName = Language.StringByID(R.MyInternationalizationString.uFixedPosition);
            frame.AddRowMenu(MenuName, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
@@ -302,53 +324,60 @@
                //发送定位功能
                HdlGatewayLogic.Current.SetFixedPositionCommand(zbGateway);
            });
            if (flage == true)
            {
                //搜索网关的时候,不能删除,不给他切换
                return;
            }
            //切换
            MenuName = Language.StringByID(R.MyInternationalizationString.uSwitch1);
            string strWayId = this.zbGateway.GwId;
            if (strWayId == GatewayResourse.AppOldSelectGatewayId)
            //搜索网关的时候,不能删除,不给他切换
            if (isSearchGw == false)
            {
                MenuName = Language.StringByID(R.MyInternationalizationString.uRefresh);
            }
            frame.AddRowMenu(MenuName, "Item/GwSwitchIcon.png", "Item/GwSwitchIconSelected.png", () =>
            {
                string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway);
                //是否切换到{0}网关?
                string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + nameValue + "]");
                if (strWayId == GatewayResourse.AppOldSelectGatewayId)
                //切换
                MenuName = Language.StringByID(R.MyInternationalizationString.uSwitch1);
                string strWayId = this.zbGateway.GwId;
                if (strWayId == HdlGatewayResourse.AppOldSelectGatewayId)
                {
                    //是否重新刷新{0}网关?
                    msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + nameValue + "]");
                    MenuName = Language.StringByID(R.MyInternationalizationString.uRefresh);
                }
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                frame.AddRowMenu(MenuName, "Item/GwSwitchIcon.png", "Item/GwSwitchIconSelected.png", () =>
                {
                    HdlThreadLogic.Current.RunThread(() =>
                    string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway);
                    //是否切换到{0}网关?
                    string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + nameValue + "]");
                    if (strWayId == HdlGatewayResourse.AppOldSelectGatewayId)
                    {
                        //执行切换网关操作
                        this.DoSwitchGateway();
                        //是否重新刷新{0}网关?
                        msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + nameValue + "]");
                    }
                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                    {
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            //执行切换网关操作
                            this.DoSwitchGateway();
                        });
                    });
                });
            });
            //删除
            MenuName = Language.StringByID(R.MyInternationalizationString.uDelete);
            frame.AddRowMenu(MenuName, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
            {
                //如移除网关,该网关绑定的设备列表{0}将清空,确认继续执行该操作?
                string msg = Language.StringByID(R.MyInternationalizationString.uUnBindedMsg);
                if (msg.Contains("{0}") == true)
                //删除
                MenuName = Language.StringByID(R.MyInternationalizationString.uDelete);
                frame.AddRowMenu(MenuName, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
                {
                    msg = string.Format(msg, "\r\n");
                }
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                {
                    this.DeleteGateway(strWayId);
                    //如移除网关,该网关绑定的设备列表{0}将清空,确认继续执行该操作?
                    string msg = Language.StringByID(R.MyInternationalizationString.uUnBindedMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, "\r\n");
                    }
                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                    {
                        this.DeleteGateway(strWayId);
                    });
                });
            });
            }
            //if (canAddReplaceMenu == true)
            //{
            //    //替换
            //    MenuName = Language.StringByID(R.MyInternationalizationString.uReplace);
            //    frame.AddRowMenu(MenuName, null, "Item/ReplaceIconSelected.png", () =>
            //    {
            //    });
            //}
        }
        #endregion
@@ -425,13 +454,13 @@
                this.CloseForm();
                //关闭指定界面(网关搜索)
                this.CloseFormByFormName("GatewaySearchListForm");
                this.CloseFormByFormName("NewGateWayMenuSelectForm");
                HdlFormLogic.Current.CloseFormByFormName("GatewaySearchListForm");
                HdlFormLogic.Current.CloseFormByFormName("NewGateWayMenuSelectForm");
                //关闭指定界面(网关编辑)
                this.CloseFormByFormName("GatewayListForm");
                HdlFormLogic.Current.CloseFormByFormName("GatewayListForm");
                if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false)
                if (HdlFormLogic.Current.IsFormOpen("DeviceListMainForm") == false)
                {
                    //刷新主画面
                    var form = new Device.DeviceListMainForm();
@@ -470,7 +499,7 @@
                    return;
                }
                if (strWayId == GatewayResourse.AppOldSelectGatewayId)
                if (strWayId == HdlGatewayResourse.AppOldSelectGatewayId)
                {
                    HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty);
                }