From 3aa397ab145382935492b11c1f18c9634e69910b Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 10 十二月 2020 16:45:00 +0800 Subject: [PATCH] 请合并,门锁和晾衣架第一版代码 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 2806 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 1,408 insertions(+), 1,398 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs old mode 100755 new mode 100644 index bc0a6b3..eca7a87 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -6,1404 +6,1414 @@ using ZigBee.Device; namespace Shared.Phone.UserCenter.Device -{ +{ + /// <summary> + /// 璁惧鍒楄〃鐨勪富鐣岄潰 + /// </summary> + public class DeviceListMainForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> - /// 璁惧鍒楄〃鐨勪富鐣岄潰 + /// 鏅鸿兘闊崇 /// </summary> - public class DeviceListMainForm : EditorCommonForm - { - #region 鈻� 鍙橀噺澹版槑___________________________ - /// <summary> - /// 鏅鸿兘闊崇 - /// </summary> - private MySmartSoundControl smmartSoundView = null; - /// <summary> - /// 缃戝叧鎺т欢 - /// </summary> - private MyGatewayControl gatewayViewRow = null; - /// <summary> - /// 鍒楄〃鎺т欢 - /// </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>(); - /// <summary> - /// 褰撳墠姝e湪鎿嶄綔鐨勮澶囧璞ac鍦板潃(璁惧淇℃伅缂栬緫鐣岄潰鐢�) - /// </summary> - private string nowActionDeviceMac = null; - - #endregion - - #region 鈻� 鍒濆鍖朹____________________________ - - /// <summary> - /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) - /// </summary> - public void ShowForm() - { - this.ScrollEnabled = false; - - //璁剧疆鏍囬淇℃伅 - base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DeviceManagement)); - - //鍙充笂娣诲姞鎸夐挳 - var btnAddDeviceIcon = new MostRightIconControl(69, 69); - btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png"; - topFrameLayout.AddChidren(btnAddDeviceIcon); - btnAddDeviceIcon.InitControl(); - btnAddDeviceIcon.ButtonClickEvent += (sender, e) => - { - var form = new DeviceDirection.AddDeviceTypeListForm(); - form.AddForm(); - }; - - //鍒濆鍖栦腑閮ㄦ帶浠� - this.InitMiddleFrame(); - - //寮�鍚紶鎰熷櫒鎶ヨ鐩戣 - this.StartCheckDeviceAlarm(); - //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� - HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) => - { - HdlThreadLogic.Current.RunMain(() => - { - //鎺ュ彈璁惧鐘舵�� - this.ReceiveDeviceStatu(report); - - }, ShowErrorMode.NO); - }); - //寮�鍚娴嬬綉鍏冲湪绾跨姸鎬佺殑绾跨▼ - HdlGatewayLogic.Current.StartCheckGatewayOnlineThread(this); - } - - /// <summary> - /// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤) - /// </summary> - public void InitMiddleFrame() - { - //娓呯┖bodyFrame - this.ClearBodyFrame(); - - smmartSoundView = new MySmartSoundControl(); - bodyFrameLayout.AddChidren(smmartSoundView); - smmartSoundView.InitControl(); - //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽 - if (Config.Instance.Home.IsVirtually == false) - { - smmartSoundView.ButtonClickEvent += (sernder, e) => - { - var form = new SmartSoundListForm(); - form.AddForm(); - }; - } - //鍒濆鍖栫綉鍏宠鎺т欢 - GatewayResourse.NowSelectGatewayId = GatewayResourse.AppOldSelectGatewayId; - var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); - this.gatewayViewRow = new MyGatewayControl(nowGateway); - bodyFrameLayout.AddChidren(gatewayViewRow); - gatewayViewRow.InitControl(); - - //鍒濆鍖栨悳绱㈡帶浠� - this.InitSearchControl(); - - HdlThreadLogic.Current.RunThread(() => - { - //鍒濆鍖栬澶囧垪琛ㄦ帶浠� - this.InitDeviceListControl(); - }); - } - - #endregion - - #region 鈻� 鍒濆鍖栨悳绱㈡帶浠禵____________________ - - /// <summary> - /// 鍒濆鍖栨悳绱㈡帶浠� - /// </summary> - private void InitSearchControl() - { - //鐧借壊鑳屾櫙 - var frame = new FrameLayout(); - frame.BackgroundColor = UserCenterColor.Current.White; - frame.Y = this.gatewayViewRow.Bottom + Application.GetRealHeight(23); - frame.Height = bodyFrameLayout.Height - this.gatewayViewRow.Bottom - Application.GetRealHeight(23); - bodyFrameLayout.AddChidren(frame); - - //鎼滅储璁惧鍏抽敭璇� - string textTip = Language.StringByID(R.MyInternationalizationString.uSearchDeviceKeyWorld); - var txtSearchControl = new SearchTextControl(textTip); - frame.AddChidren(txtSearchControl); - txtSearchControl.Y = Application.GetRealHeight(46); - //缁戝畾鍥炶皟鍑芥暟 - txtSearchControl.BindEvent(this.SetRowDataBySearchKeys); - - //鍒楄〃鎺т欢 - listView = new VerticalListRefreshControl(29); - listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29); - listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29); - frame.AddChidren(listView); - listView.BeginHeaderRefreshingAction += () => - { - //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - UserView.UserPage.Instance.RefreshAllForm = true; - - HdlThreadLogic.Current.RunThread(() => - { - //涓嬫媺鍒锋柊 - this.ListViewBeginHeaderRefreshing(); - }); - }; - } - - #endregion - - #region 鈻� 鍒濆鍖栬澶囧垪琛ㄦ帶浠禵________________ - - /// <summary> - /// 鍒濆鍖栬澶囧垪琛ㄦ帶浠� - /// </summary> - private void InitDeviceListControl() - { - //鑾峰彇璁惧鍒楄〃 - var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(GatewayResourse.NowSelectGatewayId); - var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(GatewayResourse.NowSelectGatewayId); - listDevice.AddRange(listSpecialOta); - - this.dicRowInfo.Clear(); - - //娌℃湁璁惧 - if (listDevice.Count == 0) - { - return; - } - - //鏍规嵁MAC鍚堝苟璁惧鍒楄〃 - this.MargeAllDeviceByMac(listDevice); - - if (this.Parent == null) - { - return; - } - HdlThreadLogic.Current.RunMain(() => - { - var listOta = new List<OTADevice>(); - foreach (var macAddress in this.dicRowInfo.Keys) - { - //鑾峰彇ota璁惧 - var ota = Common.LocalDevice.Current.GetOTADevice(macAddress); - if (ota != null) - { - listOta.Add(ota); - } - //娣诲姞璁惧鐨勮彍鍗曡 - this.AddDeviceMenuRow(macAddress); - } - //濡傛灉褰撳墠涓嶆槸铏氭嫙浣忓畢 - if (Common.Config.Instance.Home.IsVirtually == false) - { - //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ - this.StartGatewayOnlieCheckThread(); - //妫�娴嬭澶囨柊鐗堟湰 - this.CheckDeviceNewVersion(listOta); - } - }); - } - - #endregion - - #region 鈻� 娣诲姞璁惧鑿滃崟琛宊____________________ - - /// <summary> - /// 娣诲姞璁惧鐨勮彍鍗曡 - /// </summary> - /// <param name="deviceMac">璁惧Mac鍦板潃</param> - private void AddDeviceMenuRow(string deviceMac) - { - var rowInfo = this.dicRowInfo[deviceMac]; - - //鍒涘缓涓�涓彲浠ュ睍寮�鍜屾敹缂╃殑FrameLayout,鐩稿綋浜庤彍鍗曟爮 - var frameTable = new FrameListControl(29); - frameTable.Height = ControlCommonResourse.ListViewRowHeight + frameTable.rowSpace; - listView.AddChidren(frameTable); - rowInfo.frameTable = frameTable; - - //鎺т欢 - var rowMenu = new DeviceObjectControl(deviceMac, listView.rowSpace / 2); - rowMenu.MainKeys = deviceMac; - frameTable.AddChidren(rowMenu); - rowMenu.InitControl(); - rowInfo.MenuRow = rowMenu; - //鍚戝彸鍥炬爣 - var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58); - btnRight.UnSelectedImagePath = "Item/RightNext.png"; - btnRight.SelectedImagePath = "Item/Down.png"; - rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind); - - //鎻愮ず鏂扮増鏈� - var btnNew = new InformationTipView(rowMenu.btnIcon); - btnNew.Visible = false; - rowMenu.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEvent); - rowMenu.AddTag("btnNew", btnNew); - - //妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘 - var listdevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac); - if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true) - { - //瀹氫綅 - var btnPosition = rowMenu.AddEditorControl(false); - btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; - btnPosition.ButtonClickEvent += (sender, e) => - { - //瀹氫綅 - Common.LocalDevice.Current.SetFixedPositionCommand(listdevice[0]); - }; - } - - //灞曞紑,鎶樺彔 - btnRight.ButtonClickEvent += (sender, e) => - { - //鍥炶矾鏁板ぇ浜�1鎵嶅睍寮� - var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false); - if (listMacDevice.Count > 1) - { - btnRight.IsSelected = !btnRight.IsSelected; - //灞曞紑鎴栬�呮姌鍙犳槑缁嗗垪琛� - this.ShowDetailList(deviceMac, btnRight.IsSelected); - } - else - { - if (LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true) - { - //mini澶滅伅鐨勫姛鑳借缃晫闈� - var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]); - var form = new MainPage.DeviceDetailInfoForm(); - form.AddForm(listMacDevice[0], room); - } - else - { - //璁惧淇℃伅鐣岄潰 - var form = new DeviceMacInfoEditorForm(); - form.AddForm(deviceMac); - } - btnNew.Visible = false; - //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 - this.nowActionDeviceMac = deviceMac; - } - }; - - rowMenu.frameTable.ButtonClickEvent += (sender, e) => - { - //闅愯棌鑿滃崟 - rowMenu.HideMenu(); - //寮哄埗璺宠浆鐪熷疄璁惧鐣岄潰 - if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1) - { - var form2 = new DeviceAddSuccessForm(); - form2.AddForm(deviceMac); - return; - } - var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false); - if (listMacDevice.Count > 0 && LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true) - { - //mini澶滅伅鐨勫姛鑳借缃晫闈� - var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]); - var form = new MainPage.DeviceDetailInfoForm(); - form.AddForm(listMacDevice[0], room); - } - else - { - //璁惧淇℃伅鐣岄潰 - var form = new DeviceMacInfoEditorForm(); - form.AddForm(deviceMac); - } - - btnNew.Visible = false; - //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 - this.nowActionDeviceMac = deviceMac; - }; - //宸︽粦鑿滃崟浜嬩欢 - rowMenu.OpenMenuAction += () => - { - if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowMenu.MainKeys) - { - //宸︽粦鑿滃崟鍙兘婊戜竴涓� - this.oldShowRightMuneRow.HideMenu(); - } - this.oldShowRightMuneRow = rowMenu; - }; - } - - #endregion - - #region 鈻� 灞曞紑鎶樺彔___________________________ - - /// <summary> - /// 灞曞紑鎴栬�呴殣钘忓垪琛� - /// </summary> - /// <param name="deviceMac">璁惧Mac鍦板潃</param> - /// <param name="isShow">鏄惁灞曞紑</param> - private void ShowDetailList(string deviceMac, bool isShow) - { - var rowInfo = this.dicRowInfo[deviceMac]; - //瀹冨師鏉ョ殑楂樺害 - int oldHeight = rowInfo.frameTable.Height; - //鍙樻洿鐨勯珮搴�,榛樿涓哄垪琛ㄩ殣钘� - int heightValue = ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace; - var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac); - if (isShow == true) - { - //澶囨敞锛氶潰鏉夸腑鍙樉绀虹湡瀹炵殑璁惧锛屽叾浠栧睘浜庣粦瀹氱殑鍥炶矾涓嶆樉绀� - //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑 - var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice); - if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) - { - var listTemp = Common.LocalDevice.Current.GetMutilfunctionPanelByMac(listDevice); - //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� - heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); - //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 - if (rowInfo.frameTable.ChildrenCount == 1) - { - foreach (CommonDevice info in listTemp) - { - //鍔犺浇瀹冪殑鍒楄〃 - this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); - } - } - } - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir - || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment - || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment) - { - var listTemp = Common.LocalDevice.Current.GetPanelMatchEpointByMac(listDevice); - //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� - heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); - //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 - if (rowInfo.frameTable.ChildrenCount == 1) - { - foreach (CommonDevice info in listTemp) - { - //鍔犺浇瀹冪殑鍒楄〃 - this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); - } - } - } - else - { - //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� - heightValue = (listDevice.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); - //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 - if (rowInfo.frameTable.ChildrenCount == 1) - { - foreach (CommonDevice info in listDevice) - { - //鍔犺浇瀹冪殑鍒楄〃 - this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); - } - } - } - } - //鑷韩楂樺害鍙樻洿 - rowInfo.frameTable.Height = heightValue; - } - - /// <summary> - /// 娣诲姞璁惧鐨勬槑缁嗚 - /// </summary> - /// <param name="frame">瀹瑰櫒</param> - /// <param name="device"></param> - /// <param name="deviceEnumInfo"></param> - private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device, DeviceEnumInfo deviceEnumInfo) - { - var rowInfo = this.dicRowInfo[device.DeviceAddr]; - if (rowInfo.dicDetailRow == null) - { - rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>(); - } - - //琛屾帶浠� - 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(); - //搴曠嚎 - rowDevice.frameTable.AddBottomLine(); - //鍙崇澶� - rowDevice.frameTable.AddRightArrow(); - //鍦ㄧ嚎鐘舵�� - rowDevice.IsOnline = rowInfo.MenuRow.IsOnline; - //淇濆瓨鎺т欢 - string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device); - rowInfo.dicDetailRow[maikey] = rowDevice; - - //妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘 - if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(device) == true) - { - //瀹氫綅 - var btnPosition = rowDevice.AddEditorControl(false); - btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; - btnPosition.ButtonClickEvent += (sender, e) => - { - //瀹氫綅 - Common.LocalDevice.Current.SetFixedPositionCommand(device); - }; - } - - rowDevice.frameTable.ButtonClickEvent += (sender, e) => - { - //闅愯棌鑿滃崟 - rowDevice.HideMenu(); - //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 - this.nowActionDeviceMac = device.DeviceAddr; - //濡傛灉褰撳墠浣忓畢涓嶆槸铏氭嫙浣忓畢 - 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; - }; - } - - /// <summary> - /// 鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 - /// </summary> - /// <param name="device"></param> - /// <param name="deviceEnumInfo"></param> - private void ShowDeviceFunctionSettionForm(CommonDevice device, DeviceEnumInfo deviceEnumInfo) - { - //鏅鸿兘闂ㄩ攣 - if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鏅鸿兘闂ㄩ攣) - { - var form = new DeviceMacInfoEditorForm(); - form.AddForm(device.DeviceAddr); - } - else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜) - { - var form = new DeviceMacInfoEditorForm(); - form.AddForm(device.DeviceAddr); - } - //pir浼犳劅鍣� - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir) - { - if (device is IASZone) - { - var form = new DevicePirSensor.PirSensorBindTargetSettionForm(); - form.AddForm((IASZone)device); - } - else - { - //pir浼犳劅鍣�,浠栦滑鍙堟悶浜嗕釜缁х數鍣ㄥ湪閲岄潰 - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - //涓ぎ绌鸿皟 - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway) - { - var form = new DeviceAirConditioner.IndoorUnitSettionForm(); - form.AddForm((AC)device); - } - //鏂伴闈㈡澘 - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) - { - //鏂规偊鏂伴闈㈡澘鐨勬寜閿厤缃� - //骞叉帴鐐� - if (device.Type == DeviceType.FreshAir) - { - var form = new DevicePanel.PanelSettionWithSourceForm(); - form.AddForm(device); - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆 - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment) - { - - if (device.Type == DeviceType.FreshAir || device.Type == DeviceType.Thermostat) - { - var form = new DevicePanel.PanelSettionWithSourceForm(); - form.AddForm(device); - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - //绠�绾﹀鍔熻兘闈㈡澘鐨勬寜閿厤缃� - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - //鏂规偊闈㈡澘 - else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo - || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFour - || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEight) - { - //骞叉帴鐐� - if (device.Type == DeviceType.OnOffSwitch) - { - //鏂规偊闈㈡澘鐨勬寜閿厤缃� - var form = new DevicePanel.PanelFangyueButtonSettionForm(); - form.AddForm(device); - } - //缁х數鍣� - else if (device.Type == DeviceType.OnOffOutput) - { - //鏂规偊闈㈡澘鐨勫姛鑳介厤缃� - var form = new DevicePanel.PanelFangyueFunctionSettionForm(); - form.AddForm(device, deviceEnumInfo); - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - //闈㈡澘璁惧 - else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘) - { - //骞叉帴鐐� - if (device.Type == DeviceType.OnOffSwitch) - { - //娌充笢璁惧 - if (deviceEnumInfo.IsHdlDevice == true) - { - var form = new DevicePanel.PanelButtonSettionForm(); - form.AddForm(device); - } - else - { - var form = new DeviceDryContactSettionForm(); - form.AddForm(device); - } - } - //缁х數鍣� - else if (device.Type == DeviceType.OnOffOutput) - { - //娌充笢璁惧 - if (deviceEnumInfo.IsHdlDevice == true) - { - var form = new DevicePanel.PanelFunctionSettionForm(); - form.AddForm(device); - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - //濡傛灉鏄共鎺ョ偣 - else if (device.Type == DeviceType.OnOffSwitch) - { - var form = new DeviceDryContactSettionForm(); - form.AddForm(device); - } - else - { - var form = new DeviceFunctionSettionForm(); - form.AddForm(device, true); - } - } - - #endregion - - #region 鈻� 閿�兼悳绱__________________________ - - /// <summary> - /// 鏍规嵁鎼滅储閿�硷紝璁惧畾鍒楄〃鏁版嵁 - /// </summary> - /// <param name="searchKey">Search key.</param> - private void SetRowDataBySearchKeys(string searchKey) - { - lock (dicRowInfo) - { - HdlThreadLogic.Current.RunMain(() => - { - if (this.listView == null) - { - return; - } - //棣栧厛鍏堢Щ闄ゅ垪琛ㄦ墍鏈夋帶浠� - this.listView.RemoveAll(); - //濡傛灉鎼滅储閿�间负绌猴紝鍒欒繕鍘熶负鍘熷鐘舵��:鏄剧ず璁惧绫诲瀷鎬昏 - if (searchKey == string.Empty) - { - foreach (var deviceMac in dicRowInfo.Keys) - { - //娣诲姞璁惧鐨勮 - this.AddDeviceMenuRow(deviceMac); - } - //娣诲姞搴曢儴闂撮殭 - var frameTemp = new FrameLayout(); - frameTemp.Height = Application.GetRealHeight(23); - listView.AddChidren(frameTemp); - } - else - { - //鎼滅储鍚嶅瓧閲岄潰鍖呭惈閿�肩殑璁惧 - foreach (var rowInfo in this.dicRowInfo.Values) - { - if ((rowInfo.MacName != null && rowInfo.MacName.Contains(searchKey) == true) - || rowInfo.DeviveTypeName.Contains(searchKey) == true) - { - //娣诲姞璁惧鐨勮 - this.AddDeviceMenuRow(rowInfo.DeviceMac); - } - } - //娣诲姞搴曢儴闂撮殭 - var frameTemp = new FrameLayout(); - frameTemp.Height = Application.GetRealHeight(23); - listView.AddChidren(frameTemp); - } - }); - } - } - - #endregion - - #region 鈻� 涓嬫媺鍒锋柊___________________________ - - /// <summary> - /// 婊戝姩鎺т欢涓嬫媺鍒锋柊 - /// </summary> - private void ListViewBeginHeaderRefreshing() - { - //濡傛灉褰撳墠浣忓畢鏄櫄鎷熺殑 - if (Common.Config.Instance.Home.IsVirtually == true) - { - //灏辨樉绀轰竴涓壒鏁堣�屽凡 - System.Threading.Thread.Sleep(2000); - HdlThreadLogic.Current.RunMain(() => - { - //闅愯棌涓嬫媺鍒锋柊鐗规晥 - listView.EndHeaderRefreshing(); - }); - return; - } - //濡傛灉鏄湪绾跨殑 - var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.NowSelectGatewayId); - if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(nowGateway) == true) - { - //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D - ZbGateway realWay = null; - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, nowGateway) == true) - { - //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆) - if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.HomeId) == true) - { - //鏄剧ず杩涘害鏉� - ProgressBar.Show(); - int result2 = HdlGatewayLogic.Current.ReBindNewGateway(realWay); - //鍏抽棴杩涘害鏉� - ProgressBar.Close(); - if (result2 == -1) - { - HdlThreadLogic.Current.RunMain(() => - { - //闅愯棌涓嬫媺鍒锋柊鐗规晥 - listView.EndHeaderRefreshing(); - }); - return; - } - } - } - } - if (this.Parent == null) - { - return; - } - - //鑾峰彇鍏ㄩ儴璁惧 - int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway, false); - if (this.Parent == null) - { - return; - } - HdlThreadLogic.Current.RunMain(() => - { - //闅愯棌涓嬫媺鍒锋柊鐗规晥 - listView.EndHeaderRefreshing(); - if (result != -1) - { - //閲嶆柊鍒锋柊鐣岄潰 - this.InitMiddleFrame(); - } - }); - } - - #endregion - - #region 鈻� 缃戝叧鍦ㄧ嚎妫�娴媉______________________ - - /// <summary> - /// 寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ - /// </summary> - private void StartGatewayOnlieCheckThread() - { - string selectGwId = GatewayResourse.NowSelectGatewayId; - HdlThreadLogic.Current.RunThread(() => - { - ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId); - if (zbGateway == null) - { - return; - } - //鍒锋柊缃戝叧鍦ㄧ嚎鐘舵�� - HdlGatewayLogic.Current.RefreshGatewayOnlineStatu(new List<ZbGateway>() { zbGateway }); - - HdlThreadLogic.Current.RunMain(() => - { - if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId) - { - bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbGateway); - //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� - this.gatewayViewRow?.RefreshOnlineStatu(); - //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� - this.RefreshDeviceOnlineStatuByGatewayOnline(online); - } - }); - }); - } - - /// <summary> - /// 缃戝叧鍦ㄧ嚎鐘舵�佸彉鏇� - /// </summary> - /// <param name="gateWay">缃戝叧瀵硅薄</param> - /// <param name="online">鍦ㄧ嚎鐘舵�佸彉鏇村悗鐨勭姸鎬�</param> - /// <param name="hadGwOnline">2020.05.25杩藉姞:姝や綇瀹呮槸鍚︽嫢鏈夌綉鍏冲湪绾�</param> - public override void GatewayOnlinePush(ZbGateway gateWay, bool online, bool hadGwOnline) - { - if (this.gatewayViewRow == null) - { - return; - } - if (gateWay.GwId == this.gatewayViewRow.zbGatewayId) - { - HdlThreadLogic.Current.RunMain(() => - { - //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂� - if (this.gatewayViewRow.isOnline != online) - { - //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� - this.RefreshDeviceOnlineStatuByGatewayOnline(online); - } - //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� - this.gatewayViewRow?.RefreshOnlineStatu(); - }); - } - } - - #endregion - - #region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________ - - /// <summary> - /// 鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� - /// </summary> - /// <param name="gatewayOnline">缃戝叧鐨勫湪绾跨姸鎬�</param> - private void RefreshDeviceOnlineStatuByGatewayOnline(bool gatewayOnline) - { - if (gatewayOnline == false) - { - //璁剧疆鍏ㄩ儴璁惧绂荤嚎 - this.SetAllDeviceOffLine(); - } - else - { - //鍒锋柊璁惧鍦ㄧ嚎鐘舵�� - this.RefreshDeviceOnlineStatu(); - } - } - - /// <summary> - /// 鍒锋柊璁惧鍦ㄧ嚎鐘舵�� - /// </summary> - private void RefreshDeviceOnlineStatu() - { - string gwId = GatewayResourse.NowSelectGatewayId; - HdlThreadLogic.Current.RunThread(() => - { - if (this.Parent == null) { return; } - //鑾峰彇璁惧鍒楄〃 - var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwId); - var listCheck = new List<string>(); - foreach (var device in listDevice) - { - if (this.Parent == null) { return; } - if (listCheck.Contains(device.DeviceAddr) == false) - { - //鍙涓�涓洖璺嵆鍙� - listCheck.Add(device.DeviceAddr); - var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device); - if (deviceInfo != null) - { - //鍙樻洿鍦ㄧ嚎鐘舵�� - device.IsOnline = deviceInfo.IsOnline; - HdlThreadLogic.Current.RunMain(() => - { - //璁剧疆璁惧鍦ㄧ嚎鐘舵�� - this.ReceiveDeviceStatu(device); - }, ShowErrorMode.NO); - } - System.Threading.Thread.Sleep(50); - } - } - }); - } - - /// <summary> - /// 鎺ュ彈璁惧鐘舵�� - /// </summary> - /// <param name="device"></param> - private void ReceiveDeviceStatu(CommonDevice device) - { - DeviceObjRowInfo rowInfo = null; - if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true) - { - rowInfo = this.dicRowInfo[device.DeviceAddr]; - } - if (rowInfo == null || rowInfo.MenuRow == null) - { - return; - } - //鍒锋柊璁惧鐨勫湪绾跨姸鎬� - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); - var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); - if (localDevice != null) - { - //淇濆瓨鐘舵�� - localDevice.IsOnline = device.IsOnline; - } - - rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); - if (rowInfo.dicDetailRow != null) - { - foreach (var detailRow in rowInfo.dicDetailRow.Values) - { - detailRow.IsOnline = rowInfo.MenuRow.IsOnline; - } - } - } - - /// <summary> - /// 璁剧疆鍏ㄩ儴璁惧绂荤嚎 - /// </summary> - private void SetAllDeviceOffLine() - { - foreach (var rowInfo in this.dicRowInfo.Values) - { - //鑿滃崟 - if (rowInfo.MenuRow != null) - { - rowInfo.MenuRow.IsOnline = false; - } - //鏄庣粏 - if (rowInfo.dicDetailRow != null) - { - foreach (var detailRow in rowInfo.dicDetailRow.Values) - { - detailRow.IsOnline = false; - } - } - } - } - - #endregion - - #region 鈻� 浼犳劅鍣ㄦ姤璀________________________ - - /// <summary> - /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣 - /// </summary> - private void StartCheckDeviceAlarm() - { - HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) => - { - HdlThreadLogic.Current.RunMain(() => - { - if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false) - { - return; - } - //鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥 - this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal(); - }); - }); - } - - #endregion - - #region 鈻� 璁惧鏂扮増鏈琠________________________ - - /// <summary> - /// 妫�娴嬭澶囨柊鐗堟湰 - /// </summary> - /// <param name="list">ota璁惧</param> - private void CheckDeviceNewVersion(List<OTADevice> list) - { - HdlThreadLogic.Current.RunThread(() => - { - System.Threading.Thread.Sleep(2000); - foreach (var ota in list) - { - if (this.Parent == null) - { - return; - } - //娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�) - var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.A璁惧, ota.HwVersion.ToString(), ota.ImgTypeId.ToString()); - - //鑾峰彇璁惧鏈�鏂扮増鏈� - var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.A璁惧, - ota.HwVersion.ToString(), - ota.ImgTypeId.ToString(), - ota.ImgVersion); - - if (deviceFirmware == null) - { - continue; - } - - //鎷ユ湁鏂扮増鏈� - HdlThreadLogic.Current.RunMain(() => - { - if (this.dicRowInfo.ContainsKey(ota.DeviceAddr) == true) - { - var row = this.dicRowInfo[ota.DeviceAddr].MenuRow; - if (row != null) - { - var btnNew = (InformationTipView)row.GetTagByKey("btnNew"); - if (btnNew != null) - { - btnNew.Visible = true; - } - } - } - }); - } - }); - } - - #endregion - - #region 鈻� 瀹炵幇澶栭儴璋冪敤_______________________ - - /// <summary> - /// 娣诲姞鏂扮殑璁惧鍒扮晫闈㈡甯冧腑(澶栭儴璋冪敤) - /// </summary> - /// <param name="deviceAddr">璁惧Mac鍦板潃</param> - public void AddDeviceToFormTable(string deviceAddr) - { - //鏂板缓涓�涓璞� - if (this.dicRowInfo.ContainsKey(deviceAddr) == false) - { - var localDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr); - if (localDevice.Count == 0) - { - //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶� - var ota = Common.LocalDevice.Current.GetOTADevice(deviceAddr); - if (ota == null) - { - //鍏ョ綉涔嬪悗锛屽張鎶婂畠鍒犱簡 - return; - } - localDevice.Add(ota); - } - var rowNewInfo = new DeviceObjRowInfo(); - rowNewInfo.DeviceMac = deviceAddr; - rowNewInfo.MacName = Common.LocalDevice.Current.GetDeviceMacName(localDevice[0]); - rowNewInfo.DeviveTypeName = Common.LocalDevice.Current.GetDeviceObjectText(localDevice); - this.dicRowInfo[deviceAddr] = rowNewInfo; - - //鍒涘缓鏂扮殑琛� - this.AddDeviceMenuRow(deviceAddr); - - //璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 - this.nowActionDeviceMac = deviceAddr; - } - } - - /// <summary> - /// 鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅(澶栭儴璋冪敤) - /// </summary> - /// <param name="deviceAddr">璁惧Mac鍦板潃</param> - public void RefreshDeviceRow(string deviceAddr) - { - if (this.dicRowInfo.ContainsKey(deviceAddr) == true) - { - var rowInfo = this.dicRowInfo[deviceAddr]; - //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂� - if (LocalDevice.Current.GetDevicesByMac(deviceAddr).Count == 0 - && LocalDevice.Current.GetOTADevice(deviceAddr) == null) - { - //绉婚櫎鎺т欢 - rowInfo.dicDetailRow = null; - rowInfo.frameTable.RemoveFromParent(); - - this.dicRowInfo.Remove(deviceAddr); - } - else - { - //鍒锋柊璁惧淇℃伅 - rowInfo.MenuRow?.RefreshControlInfo(true); - if (rowInfo.dicDetailRow != null) - { - foreach (var contr in rowInfo.dicDetailRow.Values) - { - contr?.RefreshControlInfo(); - } - } - } - } - } - - #endregion - - #region 鈻� 鍚堝苟鏁版嵁___________________________ - - /// <summary> - /// 鏍规嵁MAC鍚堝苟璁惧鍒楄〃 - /// </summary> - /// <param name="listDevice"></param> - private void MargeAllDeviceByMac(List<CommonDevice> listDevice) - { - //鏍规嵁Mac鍏ㄩ儴鍒嗙粍 - var dic = new Dictionary<string, List<CommonDevice>>(); - foreach (CommonDevice device in listDevice) - { - if (device == null || device.DeviceAddr == null) - { - continue; - } - - //鑾峰彇璁惧绫诲瀷鐨� - var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); - if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleEnvironment) - { - foreach (var outClu in device.OutClusterList) - { - //鍘绘帀绠�绾︾幆澧冮潰鏉跨被鐨勫悇绉嶆湇鍔$璁惧锛屽鍐呮満涓嶆樉绀� - if (outClu.OutCluster == 513) - { - continue; - } - } - } - if (dic.ContainsKey(device.DeviceAddr) == false) - { - dic[device.DeviceAddr] = new List<CommonDevice>(); - } - dic[device.DeviceAddr].Add(device); - } - //鑾峰彇淇℃伅 - foreach (var mac in dic.Keys) - { - var info = new DeviceObjRowInfo(); - info.DeviceMac = mac; - info.MacName = Common.LocalDevice.Current.GetDeviceMacName(dic[mac][0]); - info.DeviveTypeName = Common.LocalDevice.Current.GetDeviceObjectText(dic[mac]); - this.dicRowInfo[mac] = info; - } - } - - #endregion - - #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ - - /// <summary> - /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� - /// </summary> - public override int FormActionAgainEvent() - { - if (this.nowActionDeviceMac != null) - { - //鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅 - this.RefreshDeviceRow(this.nowActionDeviceMac); - } - //娓呯┖璁板綍 - this.nowActionDeviceMac = null; - //缃戝叧鎺т欢鍒锋柊 - this.gatewayViewRow.RefreshControl(); - - return 1; - } - - #endregion - - #region 鈻� 鍏抽棴鐣岄潰___________________________ - - /// <summary> - /// 鐢婚潰鍏抽棴 - /// </summary> - public override void CloseFormBefore() - { - HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor"); - HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); - - base.CloseFormBefore(); - } - - #endregion - - #region 鈻� 缁撴瀯浣撶被___________________________ - - /// <summary> - /// 璁惧琛屼俊鎭� - /// </summary> - private class DeviceObjRowInfo - { - /// <summary> - /// 璁惧Mac鍦板潃 - /// </summary> - public string DeviceMac = string.Empty; - /// <summary> - /// 璁惧鐨凪AC鍚嶅瓧 - /// </summary> - public string MacName = string.Empty; - /// <summary> - /// 璁惧绫诲瀷鐨勬枃鏈俊鎭� - /// </summary> - public string DeviveTypeName = string.Empty; - /// <summary> - /// 鑿滃崟琛� - /// </summary> - public DeviceObjectControl MenuRow = null; - /// <summary> - /// 妗屽竷FrameLayout - /// </summary> - public FrameListControl frameTable = null; - /// <summary> - /// 鏄庣粏琛� - /// </summary> - public Dictionary<string, DeviceRoomControl> dicDetailRow = null; - } - - #endregion - - #region 鈻� 鑷畾涔夌綉鍏虫帶浠禵____________________ - - /// <summary> - /// 鑷畾涔夌綉鍏虫帶浠� - /// </summary> - private class MyGatewayControl : FrameRowControl - { - /// <summary> - /// 缃戝叧ID - /// </summary> - public string zbGatewayId = string.Empty; - /// <summary> - /// 缃戝叧鍚嶅瓧鎺т欢 - /// </summary> - private NormalViewControl btnName = null; - /// <summary> - /// 鍦ㄧ嚎鐘舵�� - /// </summary> - public bool isOnline = false; - - /// <summary> - /// 鑷畾涔夌綉鍏虫帶浠� - /// </summary> - /// <param name="i_zbGateway">缃戝叧瀵硅薄</param> - public MyGatewayControl(ZbGateway i_zbGateway) - { - this.UseClickStatu = false; - if (i_zbGateway != null) - { - this.zbGatewayId = i_zbGateway.GwId; - } - this.BackgroundColor = UserCenterColor.Current.White; - this.Y = Application.GetRealHeight(174); - this.Height = Application.GetRealHeight(173); - } - - /// <summary> - /// 鍒濆鍖栨帶浠� - /// </summary> - public void InitControl() - { - //鑾峰彇鏈湴缃戝叧瀵硅薄 - ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); - //鍥炬爣 - var btnIcon = this.AddLeftIcon(81); - if (zbway != null) - { - HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway); - } - else - { - btnIcon.UnSelectedImagePath = "Gateway/GatewayIcon1.png"; - } - - //鏄剧ず鏂囨湰 - btnName = this.AddLeftCaption(string.Empty, 700); - btnName.Height = Application.GetRealHeight(60); - btnName.TextSize = 15; - btnName.Y = Application.GetRealHeight(35); - if (zbway != null) - { - btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); - //鍦ㄧ嚎鐘舵�� - this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); - if (this.isOnline == false) - { - btnName.TextColor = UserCenterColor.Current.TextGrayColor1; - } - } - else - { - //铏氭嫙缃戝叧 - btnName.Text = Language.StringByID(R.MyInternationalizationString.uVirtualGateway); - } - - //褰撳墠缃戝叧 - var btnNowGw = this.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowGateway), 700); - btnNowGw.Height = Application.GetRealHeight(49); - btnNowGw.TextSize = 12; - btnNowGw.Y = Application.GetRealHeight(95); - btnNowGw.TextColor = UserCenterColor.Current.TextGrayColor1; - - //鍚戝彸鍥炬爣 - var btnRight = this.AddRightArrow(); - btnRight.Name = "btnRight"; - //缃戝叧绠$悊 - var btnMament = this.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGatewayManagement), 300); - btnMament.Name = "btnMament"; - - //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽 - if (Common.Config.Instance.Home.IsVirtually == false) - { - this.ButtonClickEvent += (sernder, e) => - { - if (string.IsNullOrEmpty(((View)sernder).Name) == false) - { - //鎵撳紑缃戝叧鍒楄〃鐣岄潰 - var form = new GatewayManage.GatewayListForm(); - form.AddForm(); - } - }; - } - } - - /// <summary> - /// 鍒锋柊鎺т欢淇℃伅 - /// </summary> - public void RefreshControl() - { - //鑾峰彇鏈湴缃戝叧瀵硅薄 - ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); - if (zbway == null) - { - return; - } - btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); - //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� - this.RefreshOnlineStatu(); - } - - /// <summary> - /// 鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� - /// </summary> - public void RefreshOnlineStatu() - { - //鑾峰彇鏈湴缃戝叧瀵硅薄 - ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); - if (zbway == null) - { - return; - } - //鍦ㄧ嚎鐘舵�� - bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); - if (this.isOnline != statu) - { - this.isOnline = statu; - if (this.isOnline == false) - { - btnName.TextColor = UserCenterColor.Current.TextGrayColor1; - } - else - { - btnName.TextColor = UserCenterColor.Current.TextColor1; - } - } - } - } - #endregion - - #region 鈻� 鑷畾涔夋櫤鑳介煶绠辨帶浠禵________________ - - /// <summary> - /// 鑷畾涔夌綉鍏虫帶浠� - /// </summary> - private class MySmartSoundControl : FrameRowControl - { - - /// <summary> - /// 缃戝叧鍚嶅瓧鎺т欢 - /// </summary> - private NormalViewControl btnName = null; - - /// <summary> - /// 鑷畾闊崇鍏虫帶浠� - /// </summary> - public MySmartSoundControl() - { - this.UseClickStatu = false; - this.BackgroundColor = UserCenterColor.Current.White; - this.Height = Application.GetRealHeight(173); - - //this.InitControl(); - } - - - /// <summary> - /// 鍒濆鍖栨帶浠� - /// </summary> - public void InitControl() - { - //鍥炬爣 - var btnIcon = this.AddLeftIcon(81); - btnIcon.UnSelectedImagePath = "SmartSound/SoundIcon.png"; - - //鏄剧ず鏂囨湰 - btnName = this.AddLeftCaption(string.Empty, 700); - btnName.Height = Application.GetRealHeight(60); - btnName.TextSize = 15; - btnName.Y = Application.GetRealHeight(57); - btnName.Text = "灏忓害灏忓害"; - - this.AddRightArrow(); - this.AddMostRightView("", 300, false).Name = "smartSoundLayout"; - this.AddBottomLine(); - } - } - #endregion - } + private MySmartSoundControl smmartSoundView = null; + /// <summary> + /// 缃戝叧鎺т欢 + /// </summary> + private MyGatewayControl gatewayViewRow = null; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </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>(); + /// <summary> + /// 褰撳墠姝e湪鎿嶄綔鐨勮澶囧璞ac鍦板潃(璁惧淇℃伅缂栬緫鐣岄潰鐢�) + /// </summary> + private string nowActionDeviceMac = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + this.ScrollEnabled = false; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DeviceManagement)); + + //鍙充笂娣诲姞鎸夐挳 + var btnAddDeviceIcon = new MostRightIconControl(69, 69); + btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png"; + topFrameLayout.AddChidren(btnAddDeviceIcon); + btnAddDeviceIcon.InitControl(); + btnAddDeviceIcon.ButtonClickEvent += (sender, e) => + { + var form = new DeviceDirection.AddDeviceTypeListForm(); + form.AddForm(); + }; + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + + //寮�鍚紶鎰熷櫒鎶ヨ鐩戣 + this.StartCheckDeviceAlarm(); + //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) => + { + HdlThreadLogic.Current.RunMain(() => + { + //鎺ュ彈璁惧鐘舵�� + this.ReceiveDeviceStatu(report); + + }, ShowErrorMode.NO); + }); + //寮�鍚娴嬬綉鍏冲湪绾跨姸鎬佺殑绾跨▼ + HdlGatewayLogic.Current.StartCheckGatewayOnlineThread(this); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤) + /// </summary> + public void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + smmartSoundView = new MySmartSoundControl(); + bodyFrameLayout.AddChidren(smmartSoundView); + smmartSoundView.InitControl(); + //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽 + if (Config.Instance.Home.IsVirtually == false) + { + smmartSoundView.ButtonClickEvent += (sernder, e) => + { + var form = new SmartSoundListForm(); + form.AddForm(); + }; + } + //鍒濆鍖栫綉鍏宠鎺т欢 + GatewayResourse.NowSelectGatewayId = GatewayResourse.AppOldSelectGatewayId; + var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); + this.gatewayViewRow = new MyGatewayControl(nowGateway); + bodyFrameLayout.AddChidren(gatewayViewRow); + gatewayViewRow.InitControl(); + + //鍒濆鍖栨悳绱㈡帶浠� + this.InitSearchControl(); + + HdlThreadLogic.Current.RunThread(() => + { + //鍒濆鍖栬澶囧垪琛ㄦ帶浠� + this.InitDeviceListControl(); + }); + } + + #endregion + + #region 鈻� 鍒濆鍖栨悳绱㈡帶浠禵____________________ + + /// <summary> + /// 鍒濆鍖栨悳绱㈡帶浠� + /// </summary> + private void InitSearchControl() + { + //鐧借壊鑳屾櫙 + var frame = new FrameLayout(); + frame.BackgroundColor = UserCenterColor.Current.White; + frame.Y = this.gatewayViewRow.Bottom + Application.GetRealHeight(23); + frame.Height = bodyFrameLayout.Height - this.gatewayViewRow.Bottom - Application.GetRealHeight(23); + bodyFrameLayout.AddChidren(frame); + + //鎼滅储璁惧鍏抽敭璇� + string textTip = Language.StringByID(R.MyInternationalizationString.uSearchDeviceKeyWorld); + var txtSearchControl = new SearchTextControl(textTip); + frame.AddChidren(txtSearchControl); + txtSearchControl.Y = Application.GetRealHeight(46); + //缁戝畾鍥炶皟鍑芥暟 + txtSearchControl.BindEvent(this.SetRowDataBySearchKeys); + + //鍒楄〃鎺т欢 + listView = new VerticalListRefreshControl(29); + listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29); + listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29); + frame.AddChidren(listView); + listView.BeginHeaderRefreshingAction += () => + { + //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� + UserView.UserPage.Instance.RefreshAllForm = true; + + HdlThreadLogic.Current.RunThread(() => + { + //涓嬫媺鍒锋柊 + this.ListViewBeginHeaderRefreshing(); + }); + }; + } + + #endregion + + #region 鈻� 鍒濆鍖栬澶囧垪琛ㄦ帶浠禵________________ + + /// <summary> + /// 鍒濆鍖栬澶囧垪琛ㄦ帶浠� + /// </summary> + private void InitDeviceListControl() + { + //鑾峰彇璁惧鍒楄〃 + var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(GatewayResourse.NowSelectGatewayId); + var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(GatewayResourse.NowSelectGatewayId); + listDevice.AddRange(listSpecialOta); + + this.dicRowInfo.Clear(); + + //娌℃湁璁惧 + if (listDevice.Count == 0) + { + return; + } + + //鏍规嵁MAC鍚堝苟璁惧鍒楄〃 + this.MargeAllDeviceByMac(listDevice); + + if (this.Parent == null) + { + return; + } + HdlThreadLogic.Current.RunMain(() => + { + var listOta = new List<OTADevice>(); + foreach (var macAddress in this.dicRowInfo.Keys) + { + //鑾峰彇ota璁惧 + var ota = Common.LocalDevice.Current.GetOTADevice(macAddress); + if (ota != null) + { + listOta.Add(ota); + } + //娣诲姞璁惧鐨勮彍鍗曡 + this.AddDeviceMenuRow(macAddress); + } + //濡傛灉褰撳墠涓嶆槸铏氭嫙浣忓畢 + if (Common.Config.Instance.Home.IsVirtually == false) + { + //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ + this.StartGatewayOnlieCheckThread(); + //妫�娴嬭澶囨柊鐗堟湰 + this.CheckDeviceNewVersion(listOta); + } + }); + } + + #endregion + + #region 鈻� 娣诲姞璁惧鑿滃崟琛宊____________________ + + /// <summary> + /// 娣诲姞璁惧鐨勮彍鍗曡 + /// </summary> + /// <param name="deviceMac">璁惧Mac鍦板潃</param> + private void AddDeviceMenuRow(string deviceMac) + { + var rowInfo = this.dicRowInfo[deviceMac]; + + //鍒涘缓涓�涓彲浠ュ睍寮�鍜屾敹缂╃殑FrameLayout,鐩稿綋浜庤彍鍗曟爮 + var frameTable = new FrameListControl(29); + frameTable.Height = ControlCommonResourse.ListViewRowHeight + frameTable.rowSpace; + listView.AddChidren(frameTable); + rowInfo.frameTable = frameTable; + + //鎺т欢 + var rowMenu = new DeviceObjectControl(deviceMac, listView.rowSpace / 2); + rowMenu.MainKeys = deviceMac; + frameTable.AddChidren(rowMenu); + rowMenu.InitControl(); + rowInfo.MenuRow = rowMenu; + //鍚戝彸鍥炬爣 + var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58); + btnRight.UnSelectedImagePath = "Item/RightNext.png"; + btnRight.SelectedImagePath = "Item/Down.png"; + rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind); + + //鎻愮ず鏂扮増鏈� + var btnNew = new InformationTipView(rowMenu.btnIcon); + btnNew.Visible = false; + rowMenu.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEvent); + rowMenu.AddTag("btnNew", btnNew); + + //妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘 + var listdevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac); + if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true) + { + //瀹氫綅 + var btnPosition = rowMenu.AddEditorControl(false); + btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; + btnPosition.ButtonClickEvent += (sender, e) => + { + //瀹氫綅 + Common.LocalDevice.Current.SetFixedPositionCommand(listdevice[0], true); + }; + } + + //灞曞紑,鎶樺彔 + btnRight.ButtonClickEvent += (sender, e) => + { + //鍥炶矾鏁板ぇ浜�1鎵嶅睍寮� + var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false); + if (listMacDevice.Count > 1) + { + btnRight.IsSelected = !btnRight.IsSelected; + //灞曞紑鎴栬�呮姌鍙犳槑缁嗗垪琛� + this.ShowDetailList(deviceMac, btnRight.IsSelected); + } + else + { + if (LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true) + { + //mini澶滅伅鐨勫姛鑳借缃晫闈� + var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]); + var form = new MainPage.DeviceDetailInfoForm(); + form.AddForm(listMacDevice[0], room); + } + else + { + //璁惧淇℃伅鐣岄潰 + var form = new DeviceMacInfoEditorForm(); + form.AddForm(deviceMac); + } + btnNew.Visible = false; + //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = deviceMac; + } + }; + + rowMenu.frameTable.ButtonClickEvent += (sender, e) => + { + //闅愯棌鑿滃崟 + rowMenu.HideMenu(); + //寮哄埗璺宠浆鐪熷疄璁惧鐣岄潰 + if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1) + { + var form2 = new DeviceAddSuccessForm(); + form2.AddForm(deviceMac); + return; + } + var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false); + if (listMacDevice.Count > 0 && LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true) + { + //mini澶滅伅鐨勫姛鑳借缃晫闈� + var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]); + var form = new MainPage.DeviceDetailInfoForm(); + form.AddForm(listMacDevice[0], room); + } + else + { + //璁惧淇℃伅鐣岄潰 + var form = new DeviceMacInfoEditorForm(); + form.AddForm(deviceMac); + } + + btnNew.Visible = false; + //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = deviceMac; + }; + //宸︽粦鑿滃崟浜嬩欢 + rowMenu.OpenMenuAction += () => + { + if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowMenu.MainKeys) + { + //宸︽粦鑿滃崟鍙兘婊戜竴涓� + this.oldShowRightMuneRow.HideMenu(); + } + this.oldShowRightMuneRow = rowMenu; + }; + } + + #endregion + + #region 鈻� 灞曞紑鎶樺彔___________________________ + + /// <summary> + /// 灞曞紑鎴栬�呴殣钘忓垪琛� + /// </summary> + /// <param name="deviceMac">璁惧Mac鍦板潃</param> + /// <param name="isShow">鏄惁灞曞紑</param> + private void ShowDetailList(string deviceMac, bool isShow) + { + var rowInfo = this.dicRowInfo[deviceMac]; + //瀹冨師鏉ョ殑楂樺害 + int oldHeight = rowInfo.frameTable.Height; + //鍙樻洿鐨勯珮搴�,榛樿涓哄垪琛ㄩ殣钘� + int heightValue = ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace; + var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac); + if (isShow == true) + { + //澶囨敞锛氶潰鏉夸腑鍙樉绀虹湡瀹炵殑璁惧锛屽叾浠栧睘浜庣粦瀹氱殑鍥炶矾涓嶆樉绀� + //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑 + var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice); + if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) + { + var listTemp = Common.LocalDevice.Current.GetMutilfunctionPanelByMac(listDevice); + //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� + heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); + //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 + if (rowInfo.frameTable.ChildrenCount == 1) + { + foreach (CommonDevice info in listTemp) + { + //鍔犺浇瀹冪殑鍒楄〃 + this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); + } + } + } + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir + || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment + || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment) + { + var listTemp = Common.LocalDevice.Current.GetPanelMatchEpointByMac(listDevice); + //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� + heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); + //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 + if (rowInfo.frameTable.ChildrenCount == 1) + { + foreach (CommonDevice info in listTemp) + { + //鍔犺浇瀹冪殑鍒楄〃 + this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); + } + } + } + else + { + //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠� + heightValue = (listDevice.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace); + //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 + if (rowInfo.frameTable.ChildrenCount == 1) + { + foreach (CommonDevice info in listDevice) + { + //鍔犺浇瀹冪殑鍒楄〃 + this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); + } + } + } + } + //鑷韩楂樺害鍙樻洿 + rowInfo.frameTable.Height = heightValue; + } + + /// <summary> + /// 娣诲姞璁惧鐨勬槑缁嗚 + /// </summary> + /// <param name="frame">瀹瑰櫒</param> + /// <param name="device"></param> + /// <param name="deviceEnumInfo"></param> + private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device, DeviceEnumInfo deviceEnumInfo) + { + var rowInfo = this.dicRowInfo[device.DeviceAddr]; + if (rowInfo.dicDetailRow == null) + { + rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>(); + } + + //琛屾帶浠� + 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(); + //搴曠嚎 + rowDevice.frameTable.AddBottomLine(); + //鍙崇澶� + rowDevice.frameTable.AddRightArrow(); + //鍦ㄧ嚎鐘舵�� + rowDevice.IsOnline = rowInfo.MenuRow.IsOnline; + //淇濆瓨鎺т欢 + string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device); + rowInfo.dicDetailRow[maikey] = rowDevice; + + //妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘 + if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(device) == true) + { + //瀹氫綅 + var btnPosition = rowDevice.AddEditorControl(false); + btnPosition.TextID = R.MyInternationalizationString.uFixedPosition; + btnPosition.ButtonClickEvent += (sender, e) => + { + //瀹氫綅 + Common.LocalDevice.Current.SetFixedPositionCommand(device); + }; + } + + rowDevice.frameTable.ButtonClickEvent += (sender, e) => + { + //闅愯棌鑿滃崟 + rowDevice.HideMenu(); + //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = device.DeviceAddr; + //濡傛灉褰撳墠浣忓畢涓嶆槸铏氭嫙浣忓畢 + 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; + }; + } + + /// <summary> + /// 鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 + /// </summary> + /// <param name="device"></param> + /// <param name="deviceEnumInfo"></param> + private void ShowDeviceFunctionSettionForm(CommonDevice device, DeviceEnumInfo deviceEnumInfo) + { + //鏅鸿兘闂ㄩ攣 + if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鏅鸿兘闂ㄩ攣) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鏅捐。鏋�) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绌烘皵璐ㄩ噺) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + //pir浼犳劅鍣� + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir) + { + if (device is IASZone) + { + var form = new DevicePirSensor.PirSensorBindTargetSettionForm(); + form.AddForm((IASZone)device); + } + else + { + //pir浼犳劅鍣�,浠栦滑鍙堟悶浜嗕釜缁х數鍣ㄥ湪閲岄潰 + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //涓ぎ绌鸿皟 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway) + { + var form = new DeviceAirConditioner.IndoorUnitSettionForm(); + form.AddForm((AC)device); + } + //鏂伴闈㈡澘 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) + { + //鏂规偊鏂伴闈㈡澘鐨勬寜閿厤缃� + //骞叉帴鐐� + if (device.Type == DeviceType.FreshAir) + { + var form = new DevicePanel.PanelSettionWithSourceForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment) + { + + if (device.Type == DeviceType.FreshAir || device.Type == DeviceType.Thermostat) + { + var form = new DevicePanel.PanelSettionWithSourceForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //绠�绾﹀鍔熻兘闈㈡澘鐨勬寜閿厤缃� + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + //鏂规偊闈㈡澘 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo + || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFour + || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEight) + { + //骞叉帴鐐� + if (device.Type == DeviceType.OnOffSwitch) + { + //鏂规偊闈㈡澘鐨勬寜閿厤缃� + var form = new DevicePanel.PanelFangyueButtonSettionForm(); + form.AddForm(device); + } + //缁х數鍣� + else if (device.Type == DeviceType.OnOffOutput) + { + //鏂规偊闈㈡澘鐨勫姛鑳介厤缃� + var form = new DevicePanel.PanelFangyueFunctionSettionForm(); + form.AddForm(device, deviceEnumInfo); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //闈㈡澘璁惧 + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘) + { + //骞叉帴鐐� + if (device.Type == DeviceType.OnOffSwitch) + { + //娌充笢璁惧 + if (deviceEnumInfo.IsHdlDevice == true) + { + var form = new DevicePanel.PanelButtonSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceDryContactSettionForm(); + form.AddForm(device); + } + } + //缁х數鍣� + else if (device.Type == DeviceType.OnOffOutput) + { + //娌充笢璁惧 + if (deviceEnumInfo.IsHdlDevice == true) + { + var form = new DevicePanel.PanelFunctionSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //濡傛灉鏄共鎺ョ偣 + else if (device.Type == DeviceType.OnOffSwitch) + { + var form = new DeviceDryContactSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + + #endregion + + #region 鈻� 閿�兼悳绱__________________________ + + /// <summary> + /// 鏍规嵁鎼滅储閿�硷紝璁惧畾鍒楄〃鏁版嵁 + /// </summary> + /// <param name="searchKey">Search key.</param> + private void SetRowDataBySearchKeys(string searchKey) + { + lock (dicRowInfo) + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.listView == null) + { + return; + } + //棣栧厛鍏堢Щ闄ゅ垪琛ㄦ墍鏈夋帶浠� + this.listView.RemoveAll(); + //濡傛灉鎼滅储閿�间负绌猴紝鍒欒繕鍘熶负鍘熷鐘舵��:鏄剧ず璁惧绫诲瀷鎬昏 + if (searchKey == string.Empty) + { + foreach (var deviceMac in dicRowInfo.Keys) + { + //娣诲姞璁惧鐨勮 + this.AddDeviceMenuRow(deviceMac); + } + //娣诲姞搴曢儴闂撮殭 + var frameTemp = new FrameLayout(); + frameTemp.Height = Application.GetRealHeight(23); + listView.AddChidren(frameTemp); + } + else + { + //鎼滅储鍚嶅瓧閲岄潰鍖呭惈閿�肩殑璁惧 + foreach (var rowInfo in this.dicRowInfo.Values) + { + if ((rowInfo.MacName != null && rowInfo.MacName.Contains(searchKey) == true) + || rowInfo.DeviveTypeName.Contains(searchKey) == true) + { + //娣诲姞璁惧鐨勮 + this.AddDeviceMenuRow(rowInfo.DeviceMac); + } + } + //娣诲姞搴曢儴闂撮殭 + var frameTemp = new FrameLayout(); + frameTemp.Height = Application.GetRealHeight(23); + listView.AddChidren(frameTemp); + } + }); + } + } + + #endregion + + #region 鈻� 涓嬫媺鍒锋柊___________________________ + + /// <summary> + /// 婊戝姩鎺т欢涓嬫媺鍒锋柊 + /// </summary> + private void ListViewBeginHeaderRefreshing() + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熺殑 + if (Common.Config.Instance.Home.IsVirtually == true) + { + //灏辨樉绀轰竴涓壒鏁堣�屽凡 + System.Threading.Thread.Sleep(2000); + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + }); + return; + } + //濡傛灉鏄湪绾跨殑 + var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.NowSelectGatewayId); + if (HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(nowGateway) == true) + { + //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D + ZbGateway realWay = null; + if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, nowGateway) == true) + { + //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆) + if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.HomeId) == true) + { + //鏄剧ず杩涘害鏉� + ProgressBar.Show(); + int result2 = HdlGatewayLogic.Current.ReBindNewGateway(realWay); + //鍏抽棴杩涘害鏉� + ProgressBar.Close(); + if (result2 == -1) + { + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + }); + return; + } + } + } + } + if (this.Parent == null) + { + return; + } + + //鑾峰彇鍏ㄩ儴璁惧 + int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway.GwId, false); + if (this.Parent == null) + { + return; + } + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + if (result != -1) + { + //閲嶆柊鍒锋柊鐣岄潰 + this.InitMiddleFrame(); + } + }); + } + + #endregion + + #region 鈻� 缃戝叧鍦ㄧ嚎妫�娴媉______________________ + + /// <summary> + /// 寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ + /// </summary> + private void StartGatewayOnlieCheckThread() + { + string selectGwId = GatewayResourse.NowSelectGatewayId; + HdlThreadLogic.Current.RunThread(() => + { + ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId); + if (zbGateway == null) + { + return; + } + //鍒锋柊缃戝叧鍦ㄧ嚎鐘舵�� + HdlGatewayLogic.Current.RefreshGatewayOnlineStatu(new List<ZbGateway>() { zbGateway }); + + HdlThreadLogic.Current.RunMain(() => + { + if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId) + { + bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbGateway); + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.gatewayViewRow?.RefreshOnlineStatu(); + //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� + this.RefreshDeviceOnlineStatuByGatewayOnline(online); + } + }); + }); + } + + /// <summary> + /// 缃戝叧鍦ㄧ嚎鐘舵�佸彉鏇� + /// </summary> + /// <param name="gateWay">缃戝叧瀵硅薄</param> + /// <param name="online">鍦ㄧ嚎鐘舵�佸彉鏇村悗鐨勭姸鎬�</param> + /// <param name="hadGwOnline">2020.05.25杩藉姞:姝や綇瀹呮槸鍚︽嫢鏈夌綉鍏冲湪绾�</param> + public override void GatewayOnlinePush(ZbGateway gateWay, bool online, bool hadGwOnline) + { + if (this.gatewayViewRow == null) + { + return; + } + if (gateWay.GwId == this.gatewayViewRow.zbGatewayId) + { + HdlThreadLogic.Current.RunMain(() => + { + //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂� + if (this.gatewayViewRow.isOnline != online) + { + //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� + this.RefreshDeviceOnlineStatuByGatewayOnline(online); + } + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.gatewayViewRow?.RefreshOnlineStatu(); + }); + } + } + + #endregion + + #region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________ + + /// <summary> + /// 鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� + /// </summary> + /// <param name="gatewayOnline">缃戝叧鐨勫湪绾跨姸鎬�</param> + private void RefreshDeviceOnlineStatuByGatewayOnline(bool gatewayOnline) + { + if (gatewayOnline == false) + { + //璁剧疆鍏ㄩ儴璁惧绂荤嚎 + this.SetAllDeviceOffLine(); + } + else + { + //鍒锋柊璁惧鍦ㄧ嚎鐘舵�� + this.RefreshDeviceOnlineStatu(); + } + } + + /// <summary> + /// 鍒锋柊璁惧鍦ㄧ嚎鐘舵�� + /// </summary> + private void RefreshDeviceOnlineStatu() + { + string gwId = GatewayResourse.NowSelectGatewayId; + HdlThreadLogic.Current.RunThread(() => + { + if (this.Parent == null) { return; } + //鑾峰彇璁惧鍒楄〃 + var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwId); + var listCheck = new List<string>(); + foreach (var device in listDevice) + { + if (this.Parent == null) { return; } + if (listCheck.Contains(device.DeviceAddr) == false) + { + //鍙涓�涓洖璺嵆鍙� + listCheck.Add(device.DeviceAddr); + var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device); + if (deviceInfo != null) + { + //鍙樻洿鍦ㄧ嚎鐘舵�� + device.IsOnline = deviceInfo.IsOnline; + HdlThreadLogic.Current.RunMain(() => + { + //璁剧疆璁惧鍦ㄧ嚎鐘舵�� + this.ReceiveDeviceStatu(device); + }, ShowErrorMode.NO); + } + System.Threading.Thread.Sleep(50); + } + } + }); + } + + /// <summary> + /// 鎺ュ彈璁惧鐘舵�� + /// </summary> + /// <param name="device"></param> + private void ReceiveDeviceStatu(CommonDevice device) + { + DeviceObjRowInfo rowInfo = null; + if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true) + { + rowInfo = this.dicRowInfo[device.DeviceAddr]; + } + if (rowInfo == null || rowInfo.MenuRow == null) + { + return; + } + //鍒锋柊璁惧鐨勫湪绾跨姸鎬� + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); + var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); + if (localDevice != null) + { + //淇濆瓨鐘舵�� + localDevice.IsOnline = device.IsOnline; + } + + rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); + if (rowInfo.dicDetailRow != null) + { + foreach (var detailRow in rowInfo.dicDetailRow.Values) + { + detailRow.IsOnline = rowInfo.MenuRow.IsOnline; + } + } + } + + /// <summary> + /// 璁剧疆鍏ㄩ儴璁惧绂荤嚎 + /// </summary> + private void SetAllDeviceOffLine() + { + foreach (var rowInfo in this.dicRowInfo.Values) + { + //鑿滃崟 + if (rowInfo.MenuRow != null) + { + rowInfo.MenuRow.IsOnline = false; + } + //鏄庣粏 + if (rowInfo.dicDetailRow != null) + { + foreach (var detailRow in rowInfo.dicDetailRow.Values) + { + detailRow.IsOnline = false; + } + } + } + } + + #endregion + + #region 鈻� 浼犳劅鍣ㄦ姤璀________________________ + + /// <summary> + /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣 + /// </summary> + private void StartCheckDeviceAlarm() + { + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) => + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false) + { + return; + } + //鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥 + this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal(); + }); + }); + } + + #endregion + + #region 鈻� 璁惧鏂扮増鏈琠________________________ + + /// <summary> + /// 妫�娴嬭澶囨柊鐗堟湰 + /// </summary> + /// <param name="list">ota璁惧</param> + private void CheckDeviceNewVersion(List<OTADevice> list) + { + HdlThreadLogic.Current.RunThread(() => + { + System.Threading.Thread.Sleep(2000); + foreach (var ota in list) + { + if (this.Parent == null) + { + return; + } + //娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�) + var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.A璁惧, ota.HwVersion.ToString(), ota.ImgTypeId.ToString()); + + //鑾峰彇璁惧鏈�鏂扮増鏈� + var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.A璁惧, + ota.HwVersion.ToString(), + ota.ImgTypeId.ToString(), + ota.ImgVersion); + + if (deviceFirmware == null) + { + continue; + } + + //鎷ユ湁鏂扮増鏈� + HdlThreadLogic.Current.RunMain(() => + { + if (this.dicRowInfo.ContainsKey(ota.DeviceAddr) == true) + { + var row = this.dicRowInfo[ota.DeviceAddr].MenuRow; + if (row != null) + { + var btnNew = (InformationTipView)row.GetTagByKey("btnNew"); + if (btnNew != null) + { + btnNew.Visible = true; + } + } + } + }); + } + }); + } + + #endregion + + #region 鈻� 瀹炵幇澶栭儴璋冪敤_______________________ + + /// <summary> + /// 娣诲姞鏂扮殑璁惧鍒扮晫闈㈡甯冧腑(澶栭儴璋冪敤) + /// </summary> + /// <param name="deviceAddr">璁惧Mac鍦板潃</param> + public void AddDeviceToFormTable(string deviceAddr) + { + //鏂板缓涓�涓璞� + if (this.dicRowInfo.ContainsKey(deviceAddr) == false) + { + var localDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr); + if (localDevice.Count == 0) + { + //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶� + var ota = Common.LocalDevice.Current.GetOTADevice(deviceAddr); + if (ota == null) + { + //鍏ョ綉涔嬪悗锛屽張鎶婂畠鍒犱簡 + return; + } + localDevice.Add(ota); + } + var rowNewInfo = new DeviceObjRowInfo(); + rowNewInfo.DeviceMac = deviceAddr; + rowNewInfo.MacName = Common.LocalDevice.Current.GetDeviceMacName(localDevice[0]); + rowNewInfo.DeviveTypeName = Common.LocalDevice.Current.GetDeviceObjectText(localDevice); + this.dicRowInfo[deviceAddr] = rowNewInfo; + + //鍒涘缓鏂扮殑琛� + this.AddDeviceMenuRow(deviceAddr); + + //璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = deviceAddr; + } + } + + /// <summary> + /// 鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅(澶栭儴璋冪敤) + /// </summary> + /// <param name="deviceAddr">璁惧Mac鍦板潃</param> + public void RefreshDeviceRow(string deviceAddr) + { + if (this.dicRowInfo.ContainsKey(deviceAddr) == true) + { + var rowInfo = this.dicRowInfo[deviceAddr]; + //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂� + if (LocalDevice.Current.GetDevicesByMac(deviceAddr).Count == 0 + && LocalDevice.Current.GetOTADevice(deviceAddr) == null) + { + //绉婚櫎鎺т欢 + rowInfo.dicDetailRow = null; + rowInfo.frameTable.RemoveFromParent(); + + this.dicRowInfo.Remove(deviceAddr); + } + else + { + //鍒锋柊璁惧淇℃伅 + rowInfo.MenuRow?.RefreshControlInfo(true); + if (rowInfo.dicDetailRow != null) + { + foreach (var contr in rowInfo.dicDetailRow.Values) + { + contr?.RefreshControlInfo(); + } + } + } + } + } + + #endregion + + #region 鈻� 鍚堝苟鏁版嵁___________________________ + + /// <summary> + /// 鏍规嵁MAC鍚堝苟璁惧鍒楄〃 + /// </summary> + /// <param name="listDevice"></param> + private void MargeAllDeviceByMac(List<CommonDevice> listDevice) + { + //鏍规嵁Mac鍏ㄩ儴鍒嗙粍 + var dic = new Dictionary<string, List<CommonDevice>>(); + foreach (CommonDevice device in listDevice) + { + if (device == null || device.DeviceAddr == null) + { + continue; + } + + //鑾峰彇璁惧绫诲瀷鐨� + var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); + if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleEnvironment) + { + foreach (var outClu in device.OutClusterList) + { + //鍘绘帀绠�绾︾幆澧冮潰鏉跨被鐨勫悇绉嶆湇鍔$璁惧锛屽鍐呮満涓嶆樉绀� + if (outClu.OutCluster == 513) + { + continue; + } + } + } + if (dic.ContainsKey(device.DeviceAddr) == false) + { + dic[device.DeviceAddr] = new List<CommonDevice>(); + } + dic[device.DeviceAddr].Add(device); + } + //鑾峰彇淇℃伅 + foreach (var mac in dic.Keys) + { + var info = new DeviceObjRowInfo(); + info.DeviceMac = mac; + info.MacName = Common.LocalDevice.Current.GetDeviceMacName(dic[mac][0]); + info.DeviveTypeName = Common.LocalDevice.Current.GetDeviceObjectText(dic[mac]); + this.dicRowInfo[mac] = info; + } + } + + #endregion + + #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ + + /// <summary> + /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� + /// </summary> + public override int FormActionAgainEvent() + { + if (this.nowActionDeviceMac != null) + { + //鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅 + this.RefreshDeviceRow(this.nowActionDeviceMac); + } + //娓呯┖璁板綍 + this.nowActionDeviceMac = null; + //缃戝叧鎺т欢鍒锋柊 + this.gatewayViewRow.RefreshControl(); + + return 1; + } + + #endregion + + #region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor"); + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); + + base.CloseFormBefore(); + } + + #endregion + + #region 鈻� 缁撴瀯浣撶被___________________________ + + /// <summary> + /// 璁惧琛屼俊鎭� + /// </summary> + private class DeviceObjRowInfo + { + /// <summary> + /// 璁惧Mac鍦板潃 + /// </summary> + public string DeviceMac = string.Empty; + /// <summary> + /// 璁惧鐨凪AC鍚嶅瓧 + /// </summary> + public string MacName = string.Empty; + /// <summary> + /// 璁惧绫诲瀷鐨勬枃鏈俊鎭� + /// </summary> + public string DeviveTypeName = string.Empty; + /// <summary> + /// 鑿滃崟琛� + /// </summary> + public DeviceObjectControl MenuRow = null; + /// <summary> + /// 妗屽竷FrameLayout + /// </summary> + public FrameListControl frameTable = null; + /// <summary> + /// 鏄庣粏琛� + /// </summary> + public Dictionary<string, DeviceRoomControl> dicDetailRow = null; + } + + #endregion + + #region 鈻� 鑷畾涔夌綉鍏虫帶浠禵____________________ + + /// <summary> + /// 鑷畾涔夌綉鍏虫帶浠� + /// </summary> + private class MyGatewayControl : FrameRowControl + { + /// <summary> + /// 缃戝叧ID + /// </summary> + public string zbGatewayId = string.Empty; + /// <summary> + /// 缃戝叧鍚嶅瓧鎺т欢 + /// </summary> + private NormalViewControl btnName = null; + /// <summary> + /// 鍦ㄧ嚎鐘舵�� + /// </summary> + public bool isOnline = false; + + /// <summary> + /// 鑷畾涔夌綉鍏虫帶浠� + /// </summary> + /// <param name="i_zbGateway">缃戝叧瀵硅薄</param> + public MyGatewayControl(ZbGateway i_zbGateway) + { + this.UseClickStatu = false; + if (i_zbGateway != null) + { + this.zbGatewayId = i_zbGateway.GwId; + } + this.BackgroundColor = UserCenterColor.Current.White; + this.Y = Application.GetRealHeight(174); + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鑾峰彇鏈湴缃戝叧瀵硅薄 + ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); + //鍥炬爣 + var btnIcon = this.AddLeftIcon(81); + if (zbway != null) + { + HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway); + } + else + { + btnIcon.UnSelectedImagePath = "Gateway/GatewayIcon1.png"; + } + + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 700); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 15; + btnName.Y = Application.GetRealHeight(35); + if (zbway != null) + { + btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); + //鍦ㄧ嚎鐘舵�� + this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbway); + if (this.isOnline == false) + { + btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + } + } + else + { + //铏氭嫙缃戝叧 + btnName.Text = Language.StringByID(R.MyInternationalizationString.uVirtualGateway); + } + + //褰撳墠缃戝叧 + var btnNowGw = this.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowGateway), 700); + btnNowGw.Height = Application.GetRealHeight(49); + btnNowGw.TextSize = 12; + btnNowGw.Y = Application.GetRealHeight(95); + btnNowGw.TextColor = UserCenterColor.Current.TextGrayColor1; + + //鍚戝彸鍥炬爣 + var btnRight = this.AddRightArrow(); + btnRight.Name = "btnRight"; + //缃戝叧绠$悊 + var btnMament = this.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGatewayManagement), 300); + btnMament.Name = "btnMament"; + + //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽 + if (Common.Config.Instance.Home.IsVirtually == false) + { + this.ButtonClickEvent += (sernder, e) => + { + if (string.IsNullOrEmpty(((View)sernder).Name) == false) + { + //鎵撳紑缃戝叧鍒楄〃鐣岄潰 + var form = new GatewayManage.GatewayListForm(); + form.AddForm(); + } + }; + } + } + + /// <summary> + /// 鍒锋柊鎺т欢淇℃伅 + /// </summary> + public void RefreshControl() + { + //鑾峰彇鏈湴缃戝叧瀵硅薄 + ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); + if (zbway == null) + { + return; + } + btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.RefreshOnlineStatu(); + } + + /// <summary> + /// 鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + /// </summary> + public void RefreshOnlineStatu() + { + //鑾峰彇鏈湴缃戝叧瀵硅薄 + ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); + if (zbway == null) + { + return; + } + //鍦ㄧ嚎鐘舵�� + bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbway); + if (this.isOnline != statu) + { + this.isOnline = statu; + if (this.isOnline == false) + { + btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + } + else + { + btnName.TextColor = UserCenterColor.Current.TextColor1; + } + } + } + } + #endregion + + #region 鈻� 鑷畾涔夋櫤鑳介煶绠辨帶浠禵________________ + + /// <summary> + /// 鑷畾涔夌綉鍏虫帶浠� + /// </summary> + private class MySmartSoundControl : FrameRowControl + { + + /// <summary> + /// 缃戝叧鍚嶅瓧鎺т欢 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鑷畾闊崇鍏虫帶浠� + /// </summary> + public MySmartSoundControl() + { + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + + //this.InitControl(); + } + + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鍥炬爣 + var btnIcon = this.AddLeftIcon(81); + btnIcon.UnSelectedImagePath = "SmartSound/SoundIcon.png"; + + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 700); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 15; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = "鏅鸿兘闊崇"; + + this.AddRightArrow(); + this.AddMostRightView("", 300, false).Name = "smartSoundLayout"; + this.AddBottomLine(); + } + } + #endregion + } } -- Gitblit v1.8.0