From 18b93d511dc764b469d7c4a7e755f7274f89cdb4 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 27 四月 2020 17:55:14 +0800 Subject: [PATCH] 2020-4-27-1 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 189 +++++++++++++++++++++++++++++++---------------- 1 files changed, 124 insertions(+), 65 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index a80cecc..4bd8639 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -22,6 +22,10 @@ /// </summary> private VerticalListRefreshControl listView = null; /// <summary> + /// 鍓嶄竴娆℃樉绀哄嚭宸︽粦鑿滃崟鐨凴owLayout + /// </summary> + private RowLayoutControl oldShowRightMuneRow = null; + /// <summary> /// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃) /// </summary> private Dictionary<string, DeviceObjRowInfo> dicRowInfo = new Dictionary<string, DeviceObjRowInfo>(); @@ -55,20 +59,6 @@ btnAddDeviceIcon.InitControl(); btnAddDeviceIcon.ButtonClickEvent += (sender, e) => { - ZbGateway realWay = null; - if (GatewayResourse.NowSelectGateway == null || HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == false) - { - //缃戝叧瀵硅薄寮傚父,璇烽噸鏂伴�夋嫨缃戝叧 - string msg = Language.StringByID(R.MyInternationalizationString.uGatewayIsErrorAndReSelect); - this.ShowMassage(ShowMsgType.Error, msg, () => - { - var form2 = new GatewayManage.GatewayListForm(); - form2.AddForm(); - }); - return; - } - GatewayResourse.NowSelectGateway = realWay; - var form = new DeviceDirection.AddDeviceTypeListForm(); form.AddForm(); }; @@ -88,8 +78,9 @@ this.ClearBodyFrame(); //鍒濆鍖栫綉鍏宠鎺т欢 - GatewayResourse.NowSelectGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); - this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway); + GatewayResourse.NowSelectGatewayId = GatewayResourse.AppOldSelectGatewayId; + var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); + this.gatewayViewRow = new MyGatewayControl(nowGateway); bodyFrameLayout.AddChidren(gatewayViewRow); gatewayViewRow.InitControl(); @@ -152,9 +143,8 @@ private void InitDeviceListControl() { //鑾峰彇璁惧鍒楄〃 - string gwID = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); - var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwID); - var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(gwID); + var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(GatewayResourse.NowSelectGatewayId); + var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(GatewayResourse.NowSelectGatewayId); listDevice.AddRange(listSpecialOta); this.dicRowInfo.Clear(); @@ -186,11 +176,14 @@ //娣诲姞璁惧鐨勮彍鍗曡 this.AddDeviceMenuRow(macAddress); } - - //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ - this.StartGatewayOnlieCheckThread(); - //妫�娴嬭澶囨柊鐗堟湰 - this.CheckDeviceNewVersion(listOta); + //濡傛灉褰撳墠涓嶆槸铏氭嫙浣忓畢 + if (Common.Config.Instance.Home.IsVirtually == false) + { + //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ + this.StartGatewayOnlieCheckThread(); + //妫�娴嬭澶囨柊鐗堟湰 + this.CheckDeviceNewVersion(listOta); + } }); } @@ -214,6 +207,7 @@ //鎺т欢 var rowMenu = new DeviceObjectControl(deviceMac, listView.rowSpace / 2); + rowMenu.MainKeys = deviceMac; frameTable.AddChidren(rowMenu); rowMenu.InitControl(); rowInfo.MenuRow = rowMenu; @@ -234,13 +228,8 @@ if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true) { //瀹氫綅 - var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowMenu.Height, false); + var btnPosition = rowMenu.AddEditorControl(false); btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; - btnPosition.TextAlignment = TextAlignment.Center; - btnPosition.TextSize = 12; - btnPosition.TextColor = UserCenterColor.Current.White; - btnPosition.BackgroundColor = 0xff4a4a4a; - rowMenu.AddRightView(btnPosition); btnPosition.ButtonClickEvent += (sender, e) => { //瀹氫綅 @@ -270,11 +259,30 @@ rowMenu.frameTable.ButtonClickEvent += (sender, e) => { + //闅愯棌鑿滃崟 + rowMenu.HideMenu(); + //寮哄埗璺宠浆鐪熷疄璁惧鐣岄潰 + if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1) + { + var form2 = new DeviceAddSuccessForm(); + form2.AddForm(deviceMac); + return; + } btnNew.Visible = false; var form = new DeviceMacInfoEditorForm(); form.AddForm(deviceMac); //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 this.nowActionDeviceMac = deviceMac; + }; + //宸︽粦鑿滃崟浜嬩欢 + rowMenu.OpenMenuAction += () => + { + if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowMenu.MainKeys) + { + //宸︽粦鑿滃崟鍙兘婊戜竴涓� + this.oldShowRightMuneRow.HideMenu(); + } + this.oldShowRightMuneRow = rowMenu; }; } @@ -331,6 +339,7 @@ //琛屾帶浠� var rowDevice = new DeviceRoomControl(device, frame.rowSpace / 2); + rowDevice.MainKeys = LocalDevice.Current.GetDeviceMainKeys(device); frame.AddChidren(rowDevice); rowDevice.frameTable.LeftOffset = Application.GetRealWidth(173) - ControlCommonResourse.XXLeft; rowDevice.InitControl(); @@ -349,13 +358,8 @@ if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(device) == true) { //瀹氫綅 - var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowDevice.Height, false); + var btnPosition = rowDevice.AddEditorControl(false); btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; - btnPosition.TextAlignment = TextAlignment.Center; - btnPosition.TextSize = 12; - btnPosition.TextColor = UserCenterColor.Current.White; - btnPosition.BackgroundColor = 0xff4a4a4a; - rowDevice.AddRightView(btnPosition); btnPosition.ButtonClickEvent += (sender, e) => { //瀹氫綅 @@ -365,10 +369,26 @@ rowDevice.frameTable.ButtonClickEvent += (sender, e) => { + //闅愯棌鑿滃崟 + rowDevice.HideMenu(); //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 this.nowActionDeviceMac = device.DeviceAddr; - //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 - this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo); + //濡傛灉褰撳墠浣忓畢涓嶆槸铏氭嫙浣忓畢 + if (Common.Config.Instance.Home.IsVirtually == false) + { + //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 + this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo); + } + }; + //宸︽粦鑿滃崟浜嬩欢 + rowDevice.OpenMenuAction += () => + { + if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowDevice.MainKeys) + { + //宸︽粦鑿滃崟鍙兘婊戜竴涓� + this.oldShowRightMuneRow.HideMenu(); + } + this.oldShowRightMuneRow = rowDevice; }; } @@ -420,8 +440,18 @@ //鏂伴闈㈡澘 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); + //鏂规偊鏂伴闈㈡澘鐨勬寜閿厤缃� + //骞叉帴鐐� + if (device.Type == DeviceType.FreshAir) + { + var form = new DevicePanel.PanelFangyueFreshAirButtonSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } } //鏂规偊闈㈡澘 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo @@ -563,12 +593,25 @@ /// </summary> private async void ListViewBeginHeaderRefreshing() { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熺殑 + if (Common.Config.Instance.Home.IsVirtually == true) + { + //灏辨樉绀轰竴涓壒鏁堣�屽凡 + System.Threading.Thread.Sleep(2000); + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + }); + return; + } //濡傛灉鏄湪绾跨殑 - if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(GatewayResourse.NowSelectGateway) == true) + var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.NowSelectGatewayId); + if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(nowGateway) == true) { //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D ZbGateway realWay = null; - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == true) + if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, nowGateway) == true) { //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆) if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true) @@ -591,7 +634,7 @@ } //鑾峰彇鍏ㄩ儴璁惧 - int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway); + int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway); if (this.Parent == null) { return; @@ -617,12 +660,7 @@ /// </summary> private void StartGatewayOnlieCheckThread() { - if (GatewayResourse.NowSelectGateway == null) - { - return; - } - - string selectGwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); + string selectGwId = GatewayResourse.NowSelectGatewayId; HdlThreadLogic.Current.RunThread(() => { ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId); @@ -694,7 +732,7 @@ private void StartCheckDeviceOnline() { //澶栭儴璋冪敤鐨勮瘽,涓嶅啀閲嶆柊鑾峰彇璁惧鐘舵�� - if (GatewayResourse.NowSelectGateway == null || this.reGetDeviceOnlineStatu == false) + if (this.reGetDeviceOnlineStatu == false) { return; } @@ -702,7 +740,7 @@ //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu); - string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); + string gwId = GatewayResourse.NowSelectGatewayId; HdlThreadLogic.Current.RunThread(() => { //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� @@ -989,8 +1027,6 @@ HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor"); HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); - GatewayResourse.NowSelectGateway = null; - base.CloseFormBefore(); } @@ -1054,7 +1090,10 @@ public MyGatewayControl(ZbGateway i_zbGateway) { this.UseClickStatu = false; - this.zbGatewayId = HdlGatewayLogic.Current.GetGatewayId(i_zbGateway); + if (i_zbGateway != null) + { + this.zbGatewayId = HdlGatewayLogic.Current.GetGatewayId(i_zbGateway); + } this.BackgroundColor = UserCenterColor.Current.White; this.Height = Application.GetRealHeight(173); } @@ -1068,16 +1107,32 @@ ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); //鍥炬爣 var btnIcon = this.AddLeftIcon(81); - HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway); + if (zbway != null) + { + HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway); + } + else + { + btnIcon.UnSelectedImagePath = "Gateway/GatewayIcon1.png"; + } //鏄剧ず鏂囨湰 - btnName = this.AddLeftCaption(HdlGatewayLogic.Current.GetGatewayName(zbway), 700); + btnName = this.AddLeftCaption(string.Empty, 700); btnName.Height = Application.GetRealHeight(60); btnName.TextSize = 15; btnName.Y = Application.GetRealHeight(35); - if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) + if (zbway != null) { - btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); + if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) + { + btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + } + } + else + { + //铏氭嫙缃戝叧 + btnName.Text = Language.StringByID(R.MyInternationalizationString.uVirtualGateway); } //褰撳墠缃戝叧 @@ -1094,15 +1149,19 @@ var btnMament = this.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGatewayManagement), 300); btnMament.Name = "btnMament"; - this.ButtonClickEvent += (sernder, e) => + //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽 + if (Common.Config.Instance.Home.IsVirtually == false) { - if (string.IsNullOrEmpty(((View)sernder).Name) == false) + this.ButtonClickEvent += (sernder, e) => { - //鎵撳紑缃戝叧鍒楄〃鐣岄潰 - var form = new GatewayManage.GatewayListForm(); - form.AddForm(); - } - }; + if (string.IsNullOrEmpty(((View)sernder).Name) == false) + { + //鎵撳紑缃戝叧鍒楄〃鐣岄潰 + var form = new GatewayManage.GatewayListForm(); + form.AddForm(); + } + }; + } } /// <summary> -- Gitblit v1.8.0