陈嘉乐
2020-07-10 48ba446936b51fffafa7c3600c0dadc6ac0e8c20
ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayInfoEditorForm.cs
@@ -15,7 +15,7 @@
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
        private FrameListControl listview = null;
        /// <summary>
        /// 当前选择的网关
        /// </summary>
@@ -51,15 +51,19 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var listBackControl = new VerticalFrameControl();
            listBackControl.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackControl);
            //初始化桌布
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 369, 1368);
            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1368);
            //图片
            var btnPic = new DeviceInfoIconControl();
            btnPic.Y = Application.GetRealHeight(92);
            btnPic.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnPic);
            listBackControl.frameTable.AddChidren(btnPic);
            btnPic.InitControl(this.zbGateway);
            //设备备注
@@ -84,15 +88,69 @@
                }
            };
            //设备类型
            //设备类型 (固定智能网关)
            caption = Language.StringByID(R.MyInternationalizationString.uDeviceType);
            var btnType = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
            var btnType = new FrameCaptionViewControl(caption, Language.StringByID(60004), listview.rowSpace / 2);
            btnType.UseClickStatu = false;
            listview.AddChidren(btnType);
            btnType.InitControl();
            HdlGatewayLogic.Current.SetGatewayImageText(btnType.txtView, this.zbGateway);
            //划线
            btnType.AddBottomLine();
            //安装位置
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
            listview.AddChidren(rowBeloneArea);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uInstallationLocation), this.zbGateway);
            //底线
            rowBeloneArea.AddBottomLine();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //变更网关房间
                HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway, roomKeys);
            };
            //所属住宅
            caption = Language.StringByID(R.MyInternationalizationString.uBelongResidence);
            var btnBeloneArea = new FrameCaptionViewControl(caption, Common.Config.Instance.Home.Name, listview.rowSpace / 2);
            btnBeloneArea.UseClickStatu = false;
            listview.AddChidren(btnBeloneArea);
            btnBeloneArea.InitControl();
            //划线
            btnBeloneArea.AddBottomLine();
            //mini网关有个功能设置
            var linuxImageType = this.zbGateway.LinuxImageType;
            if (linuxImageType == 11)
            {
                var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(this.zbGateway.GwId);
                CommonDevice miniDevice = null;
                foreach (var device in listDevice)
                {
                    //获取这个网关下的小夜灯设备
                    if (Common.LocalDevice.Current.IsMiniLight(device) == true)
                    {
                        miniDevice = device;
                        break;
                    }
                }
                //如果找得到的话
                if (miniDevice != null)
                {
                    //功能设置
                    var rowFunction = new RowLayoutControl(listview.rowSpace / 2);
                    listview.AddChidren(rowFunction);
                    rowFunction.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp), 700);
                    //右图标
                    rowFunction.frameTable.AddRightArrow();
                    //底线
                    rowFunction.frameTable.AddBottomLine();
                    rowFunction.frameTable.ButtonClickEvent += (sender, e) =>
                    {
                        var form = new DeviceLight.MiniNightLightFunctionSettionForm();
                        form.AddForm(miniDevice);
                    };
                }
            }
            //数据上传与下载
            var rowData = new RowLayoutControl(listview.rowSpace / 2);
@@ -104,6 +162,8 @@
            rowData.frameTable.AddBottomLine();
            rowData.frameTable.ButtonClickEvent += (sender, e) =>
            {
                var form = new GatewayUploadAndDownLoadForm();
                form.AddForm(this.zbGateway.GwId);
            };
            //通用信息
@@ -134,16 +194,16 @@
            btnNewVersion.Visible = false;
            btnNewVersion.X = Application.GetRealWidth(242);
            btnNewVersion.Y = Application.GetRealHeight(23);
            rowUpDate.AddChidren(btnNewVersion, ChidrenBindMode.BindEventOnly);
            rowUpDate.AddChidren(btnNewVersion, ChidrenBindMode.BindEvent);
            rowUpDate.ButtonClickEvent += (sender, e) =>
            {
                btnNewVersion.Visible = false;
                var form = new GatewayUpdate.GatewayFirmwareInfoForm();
                var form = new GatewayUpdate.GatewayFirmwareUpdateForm();
                form.AddForm(zbGateway);
            };
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr.FinishInitControl();
            tableContr = null;
            //保存
@@ -160,7 +220,7 @@
                if (oldName != btnNote.Text)
                {
                    //修改名字
                    this.SetGatewayName(btnNote.Text, false);
                    this.SetGatewayName(btnNote.Text, true);
                }
                else
                {
@@ -172,7 +232,7 @@
            HdlThreadLogic.Current.RunThread(() =>
            {
                //检测新版本
                this.CheckNewVersion(btnNewVersion, btnType);
                this.CheckNewVersion(btnNewVersion);
            });
        }
@@ -202,7 +262,7 @@
        private void ShowTopRightMenu()
        {
            bool flage = UserCenterResourse.DicActionForm.ContainsKey("NewGateWayMenuSelectForm");
            var frame = new TopRightMenuControl(flage == true ? 1 : 3);
            var frame = new TopRightMenuControl(flage == true ? 1 : 3, 1);
            //定位
            string MenuName = Language.StringByID(R.MyInternationalizationString.uFixedPosition);
            frame.AddRowMenu(MenuName, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
@@ -218,7 +278,7 @@
            //切换
            MenuName = Language.StringByID(R.MyInternationalizationString.uSwitch1);
            string strWayId = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string strWayId = this.zbGateway.GwId;
            if (strWayId == GatewayResourse.AppOldSelectGatewayId)
            {
                MenuName = Language.StringByID(R.MyInternationalizationString.uRefresh);
@@ -266,8 +326,7 @@
        /// 检测新版本
        /// </summary>
        /// <param name="btnNewVersion">提示有新版本的控件</param>
        /// <param name="btnType">网关类型控件</param>
        private async void CheckNewVersion(PicViewControl btnNewVersion, FrameCaptionViewControl btnType)
        private async void CheckNewVersion(PicViewControl btnNewVersion)
        {
            //获取网关版本信息
            var result = await HdlGatewayLogic.Current.GetGatewayAllNewVersion(this.zbGateway);
@@ -279,7 +338,6 @@
            {
                if (this.Parent != null)
                {
                    HdlGatewayLogic.Current.SetGatewayImageText(btnType.txtView, this.zbGateway);
                    if (result[0] != null || result[1] != null || result[2] != null)
                    {
                        //提示有新版本
@@ -287,34 +345,6 @@
                    }
                }
            });
        }
        #endregion
        #region ■ 完成按钮按下_______________________
        /// <summary>
        /// 完成按钮按下
        /// </summary>
        /// <param name="gatewayName">网关名</param>
        private void FinishButtonClick(string gatewayName)
        {
            if (string.IsNullOrEmpty(gatewayName) == true)
            {
                //请输入网关名称
                string msg = Language.StringByID(R.MyInternationalizationString.uGatewayNameMastInput);
                this.ShowMassage(ShowMsgType.Error, msg);
                return;
            }
            string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway);
            if (nameValue == gatewayName)
            {
                //同名不需要处理
                this.CloseForm();
                return;
            }
            //修改名字
            this.SetGatewayName(gatewayName, true);
        }
        #endregion
@@ -351,8 +381,7 @@
        /// <param name="online"></param>
        private async void DoSwitchGateway()
        {
            string gatewayId = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            var result = await HdlGatewayLogic.Current.DoSwitchGateway(gatewayId);
            var result = await HdlGatewayLogic.Current.DoSwitchGateway(zbGateway.GwId);
            if (result == false)
            {
                return;
@@ -364,7 +393,7 @@
                this.CloseForm();
                //关闭指定界面(网关搜索)
                this.CloseFormByFormName("WiredGatewayListForm");
                this.CloseFormByFormName("GatewaySearchListForm");
                this.CloseFormByFormName("NewGateWayMenuSelectForm");
                //关闭指定界面(网关编辑)
@@ -379,7 +408,7 @@
                else
                {
                    //刷新主画面(不重新获取设备状态)
                    this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false);
                    this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame");
                }
            });
        }
@@ -393,21 +422,32 @@
        /// </summary>
        /// <param name="strWayId"></param>
        /// <param name="row"></param>
        private async void DeleteGateway(string strWayId)
        private void DeleteGateway(string strWayId)
        {
            //删除云端网关
            bool result = await HdlGatewayLogic.Current.DeleteGateway(strWayId);
            if (result == false)
            HdlThreadLogic.Current.RunThread(async () =>
            {
                return;
            }
                //打开进度条
                this.ShowProgressBar();
            if (strWayId == GatewayResourse.AppOldSelectGatewayId)
            {
                HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty);
            }
            //关闭自身
            this.CloseForm();
                //删除云端网关
                bool result = await HdlGatewayLogic.Current.DeleteGateway(strWayId);
                //关闭进度条
                this.CloseProgressBar();
                if (result == false)
                {
                    return;
                }
                if (strWayId == GatewayResourse.AppOldSelectGatewayId)
                {
                    HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty);
                }
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //关闭自身
                    this.CloseForm();
                });
            });
        }
        #endregion