From a5b3c4bae726ef6770d4bfcbf2f4b50a37ed4a15 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 06 三月 2020 15:31:36 +0800 Subject: [PATCH] 删除了郭雪城的 DeviceUi 这个类 --- ZigbeeApp/GateWay.Droid/Assets/Language.ini | 5 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionDirectoryListForm.cs | 106 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneRoomControl.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs | 2 ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs | 43 ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberInfoForm.cs | 2 ZigbeeApp/Shared/Phone/Device/Category/Category.cs | 387 +- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/AccountOption.cs | 73 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs | 76 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs | 2 ZigbeeApp/Shared/Phone/Device/Light/PlugControl.cs | 72 ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 16 ZigbeeApp/Shared/Phone/UserCenter/Guide/GuideForm1.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/DirectoryFileNameResourse.cs | 4 ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs | 62 ZigbeeApp/Shared/Phone/UserView/UserPage.cs | 2 ZigbeeApp/Shared/Phone/Device/Category/SelectScene.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAlarmsLogic.cs | 46 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/ResidenceOption.cs | 90 ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs | 73 ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs | 4 ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/Residence/FloorListRoomForm.cs | 10 ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs | 71 ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs | 19 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs | 4 ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs | 46 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs | 1009 +++++ ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs | 43 ZigbeeApp/Shared/Phone/Device/Light/AirSwitchControl.cs | 106 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileListForm.cs | 153 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 9 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswSecondarySecurityForm.cs | 16 ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs | 2 ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs | 16 ZigbeeApp/Shared/Phone/Device/Account/AccountRegisterSuccess.cs | 2 ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 29 ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/BelongAreaControl.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs | 60 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/Member/SubAccountLevelUpSuccessForm.cs | 2 ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs | 63 ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs | 29 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs | 25 ZigbeeApp/Shared/Shared.projitems | 11 ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs | 57 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs | 122 ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs | 57 ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs | 60 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs | 12 ZigbeeApp/Shared/Phone/Device/Category/SelectDevice.cs | 49 ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs | 2972 +++++++-------- ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs | 4 ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/Base/EditorCommonForm.cs | 14 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs | 22 ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs | 22 ZigbeeApp/Shared/Common/CommonPage.cs | 2 ZigbeeApp/Shared/Phone/Device/Logic/Send.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs | 89 ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs | 55 ZigbeeApp/Shared/Common/SceneTargetDeviceUI.cs | 13 ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs | 49 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs | 8 ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs | 137 ZigbeeApp/Shared/Common/SceneUI.cs | 183 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs | 13 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneSimpleSelectControl.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs | 10 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceOtherLogic.cs | 310 + ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs | 2 ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs | 11 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceSelectControl.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs | 2 ZigbeeApp/Shared/Phone/UserView/HomePage.cs | 4 ZigbeeApp/Shared/Common/SceneRoomUI.cs | 10 ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs | 66 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs | 6 ZigbeeApp/Shared/Phone/Device/CommonForm/CategoryFunctionForWinRow.cs | 11 ZigbeeApp/Home.Ios/Resources/Language.ini | 5 ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs | 78 ZigbeeApp/Home.Ios/Home.IOS.csproj | 2 ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs | 44 ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs | 18 ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddScene.cs | 20 ZigbeeApp/Shared/Phone/UserCenter/Password/EditorGesturePasswordForm.cs | 18 ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddMenuForm.cs | 21 ZigbeeApp/Shared/R.cs | 15 ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs | 22 ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs | 59 ZigbeeApp/Shared/Phone/UserView/SafetyShortcutControl.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswGestureSecirityForm.cs | 16 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs | 2 ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 75 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs | 20 ZigbeeApp/Shared/Common/Device.cs | 155 ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionGatewayListForm.cs | 17 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs | 41 ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs | 109 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs | 310 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlSceneLogic.cs | 490 ++ ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs | 4 ZigbeeApp/Shared/Phone/Device/CommonForm/SelectFunctionView.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs | 12 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs | 4 /dev/null | 26 ZigbeeApp/Shared/Phone/UserCenter/Password/EditorSecondaryPasswordForm.cs | 18 ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs | 64 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/UserCenterResourse.cs | 12 ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs | 11 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs | 23 ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs | 47 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs | 10 ZigbeeApp/Shared/Common/House.cs | 37 ZigbeeApp/Shared/Common/Room.cs | 1712 --------- 130 files changed, 5,768 insertions(+), 5,021 deletions(-) diff --git a/ZigbeeApp/GateWay.Droid/Assets/Language.ini b/ZigbeeApp/GateWay.Droid/Assets/Language.ini index 97c3bb2..e2755c4 100755 --- a/ZigbeeApp/GateWay.Droid/Assets/Language.ini +++ b/ZigbeeApp/GateWay.Droid/Assets/Language.ini @@ -780,7 +780,7 @@ 13118=鍏ㄩ�� 13119=娣诲姞鍒� 13120=璇ユ埧闂存槸鍒嗕韩杩囨潵鐨勶紝涓嶅厑璁歌繘琛岃鎿嶄綔 -13121=杩樻病閫夋嫨鎴块棿锛岃鍏堥�夋嫨 +13121=杩樻病閫夋嫨鍖哄煙锛岃鍏堥�夋嫨 13122=涓轰綘鐨勫姩浣滃垱寤烘椂闂撮棿闅� 13123=鍚� 13124=鍒犻櫎 @@ -1829,6 +1829,7 @@ 16070=灞忓箷浜害绾у埆 16071=绾� 16072=鑳屽厜鐏寒搴� +16073=鎵撳紑 ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄帴鍙g殑杩斿洖淇℃伅缈昏瘧,浠�18000寮�濮嬧槄鈽呪槄鈽� 18004=鎸囧畾缃戝叧宸茬粡琚粦瀹� @@ -1947,6 +1948,8 @@ 30031=鏂规偊8鎸夐敭杞昏Е寮忛潰鏉� 30032=鏂规偊鏂伴闈㈡澘 30033=鏂规偊鐜闈㈡澘 +30034=绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 +30035=绠�绾�2璺獥甯橀潰鏉� ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄澶囨墍灞炵绫荤殑缈昏瘧鍚嶅瓧,浠�40000寮�濮嬧槄鈽呪槄鈽� 40000=閬槼 diff --git a/ZigbeeApp/Home.Ios/Home.IOS.csproj b/ZigbeeApp/Home.Ios/Home.IOS.csproj index 4e00982..086f6ee 100644 --- a/ZigbeeApp/Home.Ios/Home.IOS.csproj +++ b/ZigbeeApp/Home.Ios/Home.IOS.csproj @@ -30,10 +30,12 @@ <DebugType>none</DebugType> <Optimize>true</Optimize> <OutputPath>bin\iPhoneSimulator\Release</OutputPath> + <DefineConstants>__IOS__;__MOBILE__;__UNIFIED__;iOS</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MtouchLink>None</MtouchLink> <MtouchArch>x86_64</MtouchArch> + <CodesignKey>iPhone Developer</CodesignKey> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> <DebugSymbols>true</DebugSymbols> diff --git a/ZigbeeApp/Home.Ios/Resources/Language.ini b/ZigbeeApp/Home.Ios/Resources/Language.ini index 97c3bb2..e2755c4 100755 --- a/ZigbeeApp/Home.Ios/Resources/Language.ini +++ b/ZigbeeApp/Home.Ios/Resources/Language.ini @@ -780,7 +780,7 @@ 13118=鍏ㄩ�� 13119=娣诲姞鍒� 13120=璇ユ埧闂存槸鍒嗕韩杩囨潵鐨勶紝涓嶅厑璁歌繘琛岃鎿嶄綔 -13121=杩樻病閫夋嫨鎴块棿锛岃鍏堥�夋嫨 +13121=杩樻病閫夋嫨鍖哄煙锛岃鍏堥�夋嫨 13122=涓轰綘鐨勫姩浣滃垱寤烘椂闂撮棿闅� 13123=鍚� 13124=鍒犻櫎 @@ -1829,6 +1829,7 @@ 16070=灞忓箷浜害绾у埆 16071=绾� 16072=鑳屽厜鐏寒搴� +16073=鎵撳紑 ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄帴鍙g殑杩斿洖淇℃伅缈昏瘧,浠�18000寮�濮嬧槄鈽呪槄鈽� 18004=鎸囧畾缃戝叧宸茬粡琚粦瀹� @@ -1947,6 +1948,8 @@ 30031=鏂规偊8鎸夐敭杞昏Е寮忛潰鏉� 30032=鏂规偊鏂伴闈㈡澘 30033=鏂规偊鐜闈㈡澘 +30034=绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 +30035=绠�绾�2璺獥甯橀潰鏉� ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄澶囨墍灞炵绫荤殑缈昏瘧鍚嶅瓧,浠�40000寮�濮嬧槄鈽呪槄鈽� 40000=閬槼 diff --git a/ZigbeeApp/Shared/Common/CommonPage.cs b/ZigbeeApp/Shared/Common/CommonPage.cs index 20b0d5a..30fd745 100755 --- a/ZigbeeApp/Shared/Common/CommonPage.cs +++ b/ZigbeeApp/Shared/Common/CommonPage.cs @@ -62,7 +62,7 @@ /// <summary> /// 鐗堟湰鍙� /// </summary> - public static string CodeIDString = "1.0.20011801"; + public static string CodeIDString = "1.0.20030601"; /// <summary> /// 娉ㄥ唽鏉ユ簮(0:HDL On 1:Zigbee) /// </summary> diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 35989ca..e91f2c2 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -45,12 +45,14 @@ { lock (dicAllDevice) { - var list = new List<CommonDevice>(); - foreach (var device in dicAllDevice.Values) + //鍏堣幏鍙栧叏閮ㄧ殑Mac + var listMac = new List<string>(); + foreach (var strMac in this.dicDeviceEpoint.Keys) { - list.Add(device); + listMac.Add(strMac); } - return list; + //鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭) + return this.GetDevicesByMac(listMac); } } } @@ -241,7 +243,16 @@ //鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶� string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); - List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID, true); + List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID); + //鑾峰彇ota璁惧 + foreach (var ota in this.dicOTADevice.Values) + { + if (ota.CurrentGateWayId == gwID) + { + listLocalDevices.Add(ota); + } + } + Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>(); foreach (var device in listLocalDevices) { @@ -555,12 +566,12 @@ /// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param> public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true) { - if (deleteRoom == true && Room.CurrentRoom != null) + if (deleteRoom == true && HdlRoomLogic.Current.CurrentRoom != null) { //浠庢埧闂翠腑鍒犻櫎 - Room.CurrentRoom.DeleteDevice(device); + HdlRoomLogic.Current.DeleteDevice(device); //鍒犻櫎鎴戠殑鍠滅埍鐨勮澶� - Room.CurrentRoom.DeleteLoveDevice(device); + HdlRoomLogic.Current.DeleteLoveDevice(device); } //鍒犻櫎缂撳瓨 @@ -702,36 +713,23 @@ /// <summary> /// 鏍规嵁缃戝叧ID鑾峰彇鎵�鏈夌殑璁惧 /// </summary> - /// <param name="gwId">缃戝叧ID</param> - /// <param name="getOtaDevice">鏄惁鑾峰彇ota璁惧</param> + /// <param name="gwId">缃戝叧ID</param>> /// <returns></returns> - public List<CommonDevice> GetDeviceByGatewayID(string gwId, bool getOtaDevice = false) + public List<CommonDevice> GetDeviceByGatewayID(string gwId) { - List<CommonDevice> list = new List<CommonDevice>(); lock (dicAllDevice) { - //鍚勭綉鍏崇殑鎵�鏈夎澶� + var listMac = new List<string>(); + //鍚勭綉鍏崇殑鎵�鏈夎澶囩殑Mac foreach (CommonDevice device in this.dicAllDevice.Values) { if (gwId == device.CurrentGateWayId) { - list.Add(device); + listMac.Add(device.DeviceAddr); } } - if (getOtaDevice == true) - { - //鑾峰彇ota璁惧 - foreach (var ota in this.dicOTADevice.Values) - { - if (ota.CurrentGateWayId == gwId) - { - list.Add(ota); - } - } - } + return this.GetDevicesByMac(listMac); } - - return list; } /// <summary> @@ -798,6 +796,39 @@ } return -1; }); + return list; + } + + /// <summary> + /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭) + /// </summary> + /// <param name="DeviceAddr">Mac鍦板潃</param> + /// <returns></returns> + public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr) + { + //鍏堟帓搴� + listMacAddr.Sort(); + + var list = new List<CommonDevice>(); + foreach (string strMac in listMacAddr) + { + var listEpoint = new List<int>(); + //鑾峰彇鍏ㄩ儴鐨勭鐐� + foreach (int epoint in this.dicDeviceEpoint[strMac]) + { + listEpoint.Add(epoint); + } + //鐒跺悗鎺掑簭 + listEpoint.Sort(); + foreach (int epoint in listEpoint) + { + var device = this.GetDevice(strMac, epoint); + if (device != null) + { + list.Add(device); + } + } + } return list; } @@ -1266,43 +1297,6 @@ #endregion - #region 鈻� 璁惧UI鐩稿叧_________________________ - - /// <summary> - /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 - /// </summary> - /// <param name="device"></param> - /// <returns></returns> - public DeviceUI GetDeviceUI(CommonDevice device) - { - //鍒涘缓涓�涓柊鐨勪笢瑗跨粰杩囧幓 - var deviceUi = new DeviceUI(); - deviceUi.DeviceAddr = device.DeviceAddr; - deviceUi.DeviceEpoint = device.DeviceEpoint; - return deviceUi; - } - - /// <summary> - /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 - /// </summary> - /// <param name="filePath"></param> - /// <returns></returns> - public DeviceUI GetDeviceUI(string filePath) - { - string[] arry = filePath.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); - if (arry.Length != 4) - { - return null; - } - //鍒涘缓涓�涓柊鐨勪笢瑗跨粰杩囧幓 - var deviceUi = new DeviceUI(); - deviceUi.DeviceAddr = arry[2]; - deviceUi.DeviceEpoint = Convert.ToInt32(arry[3]); - return deviceUi; - } - - #endregion - #region 鈻� 鑾峰彇鑷畾涔夌殑璁惧绫诲瀷_______________ /// <summary> @@ -1329,7 +1323,11 @@ return info; } //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - return this.GetNotHdlMyDeviceEnumInfo(listdevice); + info = this.GetNotHdlMyDeviceEnumInfo(listdevice); + //杩欓噷鍐嶆鍒ゆ柇鏄惁鏄渤涓滆澶�,鏈夊彲鑳藉畠鐨勬ā鍧桰D鍐欓敊浜� + info.IsHdlDevice = this.IsHdlDevice(checkDevice); + + return info; } /// <summary> @@ -1774,7 +1772,7 @@ //鍗曠函鍙槸Ota璁惧鍒欎笉澶勭悊 return; } - Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false); + HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false); } } @@ -1790,7 +1788,7 @@ //鏈垎閰嶅尯鍩� return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } - var room = Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); + var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); if (room != null) { return room.Name; @@ -1810,7 +1808,7 @@ { return null; } - return Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); + return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); } #endregion @@ -1834,7 +1832,7 @@ /// <returns></returns> public string GetDeviceMainKeys(CommonDevice device) { - return device.DeviceAddr + device.DeviceEpoint; + return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint); } /// <summary> @@ -1845,7 +1843,7 @@ /// <returns></returns> public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint) { - return DeviceAddr + DeviceEpoint; + return DeviceAddr + "_" + DeviceEpoint; } /// <summary> @@ -2064,6 +2062,8 @@ statu = 2; } } + + statu = 1; return listDevice; } @@ -2254,9 +2254,10 @@ //********************************************************************* //鏂拌澶囨坊鍔犳柟娉曪細 //1銆佸湪杩欓噷濉啓涓婃ā鍧桰D锛岀劧鍚庢槸 DeviceConcreteType 锛岀劧鍚庢槸 DeviceBeloneType - //2銆佺劧鍚庡湪鏈�涓嬮潰娣诲姞銆愯澶囩殑鍏蜂綋绫诲瀷銆戯紝銆愯澶囩殑鎵�灞炵被鍨嬨�� + //2銆佺劧鍚庡湪鏈�涓嬮潰鐨勩�愯嚜瀹氫箟璁惧绫诲瀷銆戞姌鍙犳爮閲屾坊鍔犮�愯澶囩殑鍏蜂綋绫诲瀷銆戯紝銆愯澶囩殑鎵�灞炵被鍨嬨�� //3銆佷互璁惧鐨勫叿浣撶被鍨嬩负鍚嶅瓧(鍘绘帀銆�-銆�)娣诲姞璁惧鐨勩�愭墍灞炲浘鐗囥�戯紝銆愮湡瀹炵墿鐞嗗浘鐗囥�戙�傚洖璺浘鐗囬渶瑕佺壒娈婂鐞� //4銆佹坊鍔燫鏂囦欢,娣诲姞Language鏂囦欢 + //5銆佸鏋滈渶瑕佸叡鏈夊浘鐗�,鍒欏湪杩欎釜鍑芥暟鐨勬渶搴曚笅娣诲姞 //********************************************************************* //=========鈽呪槄寮�鍚堝笜绫�(100-199)鈽呪槄========= @@ -2272,6 +2273,8 @@ this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//绠�绾�4鎸夐敭闈㈡澘 this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//绠�绾�3鎸夐敭闈㈡澘 this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//绠�绾�2鎸夐敭闈㈡澘 + this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200";//绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 + this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200";//绠�绾�2璺獥甯橀潰鏉� this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200";//鏂规偊2鎸夐敭杞昏Е寮忛潰鏉� this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200";//鏂规偊4鎸夐敭杞昏Е寮忛潰鏉� this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200";//鏂规偊8鎸夐敭杞昏Е寮忛潰鏉� @@ -2326,6 +2329,8 @@ //鉁┾湬鉁┾湬鉁╅渶瑕佸叡鏈夌殑鍥剧墖瀵硅薄鉁┾湬鉁┾湬鉁� + //涓よ�呴兘鏄疍eviceConcreteType + //Keys:鎸囧畾鐨勮澶� value:娌跨敤鐨勫浘鐗囨槸鍝璁惧鐨� this.dicPictrueShard = new Dictionary<string, string>(); this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭闈㈡澘 娌跨敤 4鎸夐敭鐨勫浘鏍� this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//绠�绾�3鎸夐敭闈㈡澘 娌跨敤 3鎸夐敭鐨勫浘鏍� @@ -2402,6 +2407,14 @@ /// </summary> ButtonPanel_SimpleTwo = 222, /// <summary> + /// 绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 闀滃儚id锛�224 + /// </summary> + ButtonPanel_FourButtonScene = 224, + /// <summary> + /// 绠�绾�2璺獥甯橀潰鏉� 闀滃儚id锛�226 + /// </summary> + ButtonPanel_TwoButtonCurtain = 226, + /// <summary> /// 鏂规偊2鎸夐敭杞昏Е寮忛潰鏉� 闀滃儚id锛�240 /// </summary> ButtonPanel_FangyueTwo = 240, diff --git a/ZigbeeApp/Shared/Common/DeviceUI.cs b/ZigbeeApp/Shared/Common/DeviceUI.cs deleted file mode 100755 index 3bf7ba0..0000000 --- a/ZigbeeApp/Shared/Common/DeviceUI.cs +++ /dev/null @@ -1,567 +0,0 @@ -锘縰sing System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using ZigBee.Device; - -namespace Shared.Common -{ - /// <summary> - /// 璁惧锛堝拰UI鐩稿叧锛屽拰device鏈夊尯鍒級 - /// </summary> - [System.Serializable] - public class DeviceUI - { - #region 鈼� 鍙橀噺____________________________ - - /// <summary> - /// 璁惧MAC鍦板潃 - /// </summary> - public string DeviceAddr = string.Empty; - /// <summary> - /// 璁惧绔偣 - /// </summary> - public int DeviceEpoint = 0; - - /// <summary> - /// 璁惧鏂囦欢 - /// </summary> - /// <value>The name of the file.</value> - [Newtonsoft.Json.JsonIgnore] - public string FileName - { - get - { - var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); - if (myDevice != null) - { - return myDevice.FilePath; - } - return $"Device_Unkwon"; - } - } - - - [Newtonsoft.Json.JsonIgnore] - public ZigBee.Device.CommonDevice CommonDevice - { - get - { - return Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); - } - } - - /// <summary> - /// 鏄惁鏄嚜瀹氫箟鍥剧墖 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public bool IsCustomizeImage - { - get - { - var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); - if (myDevice != null) - { - return myDevice.IsCustomizeImage; - } - return false; - } - } - /// <summary> - /// 璁惧鍥剧墖 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public string IconPath - { - get - { - var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); - if (myDevice != null) - { - return myDevice.IconPath; - } - return string.Empty; - } - } - /// <summary> - /// 璁惧鍥剧墖--鍦ㄧ嚎鎴栬�呴�変腑鐘舵�� - /// </summary> - /// <value>The online icon path.</value> - [Newtonsoft.Json.JsonIgnore] - public string OnlineIconPath - { - get - { - var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); - if (myDevice != null) - { - return myDevice.OnlineIconPath; - } - return string.Empty; - } - } - - /// <summary> - /// 鎺у埗寤舵椂榛樿鍙嶉鐨勭嚎绋嬪垪琛� - /// </summary> - public static List<System.Threading.Thread> threads = new List<System.Threading.Thread> { }; - - #endregion - - #region 鈼� 鍙戦�佹帶鍒跺懡浠ゅ欢鏃跺弽棣坃_____________ - - /// <summary> - /// 鍙戦�佹帶鍒跺懡浠ゅ欢鏃跺弽棣� - /// </summary> - /// <param name="commonDevice">Common device.</param> - /// <param name="action">Action.</param> - /// <param name="delayTime">Delay time.</param> - public static void SendCommandDelayAction(CommonDevice commonDevice, Action action, int delayTime = 3) - { - var threadName = commonDevice.GetHashCode().ToString(); - if (threads.Find((obj) => obj.Name == threadName) == null) - { - var thread = new System.Threading.Thread(() => - { - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalSeconds < delayTime) - { - System.Threading.Thread.Sleep(100); - } - lock (threads) - { - threads.RemoveAll((obj) => obj.Name == threadName); - } - action?.Invoke(); - }) - { IsBackground = true, Name = threadName }; - lock (threads) - { - threads.Add(thread); - } - thread.Start(); - } - } - - #endregion - - #region 鈼� 鏄剧ず鎺у埗璁惧鏄惁鎴愬姛鐨勬彁绀篲________ - - /// <summary> - /// 鏄剧ず鎺у埗璁惧鏄惁鎴愬姛鐨勬彁绀� - /// </summary> - /// <param name="r">The red component.</param> - public static void ShowStatuTip(int r) - { - Application.RunOnMainThread(() => - { - string msg = Language.StringByID(r); - var tip = new Phone.UserCenter.ShowMsgControl(Phone.UserCenter.ShowMsgType.Tip, msg); - tip.Show(); - }); - } - - #endregion - - #region 鈼� 鑾峰彇璁惧绫诲瀷鍥剧墖__________________ - - /// <summary> - /// 閫氳繃璁惧绫诲瀷鑾峰彇閫氱敤鐨勮澶囩被鍨嬪浘鐗� - /// </summary> - /// <returns>The device type un selected image path.</returns> - /// <param name="deviceType">Device type.</param> - public static string GetDeviceTypeUnSelectedImagePath(ZigBee.Device.DeviceType deviceType) - { - string ImagePath; - //绐楀笜 - switch (deviceType) - { - case DeviceType.OnOffSwitch: - //鎺у埗闈㈡澘 - ImagePath = "Device/DryContact.png"; - break; - case DeviceType.OnOffOutput: - //缁х數鍣� - ImagePath = "Device/Relay.png"; - break; - case DeviceType.DimmableLight: - //璋冨厜鐏� - ImagePath = "Device/DimmableLight.png"; - break; - case DeviceType.WindowCoveringDevice: - //绐楀笜 - ImagePath = "Device/Curtain.png"; - break; - case DeviceType.Thermostat: - //绌鸿皟 - ImagePath = "Device/AirConditioner.png"; - break; - case DeviceType.IASZone: - //浼犳劅鍣� - ImagePath = "Device/Sensor.png"; - break; - case DeviceType.AirSwitch: - //绌烘皵寮�鍏� - ImagePath = "Device/AirSwitch.png"; - break; - case DeviceType.Repeater: - //涓户鍣� - ImagePath = "Device/AirSwitch.png"; - break; - case DeviceType.TemperatureSensor: - //娓╂箍搴︿紶鎰熷櫒 - ImagePath = "Device/Sensor.png"; - break; - default: - ImagePath = "Device/Relay.png"; - break; - } - return ImagePath; - } - - /// <summary> - /// 閫氳繃璁惧绫诲瀷鑾峰彇閫氱敤鐨勯�変腑鐘舵�佺殑璁惧绫诲瀷鍥剧墖 - /// </summary> - /// <returns>The device type un selected image path.</returns> - /// <param name="deviceType">Device type.</param> - public static string GetDeviceTypeSelectedImagePath(ZigBee.Device.DeviceType deviceType) - { - string ImagePath; - switch (deviceType) - { - case DeviceType.OnOffSwitch: - //鎺у埗闈㈡澘 - ImagePath = "Device/DryContactSelected.png"; - break; - case DeviceType.OnOffOutput: - //缁х數鍣� - ImagePath = "Device/RelaySelected.png"; - break; - case DeviceType.DimmableLight: - //璋冨厜鐏� - ImagePath = "Device/DimmableLightSelected.png"; - break; - case DeviceType.WindowCoveringDevice: - //绐楀笜 - ImagePath = "Device/CurtainSelected.png"; - break; - case DeviceType.Thermostat: - //绌鸿皟 - ImagePath = "Device/AirConditionerSelected.png"; - break; - case DeviceType.IASZone: - //浼犳劅鍣� - ImagePath = "Device/SensorSelected.png"; - break; - case DeviceType.AirSwitch: - //绌烘皵寮�鍏� - ImagePath = "Device/AirSwitchSelected.png"; - break; - case DeviceType.Repeater: - //涓户鍣�--杩樻病鍥剧墖 - ImagePath = "Device/AirSwitchSelected.png"; - break; - default: - ImagePath = "Device/RelaySelected.png"; - break; - } - return ImagePath; - } - #endregion - - #region 鈼� 鑾峰彇璁惧绫诲瀷鍚嶇О__________________ - - public static string GetDeviceTypeName(ZigBee.Device.DeviceType deviceType) - { - int deviceTypeR; - switch (deviceType) - { - case DeviceType.OnOffSwitch: - //鎺у埗闈㈡澘 - deviceTypeR = R.MyInternationalizationString.OnOffSwitch; - break; - case DeviceType.OnOffOutput: - //缁х數鍣�--鐏� - deviceTypeR = R.MyInternationalizationString.OnOffOutput; - break; - case DeviceType.DimmableLight: - //璋冨厜鐏� - deviceTypeR = R.MyInternationalizationString.DimmableLight; - break; - case DeviceType.WindowCoveringDevice: - //绐楀笜 - deviceTypeR = R.MyInternationalizationString.WindowCoveringDevice; - break; - case DeviceType.Thermostat: - //绌鸿皟 - deviceTypeR = R.MyInternationalizationString.Thermostat; - break; - case DeviceType.IASZone: - //浼犳劅鍣� - deviceTypeR = R.MyInternationalizationString.IASZone; - break; - case DeviceType.AirSwitch: - //绌烘皵寮�鍏� - deviceTypeR = R.MyInternationalizationString.AirSwitch; - break; - case DeviceType.Repeater: - //涓户鍣� - deviceTypeR = R.MyInternationalizationString.Repeater; - break; - case DeviceType.DoorLock: - //闂ㄩ攣 - deviceTypeR = R.MyInternationalizationString.DoorLock; - break; - - case DeviceType.TemperatureSensor: - //娓╁害浼犳劅鍣� - deviceTypeR = R.MyInternationalizationString.TemperatureAndHumiditySensor; - break; - default: - deviceTypeR = R.MyInternationalizationString.UnknowDevice; - break; - } - return Language.StringByID(deviceTypeR); - } - - #endregion - - #region 鈼� 閫氳繃id鑾峰彇璁惧鍖哄煙_____________ - - /// <summary> - /// GetZone - /// </summary> - /// <returns></returns> - public string GetZone() - { - var room = Room.CurrentRoom.GetRoomByDevice(CommonDevice); - if (room == null) - { - return Language.StringByID(R.MyInternationalizationString.UnallocatedArea); - } - if(string.IsNullOrEmpty(room.FloorId)) - { - return room.Name; - } - var floorName = Config.Instance.Home.GetFloorNameById(room.FloorId); - if (floorName == null) - { - return room.Name; - } - return $"{floorName},{room.Name}"; - } - - #endregion - - /// <summary> - /// GetDeviceStatu - /// </summary> - /// <returns></returns> - public string GetDeviceStatu() - { - var device = CommonDevice; - if (device.Type == DeviceType.OnOffOutput) - { - if ((device as ToggleLight).OnOffStatus == 1) - { - return Language.StringByID(R.MyInternationalizationString.Open); - } - return Language.StringByID(R.MyInternationalizationString.Shut); - } - else if (device.Type == DeviceType.AirSwitch) - { - if ((device as ZigBee.Device.AirSwitch).OnOffStatus == 1) - { - return Language.StringByID(R.MyInternationalizationString.Open); - } - return Language.StringByID(R.MyInternationalizationString.Shut); - } - else if (device.Type == DeviceType.DimmableLight) - { - if ((device as DimmableLight).OnOffStatus == 0 || (device as DimmableLight).Level == 0) - { - return Language.StringByID(R.MyInternationalizationString.Shut); - } - return $"{(int)((device as DimmableLight).Level * 1.0 / 254 * 100)}%"; - } - else if (device.Type == DeviceType.WindowCoveringDevice) - { - if ((device as Rollershade).WcdCurrentPositionLiftPercentage == 0) - { - return Language.StringByID(R.MyInternationalizationString.Shut); - } - return $"{(device as Rollershade).WcdCurrentPositionLiftPercentage}%"; - } - else if (device.Type == DeviceType.Thermostat) - { - //娓╁害锛屾ā寮忥紝椋庨�� - string tempareture = string.Empty; - string model = string.Empty; - string wind = string.Empty; - - var ac = CommonDevice as AC; - - if (ac.currentSystemMode == 0) - { - return Language.StringByID(R.MyInternationalizationString.Shut); - } - else if (ac.currentSystemMode == 1) - { - model = Language.StringByID(R.MyInternationalizationString.Mode_Auto); - tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; - } - else if (ac.currentSystemMode == 3) - { - model = Language.StringByID(R.MyInternationalizationString.Mode_Cool); - tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; - } - else if (ac.currentSystemMode == 4) - { - model = Language.StringByID(R.MyInternationalizationString.Mode_Heat); - tempareture = $"{ac.currentHeatingSetpoint} 鈩�"; - } - else if (ac.currentSystemMode == 7) - { - model = Language.StringByID(R.MyInternationalizationString.Mode_FanOnly); - } - else if (ac.currentSystemMode == 8) - { - model = Language.StringByID(R.MyInternationalizationString.Mode_Dry); - tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; - } - - if (ac.currentFanMode == 1) - { - wind = Language.StringByID(R.MyInternationalizationString.Fan_Low); - } - else if (ac.currentFanMode == 2) - { - wind = Language.StringByID(R.MyInternationalizationString.Fan_Middle); - } - else - { - wind = Language.StringByID(R.MyInternationalizationString.Fan_Height); - } - - if (string.IsNullOrEmpty(tempareture)) - { - return $"{model},{wind}"; - } - return $"{model},{wind},{tempareture}"; - } - else if (device.Type == DeviceType.IASZone) - { - var ias = CommonDevice as IASZone; - //鍖哄垎浼犳劅鍣ㄥ叿浣撶被鍨� - var info = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { device }); - if (info.ConcreteType == DeviceConcreteType.Sensor_Infrared) - { - //绾㈠ - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HavePerson); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_NoPerson); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_Water) - { - //姘存蹈 - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HaveWater); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_DoorWindow) - { - //闂ㄧ獥 - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Open); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Close); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_CarbonMonoxide) - { - //鐕冩皵 - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_Fire) - { - //鐑熼浘 - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_Pir) - { - //pir - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_Keyfob) - { - //閽ュ寵鎵� - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_Motion) - { - //杩愬姩浼犳劅鍣� - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); - } - else if (info.ConcreteType == DeviceConcreteType.Sensor_EmergencyButton) - { - //绱ф�ユ寜閽� - if (ias.iASInfo?.Alarm1 == 1) - { - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); - } - return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); - } - return null; - } - else if (device.Type == DeviceType.TemperatureSensor) - { - var tempera = CommonDevice as TemperatureSensor; - if(tempera.SensorDiv==1) - { - if (tempera.Temperatrue == 0) - { - return "--鈩�"; - } - return $"{tempera.Temperatrue}鈩�"; - } - else if(tempera.SensorDiv==2) - { - if (tempera.Humidity == 0) - { - return "--%"; - } - return $"{tempera.Humidity}%"; - } - return null; - } - else - { - return null; - } - } - } -} diff --git a/ZigbeeApp/Shared/Common/House.cs b/ZigbeeApp/Shared/Common/House.cs index d734fa2..7da0b22 100755 --- a/ZigbeeApp/Shared/Common/House.cs +++ b/ZigbeeApp/Shared/Common/House.cs @@ -57,9 +57,9 @@ public double Latitude = 0; /// <summary> - /// 鎴块棿璺緞鍒楄〃 + /// 鎴块棿鍒楄〃(鎴块棿鐨処D) /// </summary> - public List<string> RoomFilePathList = new List<string> { }; + public List<string> ListRooms = new List<string>(); /// <summary> /// 妤煎眰瀛楀吀 @@ -443,10 +443,11 @@ } return null; } + /// <summary> - /// InitFloor + /// 璁剧疆褰撳墠妤煎眰鐨処D /// </summary> - public void InitFloor() + public void SetCurrentFloorId() { if (Config.Instance.Home.FloorDics.Count > 0 && string.IsNullOrEmpty(CurrentFloorId)) { @@ -466,19 +467,17 @@ #region 鈼� 娣诲姞鎴块棿璺緞_________________________ /// <summary> - /// 娣诲姞銆愭埧闂磋矾寰勩�戝埌鎴块棿璺緞鍒楄〃 + /// 娣诲姞鎴块棿ID /// </summary> /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns> /// <param name="roomFilePath">Room file path.</param> - public bool AddRoomListFilePath(string roomFilePath) + public void AddRoomId(string roomId) { - if (RoomFilePathList.Contains(roomFilePath)) - { - return false; + if (ListRooms.Contains(roomId) == false) + { + ListRooms.Add(roomId); + this.Save(); } - RoomFilePathList.Add(roomFilePath); - Save(); - return true; } #endregion @@ -486,19 +485,17 @@ #region 鈼� 鍒犻櫎鎴块棿璺緞_________________________ /// <summary> - /// 绉婚櫎鎴块棿璺緞 + /// 绉婚櫎鎴块棿Id /// </summary> /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns> /// <param name="roomFilePath">Room file path.</param> - public bool RemoveRoomListFilePath(string roomFilePath) + public void RemoveRoomId(string roomId) { - if (!RoomFilePathList.Contains(roomFilePath)) - { - return false; + if (ListRooms.Contains(roomId)==true) + { + ListRooms.Remove(roomId); + Save(); } - RoomFilePathList.Remove(roomFilePath); - Save(); - return true; } #endregion diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs index 02204db..c17db61 100755 --- a/ZigbeeApp/Shared/Common/Room.cs +++ b/ZigbeeApp/Shared/Common/Room.cs @@ -12,61 +12,48 @@ /// </summary> [System.Serializable] public class Room - { - #region 鈼� 鍙橀噺____________________________ + { + #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> - /// 鎴块棿鏂囦欢 + /// 鏄惁鏄枩鐖辨埧闂� /// </summary> - /// <value>The name of the file.</value> [Newtonsoft.Json.JsonIgnore] - public string FileName + public bool IsLove { get { - return $"Room_{Id}.json"; + return Id == "Favorite"; } + } + /// <summary> + /// 鎴块棿鏂囦欢 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public string FileName + { + get + { + return $"Room_{Id}.json"; + } } + /// <summary> /// 鎴块棿id--浣跨敤guid - /// Guid.NewGuid().ToString() /// </summary> public string Id = Guid.NewGuid().ToString(); - /// <summary> - /// 妤煎眰Id - /// 鏂板鏃朵娇鐢℅uid - /// </summary> - public string FloorId = string.Empty; - /// <summary> - /// 妤煎眰鍚嶇О - /// </summary> - public string FloorName - { - get - { - return Config.Instance.Home.GetFloorNameById(FloorId); - } - } /// <summary> /// 鎴块棿鍚� /// </summary> public string Name = string.Empty; - /// <summary> /// 鎴块棿鑳屾櫙鍥� /// </summary> public string BackgroundImage = string.Empty; - /// <summary> /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 /// </summary> public int BackgroundImageType = 0; - - /// <summary> - /// 妤煎眰--澶囩敤 - /// </summary> - public Dictionary<string, string> FloorList = new Dictionary<string, string> { }; - /// <summary> /// 娓╁害浼犳劅鍣�(璁惧涓婚敭) /// </summary> @@ -82,1673 +69,44 @@ /// <summary> /// 婀垮害 /// </summary> - public decimal Humidity; - - /// <summary> - /// 褰撳墠閫夋嫨鐨勬埧闂� - /// </summary> - private static Room m_CurrentRoom = null; - /// <summary> - /// 褰撳墠閫夋嫨鐨勬埧闂� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public static Room CurrentRoom - { - get - { - if (m_CurrentRoom == null && Lists.Count > 0) - { - if (m_CurrentRoom == null) { m_CurrentRoom = Lists[0]; } - return Lists[0]; - } - return m_CurrentRoom; - } - set { m_CurrentRoom = value; } - } - - /// <summary> - /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<DeviceUI> DeviceUIList = new List<DeviceUI> { }; - /// <summary> - ///璁惧鏂囦欢璺緞鍒楄〃 - /// </summary> - public readonly List<string> DeviceUIFilePathList = new List<string>(); - - /// <summary> - /// 鍠滅埍鎴块棿id - /// </summary> - public const string LoveRoomId= "Favorite"; - - /// <summary> - /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂� - /// </summary> - /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value> - [Newtonsoft.Json.JsonIgnore] - public bool IsLove - { - get - { - return Id == LoveRoomId; - } - } - + public decimal Humidity; /// <summary> /// 鏄惁鏄垎浜繃鏉ョ殑鎴块棿 /// 娉細鍒嗕韩杩囨潵鐨勬埧闂翠笉鑳藉垹闄わ紝涓嶈兘缂栬緫璇ユ埧闂达紝涓嶈兘瀵硅澶囷紙鍔熻兘锛夈�佸満鏅繘琛屽鍒犳敼 /// </summary> - public bool IsSharedRoom = false; - + public bool IsSharedRoom = false; /// <summary> - /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰� + /// 妤煎眰Id /// </summary> - /// <value>The love room device list.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<string> LoveRoomDeviceUIFilePathList - { - get - { - if (Lists.Count == 0) - { - return new List<string> { }; - } - return CurrentRoom.GetLoveRoom().DeviceUIFilePathList; - } - } - - /// <summary> - /// 鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� - /// </summary> - /// <value>All room device type list.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<DeviceType> AllRoomDeviceTypeList - { - get - { - var typeList = new List<DeviceType> { }; - foreach (var deviceUI in AllRoomDeviceUIList) - { - if (deviceUI == null || deviceUI.CommonDevice == null) - { - continue; - } - if (!typeList.Contains(deviceUI.CommonDevice.Type)) - { - typeList.Add(deviceUI.CommonDevice.Type); - } - } - return typeList; - } - } - - /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� - /// </summary> - /// <value>All room scene UIL ist.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<SceneUI> AllRoomSceneUIList - { - get - { - var sceneList = new List<SceneUI> { }; - foreach (var r in Shared.Common.Room.Lists) - { - if(r.IsLove) - { - continue; - } - if (r.SceneUIList.Count == 0) - { - continue; - } - foreach (var sceneUI in r.SceneUIList) - { - if (sceneUI == null) - { - continue; - } - sceneList.Add(sceneUI); - } - } - return sceneList; - } - } - - /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅矾寰� - /// </summary> - /// <value>All room scene UIL ist.</value> - [Newtonsoft.Json.JsonIgnore] - public List<string> AllRoomSceneUIFilepathList - { - get - { - var pathList = new List<string> { }; - foreach (var r in Lists) - { - if(r.IsLove) - { - continue; - } - - if (r.SceneUIFilePathList.Count == 0) - { - continue; - } - foreach (var path in r.SceneUIFilePathList) - { - pathList.Add(path); - } - } - return pathList; - } - } - - /// <summary> - /// 鍦烘櫙鍒楄〃---涓嶅啀搴忓垪鍖� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<SceneUI> SceneUIList = new List<SceneUI> { }; - /// <summary> - ///鍦烘櫙鏂囦欢鍒楄〃 - /// </summary> - public readonly List<string> SceneUIFilePathList = new List<string>(); - - /// <summary> - /// 鎵�鏈夌殑鎴块棿淇℃伅 - /// </summary> - public static List<Room> Lists = new List<Room>(); - - /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶� - /// </summary> - /// <value>All room device UIL ist.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<DeviceUI> AllRoomDeviceUIList - { - get - { - List<DeviceUI> deviceList = new List<DeviceUI>(); - for (int i = 0; i < Lists.Count; i++) - { - var room = Lists[i]; - if (room.IsSharedRoom || room.IsLove) - { - continue; - } - if (room.DeviceUIList.Count == 0) - { - continue; - } - for (int j = 0; j < room.DeviceUIList.Count; j++) - { - var device = room.DeviceUIList[j]; - if (device == null || device.CommonDevice == null) - { - continue; - } - if (deviceList.Find((obj) => obj.FileName == device.FileName) == null) - { - deviceList.Add(device); - } - } - } - return deviceList; - } - } - - #endregion - - #region 鈼� 鏋勯�犳柟娉昣_______________________ - - /// <summary> - /// 鏋勯�犳柟娉� - /// </summary> - static Room() - { - InitAllRoom(); - } - - #endregion - - #region 鈼� 鍒濆鍖朹_________________________ - - /// <summary> - /// 鍒濆鍖栨埧闂翠俊鎭� - /// 浠庢枃浠朵腑鍏ㄩ儴璇诲彇鎵�鏈夌殑鎴块棿鏁版嵁鍒板唴瀛� - /// </summary> - public static void InitAllRoom() - { - Lists.Clear(); - if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false) - { - //榛樿娣诲姞鍠滅埍鐨勬埧闂�--绂佹淇敼鎴块棿鍚� - var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.JPG", Id = LoveRoomId }; - love.Save(false); - //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃 - var currentHome = Config.Instance.Home; - currentHome.RoomFilePathList.Insert(0, love.FileName); - currentHome.Save(false); - } - foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) - { - var room = GetRoomByFilePath(roomFilePath); - - if (null != room) - { - if (room.IsSharedRoom) - { - room.Name = $"{room.Name}"; - } - Lists.Add(room); - - } - } - - Config.Instance.Home.InitFloor(); - - CurrentRoom.RefreshRoomListView(); - } - - /// <summary> - /// 鍒锋柊鎴块棿瑙嗗浘鍒楄〃 - /// </summary> - public void RefreshRoomListView() - { - Application.RunOnMainThread(() => - { - Phone.Device.Room.RoomManagement.Instance.Show(); - }); - } - - /// <summary> - /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 - /// </summary> - public static void RefreshAllRoomByLocation() - { - var homeTemp = Config.Instance.Home; - homeTemp.RoomFilePathList.Clear(); - - var listFile = Global.FileListByHomeId(); - - //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� - string fRoom = "Room_Favorite.json"; - if (listFile.Contains(fRoom) == true) - { - listFile.Remove(fRoom); - homeTemp.RoomFilePathList.Add(fRoom); - } - - var listRoomFile = new List<string>(); - foreach (string fileName in listFile) - { - if (fileName.StartsWith("Room_")) - { - homeTemp.RoomFilePathList.Add(fileName); - listRoomFile.Add(fileName); - } - } - //妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬� - CheckFloorData(listRoomFile); - - homeTemp.Save(false); - InitAllRoom(); - } - - /// <summary> - /// 妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬� - /// </summary> - /// <param name="listRoomFile"></param> - private static void CheckFloorData(List<string> listRoomFile) - { - for (int i = 0; i < listRoomFile.Count; i++) - { - try - { - var byteData = Global.ReadFileByHomeId(listRoomFile[i]); - string valueData = System.Text.Encoding.UTF8.GetString(byteData); - var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData); - - //妫�娴嬪涓墜鏈烘潵鍥炲垱寤�,鐒跺悗鍙堝垹闄や箣鍚�,妤煎眰鏁版嵁涓嶈兘淇濊瘉100%鍚屾鐨勯棶棰� - if (roomTemp.FloorId != string.Empty && Config.Instance.Home.FloorDics.ContainsKey(roomTemp.FloorId) == false) - { - //鏈煡妤煎眰 - Config.Instance.Home.FloorDics[roomTemp.FloorId] = Language.StringByID(R.MyInternationalizationString.uUnKnownFloor); - } - } - catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } - } - } - - #endregion - - #region 鈼� 娣诲姞鎴块棿_________________________ - - /// <summary> - /// 澧炲姞鎴块棿 - /// </summary> - /// <returns><c>true</c>, if room was added, <c>false</c> otherwise.</returns> - /// <param name="room">Room.</param> - public bool AddRoom(Room room) - { - if (string.IsNullOrEmpty(room.FileName) || Global.IsExistsByHomeId(room.FileName)) - { - return false; - } - if (Config.Instance.Home.RoomFilePathList.Contains(room.FileName)) - { - return false; - } - Lists.Add(room); - var r = Config.Instance.Home.AddRoomListFilePath(room.FileName); - if (r == false) - { - return false; - } - Save(); - HdlAutoBackupLogic.AddOrEditorFile(room.FileName); - CurrentRoom.RefreshRoomListView(); - return true; - } - - #endregion - - #region 鈼� 鍒犻櫎鎴块棿_________________________ - - /// <summary> - /// 鍒犻櫎鎴块棿 - /// </summary> - public bool Remove(string roomFilePath) - { - var room = GetRoomByFilePath(roomFilePath); - if (null == room) - { - return false; - } - //鍒犻櫎鏉ヨ嚜鎷嶇収鎴栬�呯郴缁熷浘搴撶殑鎴块棿鑳屾櫙鍥剧墖 - if (room.BackgroundImageType == 1 || room.BackgroundImageType == 2) - { - //鍒犻櫎鎺夊師鏉ョ殑鑷畾涔夊浘鐗� - if (Global.IsExistsByHomeId(room.BackgroundImage) == true) - { - Global.DeleteFilebyHomeId(room.BackgroundImage); - //鍒犻櫎澶囦唤 - HdlAutoBackupLogic.DeleteFile(room.BackgroundImage); - } - } - //鎴戠殑鍠滅埍 - var loveRoom = this.GetLoveRoom(); - if (loveRoom != null) - { - //绉婚櫎鎴戠殑鍠滅埍閲岄潰鐨勮澶� - for (int i = 0; i < room.DeviceUIFilePathList.Count; i++) - { - loveRoom.DeviceUIFilePathList.Remove(room.DeviceUIFilePathList[i]); - loveRoom.DeviceUIList.RemoveAll((obj) => { return room.DeviceUIFilePathList[i] == obj.FileName; }); - } - //绉婚櫎鎴戠殑鍠滅埍閲岄潰鐨勫満鏅� - for (int i = 0; i < room.SceneUIFilePathList.Count; i++) - { - loveRoom.SceneUIFilePathList.Remove(room.SceneUIFilePathList[i]); - loveRoom.SceneUIList.RemoveAll((obj) => { return room.SceneUIFilePathList[i] == obj.FileName; }); - } - loveRoom.Save(false); - } - - if (Global.IsExistsByHomeId(roomFilePath) == false) - { - return false; - } - Config.Instance.Home.RemoveRoomListFilePath(roomFilePath); - //鍒犻櫎鏂囦欢 - Global.DeleteFilebyHomeId(roomFilePath); - Lists.Remove(room); - HdlAutoBackupLogic.DeleteFile(roomFilePath); - - CurrentRoom.RefreshRoomListView(); - - return true; - } - - #endregion - - #region 鈼� 鑾峰彇鎴块棿________________________ - - /// <summary> - /// 鑾峰彇鍠滅埍鎴块棿 - /// </summary> - /// <returns></returns> - public Room GetLoveRoom() - { - return CurrentRoom.GetRoomById(LoveRoomId); - } - - /// <summary> - /// 閫氳繃璺緞鑾峰彇鎴块棿 - /// </summary> - /// <returns>The room by file path.</returns> - /// <param name="roomFilePath">Room file path.</param> - public static Room GetRoomByFilePath(string roomFilePath) - { - try - { - var roomFile = Global.ReadFileByHomeId(roomFilePath); - var nowRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(System.Text.Encoding.UTF8.GetString(roomFile)); - - if (null == nowRoom) - { - System.Console.WriteLine("鎴块棿鏂囦欢璺緞涓嶅锛屾枃浠惰矾寰勪负锛�" + roomFilePath); - return null; - } - - var beforeRoom = Lists.Find((obj) => obj.Id == nowRoom.Id); - if (beforeRoom != null) - { - var tempDeviceUIList = new List<DeviceUI>(); - tempDeviceUIList.AddRange(beforeRoom.DeviceUIList); - var tempSceneUIList = new List<SceneUI>(); - tempSceneUIList.AddRange(beforeRoom.SceneUIList); - //璁惧锛坉eviceUI锛� - beforeRoom.DeviceUIList.Clear(); - foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) - { - beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); - } - //鍦烘櫙(SceneUI) - beforeRoom.SceneUIList.Clear(); - foreach (var sceneFilePath in beforeRoom.SceneUIFilePathList) - { - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneFilePath)); - var tempSceneUI = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); - if (tempSceneUI != null) - { - var scene = tempSceneUIList.Find((obj) => obj.FileName == tempSceneUI.FileName); - if (scene != null) - { - beforeRoom.SceneUIList.Add(scene); - } - else - { - beforeRoom.AddScene(scene); - } - } - } - - return beforeRoom; - } - - //璁惧锛坉eviceUI锛� - nowRoom.DeviceUIList.Clear(); - foreach (var deviceFilePath in nowRoom.DeviceUIFilePathList) - { - var tempCommon = LocalDevice.Current.GetDeviceUI(deviceFilePath); - if (tempCommon == null || tempCommon.CommonDevice == null) - { - continue; - } - nowRoom.DeviceUIList.Add(tempCommon); - } - //鍦烘櫙(SceneUI) - nowRoom.SceneUIList.Clear(); - foreach (var sceneUIFilePath in nowRoom.SceneUIFilePathList) - { - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneUIFilePath)); - var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); - if (tempScene == null) - { - continue; - } - nowRoom.SceneUIList.Add(tempScene); - } - return nowRoom; - } - catch(Exception ex) - { - return null; - } - } - - /// <summary> - /// 鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞� - /// </summary> - /// <returns>The room by name.</returns> - /// <param name="roomId">鎴块棿ID</param> - public Room GetRoomById(string roomId) - { - if (string.IsNullOrEmpty(roomId)) - { - return null; - } - return Lists.Find((obj) => obj.Id == roomId); - } - - /// <summary> - /// 鏍规嵁鎴块棿鍚嶅瓧锛岃幏鍙栨埧闂村璞� - /// </summary> - /// <returns>The room by name.</returns> - /// <param name="roomName">鎴块棿鍚�</param> - public Room GetRoomByName(string roomName) - { - return Lists.Find((obj) => obj.Name == roomName); - } - - /// <summary> - /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(妤煎眰+鎴块棿鍚�) - /// </summary> - /// <returns>鎴块棿鍚�</returns> - /// <param name="device">璁惧瀵硅薄</param> - public string GetRoomNameByDevice(CommonDevice device) - { - var room = this.GetRoomByDevice(device); - if (room == null) - { - //鏈垎閰嶅尯鍩� - return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); - } - if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) - { - //(妤煎眰+鎴块棿鍚�) - return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name; - } - return room.Name; - } - - /// <summary> - /// 鑾峰彇璁惧鎵�鍦ㄧ殑鎴块棿 - /// </summary> - /// <returns>The room by device.</returns> - /// <param name="device">璁惧瀵硅薄</param> - public Room GetRoomByDevice(CommonDevice device) - { - string deviceFile = device.FilePath; - return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceFile)); - } - - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿鍚� - /// </summary> - /// <returns>The room name by scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public string GetRoomNameBySceneId(int sceneId) - { - var room = GetRoomBySceneId(sceneId); - if (room == null) - { - return null; - } - return room.Name; - } - - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿瀵硅薄 - /// </summary> - /// <returns>The room by scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public Room GetRoomBySceneId(int sceneId) - { - foreach (var r in Lists) - { - if(r.IsLove) - { - continue; - } - foreach (var scene in r.SceneUIList) - { - if (scene.Id == sceneId) - { - return r; - } - } - } - return null; - } - - /// <summary> - /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂� - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public List<Room> GetRoomsByFloorId(string id) - { - try - { - if (Lists == null || Lists.Count == 0 || Lists.Count == 1) - { - return null; - } - if (Config.Instance.Home.FloorDics.Count == 0) - { - return Lists; - } - return Lists.FindAll((obj) => obj.FloorId == id); - } - catch(Exception ex) - { - System.Console.WriteLine(ex.Message); - return null; - } - - } - /// <summary> - /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉� - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public List<string> GetRoomNamesByFloorId(string id) - { - List<string> names = new List<string> { }; - foreach (var r in Lists) - { - if (r.FloorId == id) - { - names.Add(r.Name); - } - } - return names; - } - - /// <summary> - /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�) - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id) - { - if (Config.Instance.Home.FloorDics.Count == 0) - { - return Lists; - } - var r= Lists.FindAll((obj) => obj.FloorId == id); - r.Insert(0, GetLoveRoom()); - return r; - } - - /// <summary> - /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�) - /// </summary> - /// <returns></returns> - public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() - { - if(Config.Instance.Home.FloorDics.Count==0) - { - return Lists; - } - var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId); - r.Insert(0, GetLoveRoom()); - return r; - } - - #endregion - - #region 鈼� 鎴块棿鏂规硶________________________ - - /// <summary> - /// 璁惧鐨勬埧闂村彉鏇� - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="roomId">鏂版埧闂碔d</param> - /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> - public void ChangedRoom(CommonDevice device, string roomId, bool saveRealRoom = true) - { - //鎴块棿鏄惁淇敼 - if (this.IsRoomChanged(device, roomId) == false) - { - return; - } - //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧 - this.DeleteDevice(device); - - //娣诲姞鍒版柊鐨勬埧闂� - var room = this.GetRoomById(roomId); - if (room != null) - { - room.AddDevice(device, saveRealRoom); - } - } + public string FloorId = string.Empty; /// <summary> - /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀� + /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃(璁惧鐨勪富閿�:mac鍦板潃_绔彛) /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="roomId">鏂版埧闂碔d</param> - /// <returns></returns> - public bool IsRoomChanged(CommonDevice device, string roomId) - { - var room = this.GetRoomByDevice(device); - if (room == null || room.Id != roomId) - { - return true; - } - return false; - } - + public List<string> ListDevice = new List<string>(); /// <summary> - /// 鑾峰彇鎴块棿鎵�鍦ㄥ尯鍩� - /// 妤煎眰,鎴块棿鍚� + ///鍦烘櫙鍒楄〃(鍦烘櫙鐨処D) /// </summary> - /// <returns></returns> - public string GetZoneName() - { - if (string.IsNullOrEmpty(FloorId)) - { - return Name; - } - var floorName = Config.Instance.Home.GetFloorNameById(FloorId); - if (floorName == null) - { - return Name; - } - return $"{floorName},{Name}"; - } - - #endregion - - #region 鈼� 鏇存柊鎴块棿_________________________ - - /// <summary> - /// Updates the memorry. - /// </summary> - /// <param name="roomFilePath">Room file path.</param> - public static void UpdateMemorry(string roomFilePath) - { - GetRoomByFilePath(roomFilePath); - } - - #endregion - - #region 鈼� 鎴块棿鑳屾櫙鍥剧殑鐩稿叧___________________ - - /// <summary> - /// 绉诲姩鑳屾櫙鍥剧墖鍒颁綇瀹呯洰褰曚笅 - /// </summary> - /// <param name="oldFile">闇�瑕佺Щ鍔ㄧ殑鏂囦欢(鐩存帴鏂囦欢鍚�)</param> - /// <param name="newFile">瑕佺Щ鍔ㄥ埌鐨勪綅缃�-(鍖呭惈浣忓畢璺緞锛氫綇瀹�/鏂囦欢鍚�)</param> - public void MoveBackGroundIamageFileToDirectory(string oldFile, string newFile) - { - try - { - var newPath = System.IO.Path.Combine(Config.Instance.FullPath, newFile); - var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath,oldFile); - Global.MoveFileToDirectory(path, newPath); - //澶囦唤 - Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(oldFile); - //Save(); - } - catch (Exception ex) - { - System.Console.WriteLine("绉诲姩鍥剧墖寮傚父 " + ex.Message); - } - } - - #endregion - - #region 鈼� 娣诲姞璁惧________________________ - - /// <summary> - /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁欍�愭垜鐨勫枩鐖便�戜娇鐢�) - /// </summary> - /// <param name="deviceUIFilePath">Device UIF ile path.</param> - public void AddDevice(string deviceUIFilePath) - { - if (string.IsNullOrEmpty(deviceUIFilePath)) - { - return; - } - var deviceUI = Common.LocalDevice.Current.GetDeviceUI(deviceUIFilePath); - if (null == deviceUI.CommonDevice) - { - //褰撳墠瀵硅薄鏁版嵁鏃犳晥 - return; - } - if (!DeviceUIFilePathList.Contains(deviceUIFilePath) && !DeviceUIList.Contains(deviceUI)) - { - DeviceUIFilePathList.Add(deviceUIFilePath); - DeviceUIList.Add(deviceUI); - } - //淇濆瓨鍒版湰鍦� - Save(); - } - - /// <summary> - /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁橰oom閲岄潰浣跨敤) - /// </summary> - /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> - /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> - public void AddDevice(CommonDevice device, bool saveRealRoom) - { - if (device == null) - { - return; - } - //璁惧淇℃伅淇濆瓨鍒版湰鍦� - device.Save(); - - var deviceUI = Common.LocalDevice.Current.GetDeviceUI(device); - if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false) - { - DeviceUIFilePathList.Add(deviceUI.FileName); - DeviceUIList.Add(deviceUI); - //淇濆瓨鍒版湰鍦� - Save(); - - if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) - { - //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿 - LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, this.Id, false); - } - } - } - - #endregion - - #region 鈼� 鍒犻櫎璁惧_________________________ - /// <summary> - /// 鍒犻櫎鍔熻兘-璁惧 - /// </summary> - /// <param name="deviceUIFilePath">Device UIF ile path.</param> - public void DeleteDevice(string deviceUIFilePath) - { - if (deviceUIFilePath == null) return; - if (DeviceUIFilePathList.Contains(deviceUIFilePath)) - { - DeviceUIFilePathList.Remove(deviceUIFilePath); - DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUIFilePath); - Save(); - } - } - - /// <summary> - /// 鍒犻櫎璁惧 - /// </summary> - /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> - public void DeleteDevice(CommonDevice device) - { - if (device == null) - { - return; - } - //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿 - var room = this.GetRoomByDevice(device); - if (room == null) - { - return; - } - string deviceFile = device.FilePath; - //绉婚櫎缂撳瓨 - if (room.DeviceUIFilePathList.Contains(deviceFile) == false) - { - return; - } - room.DeviceUIFilePathList.Remove(deviceFile); - - room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile); - room.Save(); - //鏇存敼鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(room.FileName); - - //閫掑綊锛氬垹闄ゆ帀浠ュ墠鐨勬棫鏁版嵁瀵艰嚧鐨勫涓埧闂寸殑闂 - this.DeleteDevice(device); - } - - /// <summary> - /// 鍒犻櫎鎴戠殑鍠滅埍鐨勮澶� - /// </summary> - /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> - public void DeleteLoveDevice(CommonDevice device) - { - if (device == null) - { - return; - } - //鎴戠殑鍠滅埍 - var loveRoom = this.GetLoveRoom(); - if (loveRoom != null) - { - string deviceFile = device.FilePath; - //绉婚櫎缂撳瓨 - if (loveRoom.DeviceUIFilePathList.Contains(deviceFile) == false) - { - return; - } - loveRoom.DeviceUIFilePathList.Remove(deviceFile); - loveRoom.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile); - } - } - - #endregion - - #region 鈼� 鑾峰彇璁惧_________________________ - - /// <summary> - /// 鏍规嵁璁惧鑾峰彇瀹冪殑UI瀵硅薄锛屽鏋滀笉瀛樺湪鍒欐柊寤� - /// </summary> - /// <returns>The device user interface.</returns> - /// <param name="device">璁惧瀵硅薄</param> - public DeviceUI GetDeviceUI(CommonDevice device) - { - return Common.LocalDevice.Current.GetDeviceUI(device); - } - - /// <summary> - /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧 - /// </summary> - /// <returns></returns> - public List<CommonDevice> GetRoomListDevice() - { - var listDevice = new List<CommonDevice>(); - foreach (var device in this.DeviceUIList) - { - if (device == null || device.CommonDevice == null) - { - continue; - } - listDevice.Add(device.CommonDevice); - } - return listDevice; - } - - /// <summary> - /// 鑾峰彇鎴块棿璁惧绫诲瀷 - /// </summary> - /// <param name="room"></param> - /// <returns></returns> - public static List<DeviceType> GetdeviceTypes(Room room) - { - List<DeviceType> typeList = new List<DeviceType> { }; - foreach (var deviceUI in room.DeviceUIList) - { - if (deviceUI == null || deviceUI.CommonDevice == null) - { - continue; - } - if (!typeList.Contains(deviceUI.CommonDevice.Type)) - { - typeList.Add(deviceUI.CommonDevice.Type); - } - } - return typeList; - } - - /// <summary> - /// 鑾峰彇璇ョ被鍨嬬殑璁惧 - /// </summary> - /// <param name="room"></param> - /// <param name="deviceType"></param> - /// <returns></returns> - public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType) - { - List<DeviceUI> typeList = new List<DeviceUI> { }; - foreach (var deviceUI in room.DeviceUIList) - { - if (deviceUI == null || deviceUI.CommonDevice == null) - { - continue; - } - if(deviceUI.CommonDevice.Type!=deviceType) - { - continue; - } - if (!typeList.Contains(deviceUI)) - { - typeList.Add(deviceUI); - } - } - return typeList; - } - - /// <summary> - /// 鑾峰彇鏈垎閰嶅尯鍩熻澶� - /// </summary> - /// <returns></returns> - public List<DeviceUI> GetUnalloctedDeviceUIs() - { - List<DeviceUI> deviceUIs = new List<DeviceUI> { }; - var dList = AllRoomDeviceUIList; - var commonDeviceList = Common.LocalDevice.Current.listAllDevice; - - foreach (var device in commonDeviceList) - { - if (dList.Find((obj) => obj.CommonDevice.DeviceEpoint == device.DeviceEpoint && obj.CommonDevice.DeviceAddr == device.DeviceAddr) == null) - { - deviceUIs.Add(Common.LocalDevice.Current.GetDeviceUI(device)); - } - } - if (deviceUIs.Count == 0) - { - return null; - } - return deviceUIs; - } - - //public List<DeviceUI> GetUnalloctedDeviceUITypes - - #endregion - - #region 鈼� 娣诲姞鍦烘櫙_________________________ - - /// <summary> - /// 娣诲姞鍦烘櫙 0澶辫触 1鎴愬姛 -1宸茬粡瀛樺湪 - /// </summary> - /// <returns>The scene.</returns> - /// <param name="sceneName">Scene name.</param> - /// <param name="sceneIconPath">鑳屾櫙鍥剧墖锛屼笉鍖呭惈浣忓畢璺緞 濡傛灉iconPathType=1鎴栬��2 闇�瑕佹嫾鎺ヤ綇瀹� 鍙樻垚 浣忓畢/sceneIconPath</param> - /// <param name="commons">Commons.</param> - /// <param name="iconPathType">I鍦烘櫙鑳屾櫙鍥剧墖鏉ユ簮绫诲瀷 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 榛樿0</param> - public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType) - { - //var scenes = GetSceneUIsByFloorId(FloorId); - //if(scenes!=null && scenes.Count>0) - //{ - // if (scenes.Find(s => s.Name == sceneName) != null) - // { - // return -1; - // } - //} - - var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); - if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) - { - return 0; - } - var getSceneIdData = getSceneIdAllData.getSceneIdData; - - bool result = true; - foreach (var common in commons) - { - //娣诲姞鏂版垚鍛� - var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData - { - Type = common.Type, - DeviceAddr = common.DeviceAddr, - Epoint = common.Epoint, - ScenesId = getSceneIdData.NewScenesId, - TaskList = common.TaskList, - DelayTime = common.DelayTime, - MemberNumber=common.MemberNumber, - ElseScenesId = common.ElseScenesId - }; - //common.ScenesId = getSceneIdData.NewScenesId; - //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 - var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); - if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) - { - continue; - } - var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; - if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) - { - result = false; - } - } - //鍔犲叆鎴愬姛 - if (result) - { - var sceneUI = new SceneUI - { - Name = sceneName, - Id = getSceneIdData.NewScenesId, - IconPath = sceneIconPath, - IconPathType = iconPathType, - AddSceneMemberDataList= commons - }; - sceneUI.Save(); - SceneUIList.Add(sceneUI); - SceneUIFilePathList.Add(sceneUI.FileName); - Save(); - return 1; - } - return 0; - } - - /// <summary> - /// 娣诲姞鍦烘櫙 - /// </summary> - /// <param name="scene">Scene.</param> - public void AddScene(SceneUI scene) - { - SceneUIList.Add(scene); - SceneUIFilePathList.Add(scene.FileName); - Save(); - } - - /// <summary> - /// 鍒犻櫎鍦烘櫙 - /// </summary> - /// <param name="scene"></param> - public void DeleteScene(SceneUI scene) - { - var curScene = SceneUIList.Find((obj) => obj.Id == scene.Id); - if (curScene == null) - { - return; - } - SceneUIList.Remove(curScene); - SceneUIFilePathList.Remove(curScene.FileName); - Save(); - } - - #endregion - - #region 鈼� 璁惧鏄惁鏀惰棌______________________ - - /// <summary> - /// 鏄惁鏄敹钘忚澶� - /// </summary> - /// <param name="filePath"></param> - /// <returns></returns> - public bool IsCollectInRoom(string filePath) - { - if (GetLoveRoom().DeviceUIFilePathList.Find((obj) => obj == filePath) == null) - { - return false; - } - return true; - } - #endregion - - #region 鈼� 淇敼鍦烘櫙________________________ - - /// <summary> - /// 淇敼鍦烘櫙璁惧 0澶辫触 1鎴愬姛 - /// </summary> - /// <returns>The scene.</returns> - /// <param name="sceneUI">Scene user interface.</param> - /// <param name="sceneRemoveMemberData">Scene remove member data.</param> - /// <param name="addCommons">Add commons.</param> - public async System.Threading.Tasks.Task<int> ModifyScene(SceneUI sceneUI, Scene.SceneRemoveMemberData sceneRemoveMemberData, List<Scene.AddSceneMemberData> addCommons) - { - //if (AllRoomSceneUIList.Find(s => s.Name == sceneUI.Name) == null) - //{ - // return 0; - //} - - bool result = true; - //绉婚櫎鎴愬憳 杩斿洖缁撴灉 - var removeSceneMemberResponseAllData = await ZigBee.Device.Scene.RemoveSceneMemberAsync(sceneRemoveMemberData); - if (removeSceneMemberResponseAllData == null || removeSceneMemberResponseAllData.removeSceneMemberResponseData == null) - { - return 0; - } - var removeSceneMemberResponseData = removeSceneMemberResponseAllData.removeSceneMemberResponseData; - if (removeSceneMemberResponseData == null) - { - return 0; - } - if (removeSceneMemberResponseData.Result != 0) - { - result = false; - } - //娣诲姞 - foreach (var addCommon in addCommons) - { - //娣诲姞鏂版垚鍛� - var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData - { - DeviceAddr = addCommon.DeviceAddr, - Type = addCommon.Type, - Epoint = addCommon.Epoint, - ScenesId = sceneUI.Id, - TaskList = addCommon.TaskList, - DelayTime = addCommon.DelayTime, - ElseScenesId = addCommon.ElseScenesId, - MemberNumber=addCommon.MemberNumber - }; - //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 - var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); - if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) - { - result = false; - System.Console.WriteLine("娣诲姞鍦烘櫙澶辫触"); - continue; - } - var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; - if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) - { - result = false; - } - } - //鍔犲叆鎴愬姛 - if (result) - { - sceneUI.AddSceneMemberDataList = addCommons; - sceneUI.Save(); - if (IsLove == false) - { - var curScene = Common.Room.CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == sceneUI.Id); - if (curScene != null) - { - curScene.Name = sceneUI.Name; - curScene.IconPath = sceneUI.IconPath; - curScene.IconPathType = sceneUI.IconPathType; - curScene.AddSceneMemberDataList = sceneUI.AddSceneMemberDataList; - curScene.SceneDelayTime = sceneUI.SceneDelayTime; - curScene.Save(false); - Common.Room.CurrentRoom.GetLoveRoom().Save(); - } - } - return 1; - } - return 0; - } - - /// <summary> - /// 璁剧疆銆佸悓姝ュ欢鏃舵椂闂� - /// </summary> - /// <param name="scene"></param> - public void ModifySceneDelayTime(SceneUI scene) - { - if (IsLove) - { - foreach (var r in Lists) - { - if (r.IsLove || r.SceneUIList.Count == 0) - { - continue; - } - foreach (var sce in r.SceneUIList) - { - if (sce.Id == scene.Id) - { - sce.SceneDelayTime = scene.SceneDelayTime; - sce.Save(false); - r.Save(false); - break; - } - } - } - } - else - { - var curScene = Common.Room.CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == scene.Id); - if (curScene != null) - { - curScene.SceneDelayTime = scene.SceneDelayTime; - curScene.Save(false); - Common.Room.CurrentRoom.GetLoveRoom().Save(false); - } - } - } - - #endregion - - #region 鈼� 鍒犻櫎鍦烘櫙________________________ - - /// <summary> - /// 绉婚櫎鍦烘櫙--璇ヤ粎杩涜浜嗗鏈湴鍦烘櫙鏁版嵁鐨勫垹闄� - /// </summary> - /// <param name="sceneUI">Scene user interface.</param> - public void RemoveScene(SceneUI sceneUI) - { - if(Global.IsExistsByHomeId(sceneUI.FileName)==false) - { - return; - } - - if (sceneUI.IconPathType == 1 || sceneUI.IconPathType == 2) - { - if (Global.IsExistsByHomeId(sceneUI.IconPath)) - { - Global.DeleteFilebyHomeId(sceneUI.IconPath); - HdlAutoBackupLogic.DeleteFile(sceneUI.IconPath); - } - } - - if (IsLove == false) - { - if (CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == sceneUI.Id) != null) - { - CurrentRoom.GetLoveRoom().DeleteScene(sceneUI); - } - } - - SceneUIList.Remove(sceneUI); - SceneUIFilePathList.Remove(sceneUI.FileName); - Save(); - - Global.DeleteFilebyHomeId(sceneUI.FileName); - HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); - } - - #endregion - - #region 鈼� 鑾峰彇鍦烘櫙________________________ - - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鍦烘櫙 - /// </summary> - /// <returns>The scene UIB y scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public SceneUI GetSceneUIBySceneId(int sceneId) - { - foreach (var r in Lists) - { - if (r.IsLove) - { - continue; - } - foreach (var sceneUI in r.SceneUIList) - { - if (sceneUI.Id == sceneId) - { - return sceneUI; - } - } - } - return null; - } - - /// <summary> - /// 鑾峰彇璇ユゼ灞傛墍鏈夊満鏅� - /// </summary> - /// <param name="floorId"></param> - /// <returns></returns> - public List<SceneUI> GetSameFloorScenes(string floorId) - { - List<SceneUI> sceneUIs = new List<SceneUI> { }; - var rooms= CurrentRoom.GetRoomsByFloorId(floorId); - foreach(var r in rooms) - { - sceneUIs.AddRange(r.SceneUIList); - } - return sceneUIs; - } - - /// <summary> - /// 鑾峰彇璇ユゼ灞傜殑鍦烘櫙 - /// </summary> - /// <param name="floorId"></param> - /// <returns></returns> - public List<SceneUI> GetSceneUIsByFloorId(string floorId) - { - var rooms = GetRoomsByFloorId(floorId); - if (rooms == null) - { - return null; - } - var sceneList = new List<SceneUI> { }; - foreach (var r in rooms) - { - if (r.SceneUIList.Count == 0) - { - continue; - } - foreach (var sceneUI in r.SceneUIList) - { - if (sceneUI == null) - { - continue; - } - sceneList.Add(sceneUI); - } - } - return sceneList; - } - - /// <summary> - /// 鑾峰彇鏈垎閰嶅尯鍩熷満鏅� - /// </summary> - /// <returns></returns> - public List<SceneUI> GetUnalloctedScenes() - { - List<SceneUI> sceneUIs = new List<SceneUI> { }; - var sList = AllRoomSceneUIFilepathList; - - List<string> sfile = new List<string> { }; - foreach (var path in Global.FileListByHomeId()) - { - if (path.StartsWith("Scene_", StringComparison.Ordinal)) - { - sfile.Add(path); - } - } - foreach (var path in sfile) - { - if (sList.Find((obj) => obj == path) == null) - { - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(path)); - var tempSceneUI = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); - if (tempSceneUI != null) - { - sceneUIs.Add(tempSceneUI); - } - } - } - if (sceneUIs.Count == 0) - { - return null; - } - return sceneUIs; - } - - #endregion - - #region 鈼� 鍒锋柊鍦烘櫙_________________________ - - /// <summary> - /// 鍒锋柊鎴块棿鐨勫満鏅垪琛� - /// </summary> - public async System.Threading.Tasks.Task<bool> RefreshSceneUIList() - { - bool result = true; - var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); - if (sceneList == null) - { - return false; - } - List<int> sceneIDList = new List<int> { }; - foreach (var scene in sceneList) - { - if (scene == null) - { - continue; - } - sceneIDList.Add(scene.ScenesId); - } - foreach (var r in Lists) - { - if(r.IsLove) - { - continue; - } - if (r.SceneUIList == null || r.SceneUIList.Count == 0) - { - continue; - } - foreach (var rScene in r.SceneUIList) - { - if (rScene == null) - { - continue; - } - if (sceneIDList.Contains(rScene.Id) == false) - { - r.RemoveScene(rScene); - result = true; - } - } - } - return result; - } - - #endregion - - #region 鈼� 淇濆瓨____________________________ - - /// <summary> - /// 淇濆瓨 - /// </summary> - /// <param name="autoBackup">鏄惁鑷姩澶囦唤锛岄粯璁rue</param> - public void Save(bool autoBackup = true) - { - //淇濆瓨鎴块棿淇℃伅 - Global.WriteFileByBytesByHomeId(FileName, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); - if (autoBackup == true) - { - HdlAutoBackupLogic.AddOrEditorFile(FileName); - } - } - - #endregion - - #region 鈼� 妤煎眰鍜屾埧闂撮『搴忕浉鍏砡______________ - - /// <summary> - /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� - /// </summary> - /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> - /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> - /// <returns></returns> - public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - var listRoomSort = new List<string>(); - if (dicAllSort.ContainsKey(i_floorKeys) == true) - { - listRoomSort = dicAllSort[i_floorKeys]; - } - else - { - dicAllSort[i_floorKeys] = listRoomSort; - } - - var dicRoom = new Dictionary<string, Common.Room>(); - foreach (var room in Common.Room.Lists) - { - if (room.FloorId != i_floorKeys || room.IsLove == true) - { - //涓嶆槸鍚屼竴涓ゼ灞� - continue; - } - if (listRoomSort.Contains(room.Id) == false) - { - //鏂版坊鍔犵殑鎴块棿 - listRoomSort.Add(room.Id); - } - if (getShard == false && room.IsSharedRoom == true) - { - //涓嶈鍒嗕韩鐨勬埧闂� - continue; - } - dicRoom[room.Id] = room; - } - - var listSortRoom = new List<Room>(); - for (int i = 0; i < listRoomSort.Count; i++) - { - if (dicRoom.ContainsKey(listRoomSort[i]) == true) - { - listSortRoom.Add(dicRoom[listRoomSort[i]]); - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - return listSortRoom; - } - - /// <summary> - /// 淇濆瓨鎴块棿鐨勯『搴� - /// </summary> - /// <param name="i_floorKeys">妤煎眰涓婚敭</param> - /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> - public void SaveRoomSort(string i_floorKeys, List<string> listSort) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - //淇濆瓨椤哄簭 - dicAllSort[i_floorKeys] = listSort; - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - dicAllSort.Clear(); - } - - /// <summary> - /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 - /// </summary> - /// <returns></returns> - public Dictionary<string, string> GetFloorSortList() - { - //璇诲彇妤煎眰椤哄簭 - var listFloorSort = new List<string>(); - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); - } - foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) - { - if (listFloorSort.Contains(keys) == false) - { - //鏂版坊鍔犵殑妤煎眰 - listFloorSort.Add(keys); - } - } - - var dic = new Dictionary<string, string>(); - for (int i = 0; i < listFloorSort.Count; i++) - { - if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) - { - dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listFloorSort); - return dic; - } - - /// <summary> - /// 淇濆瓨妤煎眰鐨勯『搴� - /// </summary> - /// <param name="listSort">妤煎眰鐨勪富閿�</param> - public void SaveFloorSort(List<string> listSort) - { - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listSort); - } + public List<int> ListSceneId = new List<int>(); #endregion - #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________ + #region 鈻� 淇濆瓨_______________________________ /// <summary> - /// 鍏嬮殕鎴块棿瀵硅薄 + /// 淇濆瓨 /// </summary> - /// <returns></returns> - public Room CloneRoomClass() + /// <param name="autoBackup">鏄惁鑷姩澶囦唤锛岄粯璁rue</param> + public void Save(bool autoBackup = true) { - var newRoom = new Room(); - //鍏嬮殕灞炴�� - newRoom.Id = this.Id; - newRoom.FloorId = this.FloorId; - newRoom.TemperatrueDevice = this.TemperatrueDevice; - newRoom.HumidityDevice = this.HumidityDevice; - newRoom.Name = this.Name; - newRoom.BackgroundImage = this.BackgroundImage; - newRoom.BackgroundImageType = this.BackgroundImageType; - - return newRoom; + //淇濆瓨鎴块棿淇℃伅 + Global.WriteFileByBytesByHomeId(FileName, Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); + if (autoBackup == true) + { + HdlAutoBackupLogic.AddOrEditorFile(FileName); + } } #endregion - } } diff --git a/ZigbeeApp/Shared/Common/SceneRoomUI.cs b/ZigbeeApp/Shared/Common/SceneRoomUI.cs index f60ab23..b6e5613 100755 --- a/ZigbeeApp/Shared/Common/SceneRoomUI.cs +++ b/ZigbeeApp/Shared/Common/SceneRoomUI.cs @@ -26,15 +26,17 @@ { //閫夋嫨鍦烘櫙--鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� AllSceneRoomUIList.Clear(); - List<int> sceneIdList = new List<int> { }; - foreach (var r in Shared.Common.Room.Lists) + List<int> sceneIdList = new List<int> { }; + var listAllRoom = Phone.UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + foreach (var r in listAllRoom) { - if (r.SceneUIList.Count == 0) + if (r.ListSceneId.Count == 0) { continue; } - foreach (var scene in r.SceneUIList) + foreach (var sceneId in r.ListSceneId) { + var scene = Phone.UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); if (scene == null) { continue; diff --git a/ZigbeeApp/Shared/Common/SceneTargetDeviceUI.cs b/ZigbeeApp/Shared/Common/SceneTargetDeviceUI.cs index f9dddbd..12d007b 100755 --- a/ZigbeeApp/Shared/Common/SceneTargetDeviceUI.cs +++ b/ZigbeeApp/Shared/Common/SceneTargetDeviceUI.cs @@ -1,6 +1,7 @@ 锘縰sing System; using System.Collections.Generic; using System.Globalization; +using ZigBee.Device; using static ZigBee.Device.Scene; namespace Shared.Common @@ -24,7 +25,7 @@ /// 閫夋嫨鐨勮澶� /// Type=0 瀛樺湪 /// </summary> - public DeviceUI DeviceUI = new DeviceUI(); + public CommonDevice DeviceUI = new CommonDevice(); /// <summary> /// Type=0銆�1銆�2 瀛樺湪 @@ -64,7 +65,7 @@ /// <returns></returns> public string GetDeviceStatu() { - if (DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) + if (DeviceUI.Type == ZigBee.Device.DeviceType.OnOffOutput) { if (TaskList.Count == 0) { @@ -76,7 +77,7 @@ } return Language.StringByID(R.MyInternationalizationString.Shut); } - else if (DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) + else if (DeviceUI.Type == ZigBee.Device.DeviceType.AirSwitch) { if (TaskList.Count == 0) { @@ -88,7 +89,7 @@ } return Language.StringByID(R.MyInternationalizationString.Shut); } - else if (DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight) + else if (DeviceUI.Type == ZigBee.Device.DeviceType.DimmableLight) { if (TaskList.Count == 0) { @@ -100,7 +101,7 @@ } return $"{(int)(TaskList[0].Data1 * 1.0 / 254 * 100)}%"; } - else if (DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) + else if (DeviceUI.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) { if (TaskList.Count == 0) { @@ -112,7 +113,7 @@ } return $"{TaskList[0].Data2}%"; } - else if (DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) + else if (DeviceUI.Type == ZigBee.Device.DeviceType.Thermostat) { //娓╁害锛屾ā寮忥紝椋庨�� string tempareture = string.Empty; diff --git a/ZigbeeApp/Shared/Common/SceneUI.cs b/ZigbeeApp/Shared/Common/SceneUI.cs index 289d506..fa908a3 100755 --- a/ZigbeeApp/Shared/Common/SceneUI.cs +++ b/ZigbeeApp/Shared/Common/SceneUI.cs @@ -10,8 +10,8 @@ /// </summary> [System.Serializable] public class SceneUI : ZigBee.Device.CommonDevice - { - #region 鈼� 鍙橀噺____________________________ + { + #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> /// 鍦烘櫙鏂囦欢 /// </summary> @@ -28,12 +28,10 @@ /// 鍦烘櫙id /// </summary> public int Id = -1; - /// <summary> /// 鍦烘櫙鍚� /// </summary> public string Name = string.Empty; - /// <summary> /// 鍥剧墖璺緞 /// </summary> @@ -42,201 +40,34 @@ /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 /// </summary> public int IconPathType = 0; - - /// <summary> - /// 鍔熻兘璺緞鍒楄〃---澶囩敤 - /// </summary> - public List<string> FunctionFilePathList = new List<string> { }; - - /// <summary> - /// 閫氱敤鏍囪瘑--澶囩敤 - /// </summary> - public object Tag; - /// <summary> /// 寤舵椂鎵ц鏃堕棿--璁惧寤舵椂 /// </summary> public int DelayTime = 0; - /// <summary> /// 鏍囪瘑褰撳墠鍦烘櫙鏄惁鏄垎浜殑鍦烘櫙 /// </summary> public bool IsSharedScene = false; - ///// <summary> - ///// 鏄惁鏀惰棌 - ///// </summary> - //public bool IsCollected = false; - /// <summary> /// 寤舵椂鎵ц鏃堕棿--鏁翠釜鍦烘櫙寤舵椂(涓嶆槸寤舵椂鍦烘櫙閲岄潰鐨勬墽琛岀洰鏍�) /// 涓嶅簭鍒楀寲锛岄噸鏂版墦寮�APP缃�傚嵆鍙鏈缂栬緫鍦烘櫙寤舵椂鎵ц鏈夋晥 /// </summary> [Newtonsoft.Json.JsonIgnore] - public int SceneDelayTime = 0; - + public int SceneDelayTime = 0; /// <summary> /// 鍓╀綑瑙﹀彂鏃堕棿锛屽崟浣嶇 /// </summary> [Newtonsoft.Json.JsonIgnore] - public int RemainTime; - + public int RemainTime; /// <summary> /// 鍦烘櫙鎵ц鐩爣 /// </summary> public List<ZigBee.Device.Scene.AddSceneMemberData> AddSceneMemberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData> { }; - ///// <summary> - ///// RoomId - ///// </summary> - //public string RoomId = string.Empty; #endregion - - #region 鈼� 閫氳繃鍦烘櫙id鑾峰彇鍦烘櫙璺緞_____________ - /// <summary> - /// GetSceneFilePathBySceneId - /// </summary> - /// <param name="sceneId"></param> - /// <returns></returns> - public static string GetSceneFilePathBySceneId(int sceneId) - { - return $"Scene_{sceneId}.json"; - } - - #endregion - - #region 鈼� 閫氳繃id鑾峰彇鍦烘櫙鍖哄煙_________________ - - /// <summary> - /// GetZone - /// </summary> - /// <returns></returns> - public string GetZone() - { - var room = Room.CurrentRoom.GetRoomBySceneId(Id); - if(room==null) - { - return null; - } - var floorName = Shared.Common.Config.Instance.Home.GetFloorNameById(room.FloorId); - if (floorName == null) - { - return room.Name; - } - return $"{floorName},{room.Name}"; - } - - #endregion - - #region 鈼� 缂栬緫鍦烘櫙_________________________ - /// <summary> - /// 缂栬緫鍦烘櫙 - /// </summary> - /// <param name="sceneUI">sceneUI</param> - /// <param name="room">Room.</param> - public static void EditScene(SceneUI sceneUI, Room room) - { - Application.RunOnMainThread(async () => - { - try - { - var targetList = new List<SceneTargetDeviceUI> { }; - CommonPage.Loading.Start(); - //浠庣綉鍏充腑鍙嶅簭鍒楀寲鍑哄搴旂殑鎴块棿璁惧 - var sceneDeviceList = await ZigBee.Device.Scene.GetSceneDeviceListAsync(sceneUI.Id); - if (sceneDeviceList == null) - { - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheMainGatewayIsNotOnLine); - return; - } - - if (Shared.Common.Room.AllRoomDeviceUIList.Count == 0) - { - - if (Shared.Common.Room.AllRoomDeviceUIList.Count == 0) - { - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ThisSceneHaveNoDevice); - } - //return; - } - if (sceneDeviceList.getSceneDeviceListInfo != null) - { - var deviceList = sceneDeviceList.getSceneDeviceListInfo.DeviceList; - - if (deviceList != null && Room.AllRoomDeviceUIList.Count != 0) - { - foreach (var sceneDev in deviceList) - { - if (sceneDev.Type == 0) - { - var dev = Room.AllRoomDeviceUIList.Find((obj) => obj.DeviceEpoint == sceneDev.Epoint && obj.DeviceAddr == sceneDev.DeviceAddr); - if(dev!=null) - { - var sceneTargetDevice = new SceneTargetDeviceUI { - Type = 0, - DeviceUI = dev, - TaskList = sceneDev.TaskList, - DelayTimeSerialNumber= deviceList.IndexOf(sceneDev) + 1 - }; - - targetList.Add(sceneTargetDevice); - } - } - else if (sceneDev.Type == 1) - { - var localScene = Room.AllRoomSceneUIList.Find((obj) => obj.Id == sceneDev.ElseScenesId); - if (localScene != null) - { - var sceneTargetDeviceScene = new SceneTargetDeviceUI { - Type = 1, - ElseScenesId = sceneDev.ElseScenesId, - SceneName = localScene.Name, - SceneUI = localScene, - DelayTimeSerialNumber = deviceList.IndexOf(sceneDev) + 1 - }; - targetList.Add(sceneTargetDeviceScene); - } - } - else - { - var sceneTargetDeviceScene = new SceneTargetDeviceUI - { - Type = 2, - DelayTime = sceneDev.DelayTime, - DelayTimeSerialNumber = deviceList.IndexOf(sceneDev)+1 - }; - targetList.Add(sceneTargetDeviceScene); - } - } - } - } - else - { - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); - } - var scene = new CategoryAddScene(); - Phone.UserView.HomePage.Instance.AddChidren(scene); - Phone.UserView.HomePage.Instance.PageIndex += 1; - scene.isModify = true; - scene.modifyRoom = room; - scene.modifySceneUI = sceneUI; - scene.modifySceneTargetDevicesList = targetList; - scene.Show(); - } - catch (Exception ex) - { - System.Console.WriteLine($"缂栬緫鍦烘櫙鍑洪敊---{ex.Message}"); - } - finally - { - CommonPage.Loading.Hide(); - } - }); - } - - #endregion - - #region 鈼� 淇濆瓨____________________________ - + + #region 鈻� 淇濆瓨_____________________________ + /// <summary> /// 淇濆瓨 /// </summary> diff --git a/ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs b/ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs index 36efb69..f2442bc 100755 --- a/ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs @@ -13,7 +13,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// 鏀惰棌鎸夐挳 @@ -22,7 +22,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -153,11 +153,11 @@ try { var deviceUI = device; - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } @@ -169,20 +169,18 @@ { return; } - deviceUI.CommonDevice.DeviceStatusReport = common.DeviceStatusReport; + deviceUI.DeviceStatusReport = common.DeviceStatusReport; foreach(var attList in attriButeList) { - var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default; switch (attList.AttributeId) { case 0: - ac.currentLocalTemperature = curTemp; + ac.currentLocalTemperature = attList.AttriButeData / 100; ac.LastDateTime = DateTime.Now; indoorTemperatureBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {ac.currentLocalTemperature} 鈩�"; - //currentTemperatureBtn.Text = $"{ac.currentLocalTemperature} 鈩�"; break; case 17: - ac.currentCoolingSetpoint = curTemp; + ac.currentCoolingSetpoint = attList.AttriButeData / 100; if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8) { mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint; @@ -190,7 +188,7 @@ ac.LastDateTime = DateTime.Now; break; case 18: - ac.currentHeatingSetpoint = curTemp; + ac.currentHeatingSetpoint = attList.AttriButeData / 100; if (ac.currentSystemMode == 4) { mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint; @@ -198,7 +196,7 @@ ac.LastDateTime = DateTime.Now; break; case 4096: - ac.currentAutoSetpoint = curTemp; + ac.currentAutoSetpoint = attList.AttriButeData / 100; if (ac.currentSystemMode == 1) { mArcScaleSeekBar.Progress = ac.currentAutoSetpoint; @@ -217,6 +215,8 @@ fanModeBtn.IsSelected = false; FanSwingModeBtn.IsSelected = false; mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); + //濡傛灉鏄叧闂┖璋冪殑璇�,鐩存帴鍙樻殫鍗冲彲 + return; } else if (ac.currentSystemMode == 1 || ac.currentSystemMode == 3 || ac.currentSystemMode == 4 || ac.currentSystemMode == 7 || ac.currentSystemMode == 8) { @@ -291,16 +291,16 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.Thermostat) + if (deviceUI.Type == DeviceType.Thermostat) { ac.IsOnline = common.IsOnline; ac.LastDateTime = DateTime.Now; @@ -374,12 +374,12 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev, Shared.Common.Room room) + public void Show(CommonDevice dev, Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; - this.ac = device.CommonDevice as ZigBee.Device.AC; + this.ac = device as ZigBee.Device.AC; AddTop(); AddBodyView(device); @@ -393,7 +393,7 @@ //鍙戦�佽鍙栫姸鎬佸懡浠� UserView.UserHomeView.ReadStatus(ac, () => { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendACStatuComand(device); }); } else @@ -401,11 +401,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendACStatuComand(device); } } - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName)==false) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device)==false) { collectionBtn.IsSelected = false; } @@ -449,7 +449,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -492,7 +492,7 @@ Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold=true @@ -1080,9 +1080,10 @@ ACControlBase.ShowACIsCloseTip(); return; } - modeBtn.IsSelected = true; + modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByMode(acMode); - modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode); + modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode); + modeBtn.IsSelected = true; currentModeBtn.Text = ACControlBase.GetModeNameByMode(acMode); ac.currentSystemMode = (int)acMode; mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac); @@ -1403,7 +1404,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; @@ -1459,12 +1460,12 @@ { if (collectionBtn.IsSelected) { - Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); collectionBtn.IsSelected = false; } else { - Shared.Common.Room.Lists[0].AddDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); collectionBtn.IsSelected = true; } } diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs old mode 100755 new mode 100644 index 7747c86..655fb6f --- a/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs +++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs @@ -416,7 +416,7 @@ //鍚姩ZigBee ZigBee.Common.Application.Init(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); @@ -565,7 +565,7 @@ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); //鍚姩ZigBee ZigBee.Common.Application.Init(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); @@ -618,7 +618,7 @@ ZigBee.Common.Application.Init(); //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs old mode 100755 new mode 100644 index 798fe31..7804f1f --- a/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs +++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs @@ -352,7 +352,7 @@ //鍚姩ZigBee ZigBee.Common.Application.Init(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); @@ -527,7 +527,7 @@ ZigBee.Common.Application.Init(); //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); @@ -580,7 +580,7 @@ ZigBee.Common.Application.Init(); //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { this.RemoveFromParent(); diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountRegisterSuccess.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountRegisterSuccess.cs index 3c52135..c5e73a0 100755 --- a/ZigbeeApp/Shared/Phone/Device/Account/AccountRegisterSuccess.cs +++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountRegisterSuccess.cs @@ -124,7 +124,7 @@ //鍚姩ZigBee ZigBee.Common.Application.Init(); - Shared.Common.Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs index 75e410e..9bb4cd1 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs @@ -107,7 +107,7 @@ /// <summary> /// 鐩稿悓绫诲瀷鐨勮澶囧垪琛� /// </summary> - private Dictionary<int, List<DeviceUI>> typeDeviceDic; + private Dictionary<int, List<CommonDevice>> typeDeviceDic; /// <summary> /// 璁惧绫诲瀷鐨勫浘id /// </summary> @@ -115,7 +115,7 @@ /// <summary> /// dList /// </summary> - private List<DeviceUI> devList; + private List<CommonDevice> devList; /// <summary> /// sceneList /// </summary> @@ -173,33 +173,33 @@ for (int i = 0; deviceListScrolView != null && i < deviceListScrolView.ChildrenCount; i++) { var rowLayout = deviceListScrolView.GetChildren(i) as RowLayout; - var deviceUI = rowLayout.Tag as DeviceUI; - if (deviceUI == null || deviceUI.CommonDevice == null) + var deviceUI = LocalDevice.Current.GetDevice(rowLayout.Tag.ToString()); + if (deviceUI == null) { continue; } - if (deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr || deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint) + if (deviceUI.DeviceAddr != common.DeviceAddr || deviceUI.DeviceEpoint != common.DeviceEpoint) { continue; } - switch (deviceUI.CommonDevice.Type) + switch (deviceUI.Type) { case DeviceType.OnOffOutput: //寮�鍏冲姛鑳� if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; light.DeviceStatusReport = common.DeviceStatusReport; light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = light.OnOffStatus == 1; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); light.LastDateTime = DateTime.Now; } if (common.DeviceStatusReport.CluterID == 3) { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; } break; @@ -207,18 +207,18 @@ //寮�鍏冲姛鑳� if (common.DeviceStatusReport.CluterID == 6) { - var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch; + var airSwitch = deviceUI as ZigBee.Device.AirSwitch; airSwitch.DeviceStatusReport = common.DeviceStatusReport; airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData; var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = airSwitch.OnOffStatus == 1; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); airSwitch.LastDateTime = DateTime.Now; } if (common.DeviceStatusReport.CluterID == 3) { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; } break; case DeviceType.WindowCoveringDevice: @@ -228,7 +228,7 @@ if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0) { //绐楀笜绫诲瀷 - var rollerShade = deviceUI.CommonDevice as Rollershade; + var rollerShade = deviceUI as Rollershade; rollerShade.DeviceStatusReport = common.DeviceStatusReport; rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData; rollerShade.LastDateTime = DateTime.Now; @@ -237,18 +237,18 @@ { var row = rowLayout.GetChildren(0) as CategoryFunctionForWinRow; //绐楀笜鐧惧垎姣� - var rollerShade = deviceUI.CommonDevice as Rollershade; + var rollerShade = deviceUI as Rollershade; rollerShade.DeviceStatusReport = common.DeviceStatusReport; rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData; - row.SetStatuText($"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}"); + row.SetStatuText($"{Language.StringByID(R.MyInternationalizationString.Current)} { HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)}"); row.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0; rollerShade.LastDateTime = DateTime.Now; } } if (common.DeviceStatusReport.CluterID == 3) { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; } break; @@ -257,7 +257,7 @@ if (common.DeviceStatusReport.CluterID == 513) { var attriButeList = common.DeviceStatusReport.AttriBute; - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; + var ac = deviceUI as ZigBee.Device.AC; ac.DeviceStatusReport = common.DeviceStatusReport; foreach (var attList in attriButeList) { @@ -292,12 +292,12 @@ } var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = ac.currentSystemMode != 0; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); } if (common.DeviceStatusReport.CluterID == 514) { - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; + var ac = deviceUI as ZigBee.Device.AC; var attriButeList = common.DeviceStatusReport.AttriBute; ac.DeviceStatusReport = common.DeviceStatusReport; foreach (var attList in attriButeList) @@ -316,12 +316,12 @@ } var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = ac.currentSystemMode != 0; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); } if (common.DeviceStatusReport.CluterID == 3) { - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; + var ac = deviceUI as ZigBee.Device.AC; ac.IsOnline = 1; ac.LastDateTime = DateTime.Now; } @@ -330,28 +330,28 @@ //璋冨厜鐏姛鑳� if (common.DeviceStatusReport.CluterID == 6) { - var dimmableLight = deviceUI.CommonDevice as DimmableLight; + var dimmableLight = deviceUI as DimmableLight; dimmableLight.DeviceStatusReport = common.DeviceStatusReport; dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = dimmableLight.OnOffStatus == 1; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); dimmableLight.LastDateTime = DateTime.Now; } if (common.DeviceStatusReport.CluterID == 8) { - var dimmableLight = deviceUI.CommonDevice as DimmableLight; + var dimmableLight = deviceUI as DimmableLight; dimmableLight.DeviceStatusReport = common.DeviceStatusReport; dimmableLight.Level = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = dimmableLight.OnOffStatus == 1; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); dimmableLight.LastDateTime = DateTime.Now; } if (common.DeviceStatusReport.CluterID == 3) { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; } break; @@ -359,7 +359,7 @@ //娓╁害 if (common.DeviceStatusReport.CluterID == 1026) { - var tempera = deviceUI.CommonDevice as TemperatureSensor; + var tempera = deviceUI as TemperatureSensor; foreach (var data in common.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -384,14 +384,14 @@ tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); } var row = rowLayout.GetChildren(0) as CategoryFunctionRow; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); } } } //婀垮害 if (common.DeviceStatusReport.CluterID == 1029) { - var tempera = deviceUI.CommonDevice as TemperatureSensor; + var tempera = deviceUI as TemperatureSensor; foreach (var data in common.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -409,7 +409,7 @@ tempera.LastDateTime = DateTime.Now; } var row = rowLayout.GetChildren(0) as CategoryFunctionRow; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); } } } @@ -432,40 +432,40 @@ for (int i = 0; deviceListScrolView != null && i < deviceListScrolView.ChildrenCount; i++) { var rowLayout = deviceListScrolView.GetChildren(i) as RowLayout; - var deviceUI = rowLayout.Tag as DeviceUI; - if (deviceUI == null || deviceUI.CommonDevice == null) + var deviceUI = LocalDevice.Current.GetDevice(rowLayout.Tag.ToString()); + if (deviceUI == null) { continue; } - if (deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr || deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint) + if (deviceUI.DeviceAddr != common.DeviceAddr || deviceUI.DeviceEpoint != common.DeviceEpoint) { continue; } - switch (deviceUI.CommonDevice.Type) + switch (deviceUI.Type) { case DeviceType.OnOffOutput: - deviceUI.CommonDevice.IsOnline = common.IsOnline; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; break; case DeviceType.AirSwitch: - deviceUI.CommonDevice.IsOnline = common.IsOnline; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; break; case DeviceType.WindowCoveringDevice: - deviceUI.CommonDevice.LastDateTime = DateTime.Now; - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; break; case DeviceType.DimmableLight: - deviceUI.CommonDevice.LastDateTime = DateTime.Now; - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; break; case DeviceType.Thermostat: - deviceUI.CommonDevice.LastDateTime = DateTime.Now; - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; break; } } @@ -485,25 +485,25 @@ for (int i = 0; deviceListScrolView != null && i < deviceListScrolView.ChildrenCount; i++) { var rowLayout = deviceListScrolView.GetChildren(i) as RowLayout; - var deviceUI = rowLayout.Tag as DeviceUI; - if (deviceUI == null || deviceUI.CommonDevice == null) + var deviceUI = LocalDevice.Current.GetDevice(rowLayout.Tag.ToString()); + if (deviceUI == null) { continue; } - if (deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr || deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint) + if (deviceUI.DeviceAddr != common.DeviceAddr || deviceUI.DeviceEpoint != common.DeviceEpoint) { continue; } - switch (deviceUI.CommonDevice.Type) + switch (deviceUI.Type) { case DeviceType.IASZone: //寮�鍏冲姛鑳� var ias = common as IASZone; - var iAS = deviceUI.CommonDevice as ZigBee.Device.IASZone; + var iAS = deviceUI as ZigBee.Device.IASZone; iAS.iASInfo = ias.iASInfo; var row = rowLayout.GetChildren(0) as CategoryFunctionRow; row.IsSelected = iAS.iASInfo?.Alarm1 == 1; - row.SetStatuText(deviceUI.GetDeviceStatu()); + row.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); iAS.LastDateTime = DateTime.Now; break; } @@ -717,7 +717,7 @@ floors.FloorAction += (floorId) => { floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId); - Common.Room.CurrentRoom = Common.Room.CurrentRoom.GetLoveRoom(); + HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom(); RefreshBodyView(); }; } @@ -862,7 +862,7 @@ /// </summary> private void InitData() { - typeDeviceDic = new Dictionary<int, List<DeviceUI>> { }; + typeDeviceDic = new Dictionary<int, List<CommonDevice>> { }; typeIdDic = new Dictionary<int, DeviceConcreteType> { }; } @@ -871,20 +871,20 @@ /// </summary> private void RefreshData(Common.Room room) { - devList = room.DeviceUIList; - sceneList = room.SceneUIList; + devList = HdlRoomLogic.Current.GetRoomListDevice(room); + sceneList = HdlSceneLogic.Current.GetRoomSceneList(room); typeDeviceDic.Clear(); typeIdDic.Clear(); foreach (var device in devList) { - var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device.CommonDevice); + var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); if (info.BeloneType == DeviceBeloneType.A骞叉帴鐐� || info.BeloneType == DeviceBeloneType.A涓户鍣�) { continue; } if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false) { - var sameDevList = new List<DeviceUI> { }; + var sameDevList = new List<CommonDevice> { }; sameDevList.Add(device); typeDeviceDic[info.BeloneTextId] = sameDevList; } @@ -1038,7 +1038,7 @@ deviceListScrolView.RemoveAll(); - var sameTypeList = new List<DeviceUI> { }; + var sameTypeList = new List<CommonDevice> { }; sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())]; for (int i = 0; i < sameTypeList.Count; i++) @@ -1054,15 +1054,15 @@ { Height = Application.GetRealHeight(127 + 35), LineColor = ZigbeeColor.Current.GXCClearColor, - Tag = deviceUI, - SubViewWidth=Application.GetRealWidth(184) + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI), + SubViewWidth = Application.GetRealWidth(184) }; deviceListScrolView.AddChidren(deviceTypeRowLayout); - if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) + if (deviceUI.Type == DeviceType.OnOffOutput) { //鐏� - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; if (light.Gateway != null) { new System.Threading.Thread(() => @@ -1072,7 +1072,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI); }); } else @@ -1080,7 +1080,7 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI); } } }) @@ -1088,17 +1088,17 @@ var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.IsSelected = light.OnOffStatus == 1; deviceTypeRowLayout.AddChidren(deviceRow); deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) => { - zbGateway = deviceUI.CommonDevice.Gateway; + zbGateway = deviceUI.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI); (send2 as Button).IsSelected = !(send2 as Button).IsSelected; deviceRow.IsSelected = (send2 as Button).IsSelected; if ((send2 as Button).IsSelected) @@ -1109,9 +1109,9 @@ { light.SwitchControl(0); } - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () => + HdlDeviceOtherLogic.Current.SendCommandDelayAction(deviceUI, () => { if (Parent == null) { @@ -1120,7 +1120,7 @@ RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); }; @@ -1129,7 +1129,7 @@ var lightControl = new Phone.Device.Light.OnOffControl(); UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; - lightControl.Show(deviceUI, Common.Room.CurrentRoom); + lightControl.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); lightControl.action += (curDev, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1141,7 +1141,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1149,19 +1149,19 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } } - else if (deviceUI.CommonDevice.Type == DeviceType.AirSwitch) + else if (deviceUI.Type == DeviceType.AirSwitch) { //绌烘皵寮�鍏� - var airSwitch = deviceUI.CommonDevice as AirSwitch; + var airSwitch = deviceUI as AirSwitch; if (airSwitch.Gateway != null) { new System.Threading.Thread(() => @@ -1171,14 +1171,14 @@ { UserHomeView.ReadStatus(airSwitch, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI); }); } else { if ((DateTime.Now - airSwitch.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI); } } }) @@ -1186,16 +1186,16 @@ var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); deviceRow.IsSelected = airSwitch.OnOffStatus == 1; - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceTypeRowLayout.AddChidren(deviceRow); deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) => { - zbGateway = deviceUI.CommonDevice.Gateway; + zbGateway = deviceUI.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI); (send2 as Button).IsSelected = !(send2 as Button).IsSelected; deviceRow.IsSelected = (send2 as Button).IsSelected; if ((send2 as Button).IsSelected) @@ -1206,9 +1206,9 @@ { airSwitch.SwitchControl(0); } - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () => + HdlDeviceOtherLogic.Current.SendCommandDelayAction(deviceUI, () => { if (Parent == null) { @@ -1217,7 +1217,7 @@ RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); }; @@ -1227,7 +1227,7 @@ var lightControl = new Phone.Device.Light.AirSwitchControl(); UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; - lightControl.Show(deviceUI, Common.Room.CurrentRoom); + lightControl.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); lightControl.action += (curDev, curRoom) => { @@ -1241,7 +1241,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1250,19 +1250,19 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } } - else if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) + else if (deviceUI.Type == DeviceType.DimmableLight) { //璋冨厜鐏� - var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; + var dimmableLight = deviceUI as ZigBee.Device.DimmableLight; if (dimmableLight.Gateway != null) { new System.Threading.Thread(() => @@ -1272,14 +1272,14 @@ { UserHomeView.ReadStatus(dimmableLight, () => { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI); }); } else { if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI); } } }) @@ -1287,17 +1287,17 @@ var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.IsSelected = dimmableLight.OnOffStatus == 1; deviceTypeRowLayout.AddChidren(deviceRow); deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) => { - zbGateway = deviceUI.CommonDevice.Gateway; + zbGateway = deviceUI.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI); (send2 as Button).IsSelected = !(send2 as Button).IsSelected; deviceRow.IsSelected = (send2 as Button).IsSelected; if ((send2 as Button).IsSelected) @@ -1308,9 +1308,9 @@ { dimmableLight.SwitchControl(0); } - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () => + HdlDeviceOtherLogic.Current.SendCommandDelayAction(deviceUI, () => { if (Parent == null) { @@ -1319,7 +1319,7 @@ RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); }; @@ -1330,7 +1330,7 @@ UserView.HomePage.Instance.AddChidren(dimmableLightControl); UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; - dimmableLightControl.Show(deviceUI, Common.Room.CurrentRoom); + dimmableLightControl.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); dimmableLightControl.action += (curDev, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1343,7 +1343,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1351,19 +1351,19 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } } - else if (deviceUI.CommonDevice.Type == DeviceType.Thermostat) + else if (deviceUI.Type == DeviceType.Thermostat) { //绌鸿皟 - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; + var ac = deviceUI as ZigBee.Device.AC; if (ac.Gateway != null) { new System.Threading.Thread(() => @@ -1374,7 +1374,7 @@ //鍙戦�佽鍙栫姸鎬佸懡浠� UserView.UserHomeView.ReadStatus(ac, () => { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI); }); } else @@ -1382,7 +1382,7 @@ //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI); } } }) @@ -1390,17 +1390,17 @@ var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.IsSelected = ac.currentSystemMode != 1; deviceTypeRowLayout.AddChidren(deviceRow); deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) => { - zbGateway = deviceUI.CommonDevice.Gateway; + zbGateway = deviceUI.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI); (send2 as Button).IsSelected = !(send2 as Button).IsSelected; deviceRow.IsSelected = (send2 as Button).IsSelected; @@ -1412,9 +1412,9 @@ { ac.Close(); } - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () => + HdlDeviceOtherLogic.Current.SendCommandDelayAction(deviceUI, () => { if (Parent == null) { @@ -1423,7 +1423,7 @@ RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); }; @@ -1433,7 +1433,7 @@ UserView.HomePage.Instance.AddChidren(acControl); UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; - acControl.Show(deviceUI, Common.Room.CurrentRoom); + acControl.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); acControl.action += (curDev, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1446,7 +1446,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1455,19 +1455,19 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } } - else if (deviceUI.CommonDevice.Type == DeviceType.WindowCoveringDevice) + else if (deviceUI.Type == DeviceType.WindowCoveringDevice) { //鍗峰笜 - var rollerShade = deviceUI.CommonDevice as ZigBee.Device.Rollershade; + var rollerShade = deviceUI as ZigBee.Device.Rollershade; if (rollerShade.Gateway != null) { new System.Threading.Thread(() => @@ -1477,7 +1477,7 @@ { UserHomeView.ReadStatus(rollerShade, () => { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI); }); } else @@ -1485,7 +1485,7 @@ //闃叉鐭椂闂村唴澶氭璇诲彇 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI); } } }) @@ -1493,8 +1493,8 @@ var deviceRow = new CategoryFunctionForWinRow(0, 35); deviceRow.Init(deviceUI); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0; deviceRow.SetRollerShadeIcon(rollerShade.WcdType); deviceTypeRowLayout.AddChidren(deviceRow); @@ -1522,7 +1522,7 @@ UserView.HomePage.Instance.AddChidren(rollerShadeControl); UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; - rollerShadeControl.Show(deviceUI, Common.Room.CurrentRoom); + rollerShadeControl.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); rollerShadeControl.action += (curDev, curRoom) => { ReFreshDeviceActionForWin(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1534,7 +1534,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceActionForWin(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1542,27 +1542,27 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } } - else if (deviceUI.CommonDevice.Type == DeviceType.DoorLock) + else if (deviceUI.Type == DeviceType.DoorLock) { var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { - var userDoorLockPage = new UserDoorLockPage(Common.Room.CurrentRoom, deviceUI); + var userDoorLockPage = new UserDoorLockPage(HdlRoomLogic.Current.CurrentRoom, deviceUI); HomePage.Instance.AddChidren(userDoorLockPage); HomePage.Instance.PageIndex += 1; userDoorLockPage.Show(); @@ -1572,7 +1572,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1580,21 +1580,21 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } - else if (deviceUI.CommonDevice.Type == DeviceType.IASZone) + else if (deviceUI.Type == DeviceType.IASZone) { var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); - deviceRow.IsSelected = (deviceUI.CommonDevice as IASZone).iASInfo?.Alarm1 == 1; + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); + deviceRow.IsSelected = (deviceUI as IASZone).iASInfo?.Alarm1 == 1; deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); @@ -1603,7 +1603,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1611,17 +1611,17 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; } } - else if (deviceUI.CommonDevice.Type == DeviceType.TemperatureSensor) + else if (deviceUI.Type == DeviceType.TemperatureSensor) { - var tempera = deviceUI.CommonDevice as TemperatureSensor; + var tempera = deviceUI as TemperatureSensor; if (tempera.Gateway != null) { new System.Threading.Thread(() => @@ -1633,11 +1633,11 @@ { if (tempera.SensorDiv == 1) { - ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI); } else if (tempera.SensorDiv == 2) { - ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI); } }); } @@ -1647,11 +1647,11 @@ { if (tempera.SensorDiv == 1) { - ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI); } else if (tempera.SensorDiv == 2) { - ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI); } } } @@ -1660,8 +1660,8 @@ var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.IsSelected = false; deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); @@ -1671,7 +1671,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1679,9 +1679,9 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1692,8 +1692,8 @@ { var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + deviceRow.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)); deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); @@ -1702,7 +1702,7 @@ var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); + detailInfo.Show(deviceUI, HdlRoomLogic.Current.CurrentRoom); detailInfo.EditAction += (curDevice, curRoom) => { ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow); @@ -1710,9 +1710,9 @@ }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1726,21 +1726,19 @@ alert.Show(); alert.ConfirmClickEvent += () => { - if (Common.Room.CurrentRoom.IsLove) + if (HdlRoomLogic.Current.CurrentRoom.IsLove) { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); + HdlRoomLogic.Current.DeleteLoveDevice(deviceUI); deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); sameTypeList.Remove(deviceUI); } else { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.CommonDevice); + HdlRoomLogic.Current.DeleteDevice(deviceUI); deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); - sameTypeList.Remove(deviceUI); - if (Common.Room.CurrentRoom.GetLoveRoom().DeviceUIList.Find((obj) => obj.FileName == deviceUI.FileName) != null) - { - Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); - } + sameTypeList.Remove(deviceUI); + + HdlRoomLogic.Current.DeleteLoveDevice(deviceUI); } if (sameTypeList.Count == 0) { @@ -1750,9 +1748,9 @@ }; var delBtn = new CommonForm.RowLayoutDeleteButton() { - Tag = deviceUI + Tag = LocalDevice.Current.GetDeviceMainKeys(deviceUI) }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) + if (HdlRoomLogic.Current.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(delBtn); delBtn.MouseUpEventHandler += delEvent; @@ -1772,38 +1770,38 @@ /// <param name="sameTypeList"></param> /// <param name="devListScrolView"></param> /// <param name="deviceRow"></param> - private void ReFreshDeviceAction(DeviceUI deviceUI, Common.Room curRoom, List<DeviceUI> sameTypeList, VerticalScrolViewLayout devListScrolView, CategoryFunctionRow deviceRow) + private void ReFreshDeviceAction(CommonDevice deviceUI, Common.Room curRoom, List<CommonDevice> sameTypeList, VerticalScrolViewLayout devListScrolView, CategoryFunctionRow deviceRow) { - if (Common.Room.CurrentRoom.IsLove) + if (HdlRoomLogic.Current.CurrentRoom.IsLove) { deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - if (Common.Room.CurrentRoom.IsCollectInRoom(deviceUI.FileName) == false) + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false) { devListScrolView.RemoveViewByTag(deviceUI); sameTypeList.Remove(deviceUI); if (sameTypeList.Count == 0) { - RefreshFunction(Common.Room.CurrentRoom); + RefreshFunction(HdlRoomLogic.Current.CurrentRoom); } } } else { - if (curRoom.Id != Common.Room.CurrentRoom.Id) + if (curRoom.Id != HdlRoomLogic.Current.CurrentRoom.Id) { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); + HdlRoomLogic.Current.DeleteDevice(deviceUI); devListScrolView.RemoveViewByTag(deviceUI); sameTypeList.Remove(deviceUI); if (sameTypeList.Count == 0) { - RefreshFunction(Common.Room.CurrentRoom); + RefreshFunction(HdlRoomLogic.Current.CurrentRoom); } } else { deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); } } } @@ -1815,38 +1813,38 @@ /// <param name="sameTypeList"></param> /// <param name="devListScrolView"></param> /// <param name="deviceRow"></param> - private void ReFreshDeviceActionForWin(DeviceUI deviceUI, Common.Room curRoom, List<DeviceUI> sameTypeList, VerticalScrolViewLayout devListScrolView, CategoryFunctionForWinRow deviceRow) + private void ReFreshDeviceActionForWin(CommonDevice deviceUI, Common.Room curRoom, List<CommonDevice> sameTypeList, VerticalScrolViewLayout devListScrolView, CategoryFunctionForWinRow deviceRow) { - if (Common.Room.CurrentRoom.IsLove) + if (HdlRoomLogic.Current.CurrentRoom.IsLove) { deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); - if (Common.Room.CurrentRoom.IsCollectInRoom(deviceUI.FileName) == false) + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); + if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false) { devListScrolView.RemoveViewByTag(deviceUI); sameTypeList.Remove(deviceUI); if (sameTypeList.Count == 0) { - RefreshFunction(Common.Room.CurrentRoom); + RefreshFunction(HdlRoomLogic.Current.CurrentRoom); } } } else { - if (curRoom.Id != Common.Room.CurrentRoom.Id) + if (curRoom.Id != HdlRoomLogic.Current.CurrentRoom.Id) { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); + HdlRoomLogic.Current.DeleteDevice(deviceUI); devListScrolView.RemoveViewByTag(deviceUI); sameTypeList.Remove(deviceUI); if (sameTypeList.Count == 0) { - RefreshFunction(Common.Room.CurrentRoom); + RefreshFunction(HdlRoomLogic.Current.CurrentRoom); } } else { deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); } } } @@ -1876,7 +1874,8 @@ functionSceneAutoBodyView.AddChidren(functionSceneBodyView); RoomButton curBtn = new RoomButton(0, 0); - foreach (var room in Common.Room.CurrentRoom.GetRoomsByCurrentFloorIdAppendLoveRoom()) + var lisrRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom(); + foreach (var room in lisrRoom) { var row = new FrameLayout() { @@ -1891,7 +1890,7 @@ roomBtn.SetTitle(room.Name); row.AddChidren(roomBtn); - if (room.Id == Common.Room.CurrentRoom.Id) + if (room.Id == HdlRoomLogic.Current.CurrentRoom.Id) { roomBtn.IsSelected = true; curBtn = roomBtn; @@ -1914,7 +1913,7 @@ sender.IsSelected = true; curBtn.IsSelected = false; curBtn = sender; - Common.Room.CurrentRoom = room; + HdlRoomLogic.Current.CurrentRoom = room; if (sceneBtn.IsSelected) { RefreshScene(room); diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs index c0f80dd..ba9b610 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs @@ -5,6 +5,7 @@ using Shared.Phone.Device.CommonForm; using Shared.Phone.Device.Room; using Shared.Phone.UserCenter; +using ZigBee.Device; using static ZigBee.Device.Scene; namespace Shared.Phone.Device.Category @@ -157,15 +158,15 @@ string devNameText = string.Empty; if (targetDevice.Type == 0) { - if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) continue; + if (targetDevice.DeviceUI == null ) continue; devImgPath = targetDevice.DeviceUI.IconPath; - devNameText = Common.LocalDevice.Current.GetDeviceEpointName(targetDevice.DeviceUI.CommonDevice); + devNameText = Common.LocalDevice.Current.GetDeviceEpointName(targetDevice.DeviceUI); var targetRow = new SceneTargetFunctionRow(13); targetRow.Init(); targetRow.SetIcon(devImgPath); targetRow.SetNameText(devNameText); - targetRow.SetZoneText(targetDevice.DeviceUI.GetZone()); + targetRow.SetZoneText(HdlRoomLogic.Current.GetRoomNameByDevice(targetDevice.DeviceUI, ",")); targetRow.SetStatuText(targetDevice.GetDeviceStatu()); targetRowLayout.AddChidren(targetRow); if (i == sceneTargetDevicesList.Count - 1) @@ -195,7 +196,7 @@ targetRow.Init(); targetRow.SetIcon(devImgPath); targetRow.SetNameText(devNameText); - targetRow.SetZoneText(targetDevice.SceneUI.GetZone()); + targetRow.SetZoneText(HdlSceneLogic.Current.GetZoneById(targetDevice.SceneUI.Id)); targetRowLayout.AddChidren(targetRow); if (i == sceneTargetDevicesList.Count - 1) { @@ -221,7 +222,7 @@ { if (targetDevice.Type == 0) { - if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) + if (targetDevice.DeviceUI == null) { return; } @@ -471,7 +472,7 @@ confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); - confirmBtn.TextID = R.MyInternationalizationString.Next; + confirmBtn.TextID = R.MyInternationalizationString.uFinish; AddChidren(confirmBtn); if (isModify) @@ -497,7 +498,7 @@ } else { - zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); + zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)}锛寋modifyRoom.Name}"); } curRoom = modifyRoom; sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); @@ -683,7 +684,7 @@ zone.ZoneAction += (selectRoom) => { curRoom = selectRoom; - zoneRow.SetTitle(selectRoom.GetZoneName()); + zoneRow.SetTitle(HdlRoomLogic.Current.GetZoneName(selectRoom)); }; }; zoneRow.ClickBtn.MouseUpEventHandler += zoneHander; @@ -873,7 +874,7 @@ var fileName = $"SceneIcon_{tradeTime}.png"; if (modifySceneUI.Name != nameRow.NameText.Text.Trim()) { - if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) + if (HdlSceneLogic.Current.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) { CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); return; @@ -919,7 +920,7 @@ if (sceneTarget.Type == 0) { - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) + if (sceneTarget.DeviceUI == null) { continue; } @@ -927,8 +928,8 @@ { Type = 0, ScenesId = 0, - DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, - Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, + DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, + Epoint = sceneTarget.DeviceUI.DeviceEpoint, TaskList = sceneTarget.TaskList, DelayTime = 0, MemberNumber = i + 1 @@ -967,15 +968,15 @@ var sceneTarget = modifySceneTargetDevicesList[i]; if (sceneTarget.Type == 0) { - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) + if (sceneTarget.DeviceUI == null) { continue; } var removeDevice = new RemoveSceneDeviceListInfo { Type = 0, - DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, - Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, + DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, + Epoint = sceneTarget.DeviceUI.DeviceEpoint, MemberNumber = sceneTarget.DelayTimeSerialNumber }; removeSceneDeviceListInfoList.Add(removeDevice); @@ -1003,15 +1004,13 @@ } sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; sceneRemoveMemberData.ScenesId = modifySceneUI.Id; - var result = await curRoom.ModifyScene(modifySceneUI, sceneRemoveMemberData, memberDataList); + var result = await HdlSceneLogic.Current.ModifyScene(modifySceneUI, sceneRemoveMemberData, memberDataList); if (result == 1) { if (modifyRoom != curRoom) { - modifyRoom.SceneUIList.Remove(modifySceneUI); - modifyRoom.SceneUIFilePathList.Remove(modifySceneUI.FileName); - curRoom.SceneUIList.Add(modifySceneUI); - curRoom.SceneUIFilePathList.Add(modifySceneUI.FileName); + modifyRoom.ListSceneId.Remove(modifySceneUI.Id); + curRoom.ListSceneId.Add(modifySceneUI.Id); modifyRoom.Save(); curRoom.Save(); } @@ -1075,7 +1074,7 @@ if (sceneTarget.Type == 0) { - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) + if (sceneTarget.DeviceUI == null) { continue; } @@ -1083,8 +1082,8 @@ { Type = 0, ScenesId = 0, - DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, - Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, + DeviceAddr = sceneTarget.DeviceUI.DeviceAddr, + Epoint = sceneTarget.DeviceUI.DeviceEpoint, TaskList = sceneTarget.TaskList, DelayTime = 0, MemberNumber = i+1 @@ -1116,7 +1115,7 @@ } } - var result = await curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList, IconPathType); + var result = await HdlSceneLogic.Current.AddScene(curRoom, nameRow.NameText.Text, imgPath, memberDataList, IconPathType); if (result == 1) { AddAction?.Invoke(); @@ -1154,7 +1153,7 @@ /// ShowSelectAction /// </summary> /// <param name="device"></param> - private void ShowSelectAction(DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void ShowSelectAction(CommonDevice device, SceneTargetDeviceUI sceneTarget) { var dialog = new FrameLayout() { @@ -1167,23 +1166,23 @@ dialog.RemoveFromParent(); }; - if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) + if (device.Type == ZigBee.Device.DeviceType.OnOffOutput) { SelectOnoffOutput(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) + else if (device.Type == ZigBee.Device.DeviceType.AirSwitch) { SelectOnoffOutput(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight) + else if (device.Type == ZigBee.Device.DeviceType.DimmableLight) { SelectDimmableLight(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) + else if (device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) { SelectWindowCoveringDevice(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) + else if (device.Type == ZigBee.Device.DeviceType.Thermostat) { SelectThermostat(dialog, device, sceneTarget); } @@ -1195,7 +1194,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectOnoffOutput(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectOnoffOutput(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -1244,7 +1243,7 @@ Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -1351,7 +1350,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectWindowCoveringDevice(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectWindowCoveringDevice(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -1400,7 +1399,7 @@ Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -1516,7 +1515,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectDimmableLight(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectDimmableLight(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -1566,7 +1565,7 @@ TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, TextAlignment = TextAlignment.CenterLeft, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -1682,7 +1681,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectThermostat(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectThermostat(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { /// 娓╁害 int tempId=0; @@ -1739,7 +1738,7 @@ TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, TextAlignment = TextAlignment.CenterLeft, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); diff --git a/ZigbeeApp/Shared/Phone/Device/Category/SelectDevice.cs b/ZigbeeApp/Shared/Phone/Device/Category/SelectDevice.cs index 77d71a7..485d479 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/SelectDevice.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/SelectDevice.cs @@ -45,7 +45,7 @@ /// <summary> /// deviceUI /// </summary> - public DeviceUI deviceUI; + public CommonDevice deviceUI; /// <summary> /// 鍔熻兘绫诲瀷 /// </summary> @@ -82,11 +82,11 @@ /// <summary> /// dList /// </summary> - private List<DeviceUI> devList; + private List<CommonDevice> devList; /// <summary> /// 鐩稿悓绫诲瀷鐨勮澶囧垪琛� /// </summary> - private Dictionary<int, List<DeviceUI>> typeDeviceDic; + private Dictionary<int, List<CommonDevice>> typeDeviceDic; /// <summary> /// 璁惧绫诲瀷鐨勫浘id /// </summary> @@ -138,7 +138,7 @@ /// </summary> private void InitData() { - typeDeviceDic = new Dictionary<int, List<DeviceUI>> { }; + typeDeviceDic = new Dictionary<int, List<CommonDevice>> { }; typeIdDic = new Dictionary<int, DeviceConcreteType> { }; } @@ -147,12 +147,12 @@ /// </summary> private void RefreshData(Common.Room room) { - devList = room.DeviceUIList; + devList = UserCenter.HdlRoomLogic.Current.GetRoomListDevice(room); typeDeviceDic.Clear(); typeIdDic.Clear(); foreach (var device in devList) { - var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device.CommonDevice); + var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); if (info.BeloneType == DeviceBeloneType.A寮�鍏� || info.BeloneType == DeviceBeloneType.A褰╃伅 || info.BeloneType == DeviceBeloneType.A鎻掑骇 || info.BeloneType == DeviceBeloneType.A鏅鸿兘绌哄紑 || info.BeloneType == DeviceBeloneType.A鐏厜 || info.BeloneType == DeviceBeloneType.A绌鸿皟 @@ -162,7 +162,7 @@ { if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false) { - var sameDevList = new List<DeviceUI> { }; + var sameDevList = new List<CommonDevice> { }; sameDevList.Add(device); typeDeviceDic[info.BeloneTextId] = sameDevList; } @@ -288,7 +288,8 @@ bodyFrameLayout.AddChidren(functionSceneBodyView); RoomButton curBtn = new RoomButton(0, 0); - foreach (var room in Common.Room.CurrentRoom.GetRoomsByFloorIdAppendLoveRoom(floorId)) + var lisrRoom = UserCenter.HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(floorId); + foreach (var room in lisrRoom) { var row = new FrameLayout() { @@ -431,7 +432,7 @@ deviceListScrolView.RemoveAll(); - var sameTypeList = new List<DeviceUI> { }; + var sameTypeList = new List<CommonDevice> { }; sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())]; foreach (var device in sameTypeList) @@ -449,7 +450,7 @@ var deviceRow = new FunctionRow(0, 35); deviceRow.Init(device.IconPath, device.OnlineIconPath, true); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(device)); deviceRow.IsSelected = true; deviceRow.HideSwitchBtn(false); deviceRow.NameBtn.BackgroundColor = ZigbeeColor.Current.GXCRedColor; @@ -497,7 +498,7 @@ /// ShowSelectAction /// </summary> /// <param name="device"></param> - private void ShowSelectAction(DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void ShowSelectAction(CommonDevice device, SceneTargetDeviceUI sceneTarget) { var dialog = new FrameLayout() { @@ -510,23 +511,23 @@ dialog.RemoveFromParent(); }; - if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) + if (device.Type == ZigBee.Device.DeviceType.OnOffOutput) { SelectOnoffOutput(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) + else if (device.Type == ZigBee.Device.DeviceType.AirSwitch) { SelectOnoffOutput(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight) + else if (device.Type == ZigBee.Device.DeviceType.DimmableLight) { SelectDimmableLight(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) + else if (device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) { SelectWindowCoveringDevice(dialog, device, sceneTarget); } - else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) + else if (device.Type == ZigBee.Device.DeviceType.Thermostat) { SelectThermostat(dialog, device, sceneTarget); } @@ -538,7 +539,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectOnoffOutput(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectOnoffOutput(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -587,7 +588,7 @@ Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -694,7 +695,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectWindowCoveringDevice(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectWindowCoveringDevice(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -743,7 +744,7 @@ Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -859,7 +860,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectDimmableLight(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectDimmableLight(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -909,7 +910,7 @@ TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, TextAlignment = TextAlignment.CenterLeft, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); @@ -1025,7 +1026,7 @@ /// <param name="dialog"></param> /// <param name="device"></param> /// <param name="sceneTarget"></param> - private void SelectThermostat(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget) + private void SelectThermostat(FrameLayout dialog, CommonDevice device, SceneTargetDeviceUI sceneTarget) { var selectFL = new FrameLayout { @@ -1075,7 +1076,7 @@ TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 16, TextAlignment = TextAlignment.CenterLeft, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice) + Text = Common.LocalDevice.Current.GetDeviceEpointName(device) }; titleFL.AddChidren(deviceName); diff --git a/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs b/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs index 69c0b29..8779c91 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs @@ -159,7 +159,7 @@ { Config.Instance.Home.CurrentFloorId = (sender as CommonForm.LeftIconButtonRow).Tag.ToString(); Config.Instance.Home.Save(false); - Common.Room.CurrentRoom.RefreshRoomListView(); + UserCenter.HdlRoomLogic.Current.RefreshRoomListView(); } RemoveView(); FloorAction?.Invoke((sender as CommonForm.LeftIconButtonRow).Tag.ToString()); diff --git a/ZigbeeApp/Shared/Phone/Device/Category/SelectScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/SelectScene.cs index fb9e247..191ddbd 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/SelectScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/SelectScene.cs @@ -203,7 +203,7 @@ RoomButton curBtn = new RoomButton(0,0); - foreach (var room in Common.Room.CurrentRoom.GetRoomsByFloorIdAppendLoveRoom(floorId)) + foreach (var room in UserCenter.HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(floorId)) { var row = new FrameLayout() { @@ -249,7 +249,7 @@ public void RefreshScene(Common.Room room) { functionSceneBodyView.RemoveAll(); - var sceneList = room.SceneUIList; + var sceneList = room.ListSceneId; if (sceneList.Count == 0) { ShowNoSceneTip(); @@ -274,8 +274,8 @@ for (int i = 0; i < sceneList.Count; i++) { - var scene = sceneList[i]; - if (currentSceneUI?.Id == scene.Id) + var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneList[i]); + if (scene == null || currentSceneUI?.Id == scene.Id) { continue; } diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/CategoryFunctionForWinRow.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/CategoryFunctionForWinRow.cs index 5560dd9..94004ab 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/CategoryFunctionForWinRow.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/CategoryFunctionForWinRow.cs @@ -1,6 +1,7 @@ 锘縰sing System; using Shared.Common; - +using ZigBee.Device; + namespace Shared.Phone.Device.CommonForm { public class CategoryFunctionForWinRow:FrameLayout @@ -82,7 +83,7 @@ /// Init /// </summary> /// <param name="device"></param> - public void Init(DeviceUI device) + public void Init(CommonDevice device) { ImageBG = new Button() { @@ -144,7 +145,7 @@ AddChidren(OpenOrUpBtn); OpenOrUpBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0); }; StopBtn = new Button @@ -159,7 +160,7 @@ AddChidren(StopBtn); StopBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2); }; CloseOrDownBtn = new Button @@ -174,7 +175,7 @@ AddChidren(CloseOrDownBtn); CloseOrDownBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1); }; var line = new Button() diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs index 9384b38..1b5cb52 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs @@ -21,7 +21,7 @@ /// <summary> /// action /// </summary> - public Action<DeviceUI,Common.Room> EditAction; + public Action<CommonDevice, Common.Room> EditAction; /// <summary> /// curRoom /// </summary> @@ -70,7 +70,7 @@ /// </summary> /// <param name="device"></param> /// <param name="room"></param> - public void Show(DeviceUI device, Common.Room room) + public void Show(CommonDevice device, Common.Room room) { Init(device); @@ -102,7 +102,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device, Common.Room room) + public void AddBodyView(CommonDevice device, Common.Room room) { bodyFrameLayout = new FrameLayout() { @@ -144,7 +144,7 @@ }; bodyFrameLayout.AddChidren(deviceIMG); - var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device.CommonDevice); + var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); var deviceTypeName = new Button() { @@ -199,7 +199,7 @@ var nameRow = new DeviceInfoEditRow(12); nameRow.Init(); nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : "); - nameRow.SetTitle(string.IsNullOrEmpty(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); + nameRow.SetTitle(string.IsNullOrEmpty(Common.LocalDevice.Current.GetDeviceEpointName(device)) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : Common.LocalDevice.Current.GetDeviceEpointName(device)); nameFL.AddChidren(nameRow); @@ -225,11 +225,11 @@ var modelRow = new DeviceInfoRow(12); modelRow.Init(); modelRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongModel)} : "); - modelRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName); + modelRow.SetTitle(string.IsNullOrEmpty(device.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.DeviceName); modelRow.HideNext(true); modelFL.AddChidren(modelRow); - if (device.CommonDevice.Type==DeviceType.OnOffOutput || device.CommonDevice.Type==DeviceType.AirSwitch) + if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch) { var typeFL = new FrameLayout { @@ -241,7 +241,7 @@ functionTypeRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionType)} : "); //functionTypeRow.SetTitle(device.CommonDevice.DfunctionType); typeFL.AddChidren(functionTypeRow); - var dfunctionType = device.CommonDevice.DfunctionType; + var dfunctionType = device.DfunctionType; //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛� string strT = string.Empty; @@ -261,7 +261,7 @@ functionTypeRow.ClickBtn.MouseUpEventHandler += (sender, e) => { - var DfunctionType = device.CommonDevice.DfunctionType; + var DfunctionType = device.DfunctionType; //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛� int nowSelectNo = 1; @@ -298,15 +298,15 @@ //璁板綍璧峰綋鍓嶉�夋嫨鐨勫姛鑳界被鍨� if (selectNo == 0) { - device.CommonDevice.DfunctionType = DeviceFunctionType.A寮�鍏�; + device.DfunctionType = DeviceFunctionType.A寮�鍏�; } else if (selectNo == 1) { - device.CommonDevice.DfunctionType = DeviceFunctionType.A鐏厜; + device.DfunctionType = DeviceFunctionType.A鐏厜; } else { - device.CommonDevice.DfunctionType = DeviceFunctionType.A鎻掑骇; + device.DfunctionType = DeviceFunctionType.A鎻掑骇; } }; }; @@ -325,7 +325,7 @@ zone.ZoneAction += (selectRoom) => { curRoom = selectRoom; - zoneRow.SetTitle(selectRoom.GetZoneName()); + zoneRow.SetTitle(HdlRoomLogic.Current.GetZoneName(selectRoom)); }; }; zoneRow.ClickBtn.MouseUpEventHandler += selectZoneEvent; @@ -340,7 +340,7 @@ { deviceIMG.UnSelectedImagePath = unSelectedImagePath; deviceIMG.SelectedImagePath = selectedImagePath; - device.CommonDevice.IsCustomizeImage = true; + device.IsCustomizeImage = true; }; }; deviceIMG.MouseUpEventHandler += selectDeviceIconEvent; @@ -350,51 +350,51 @@ try { CommonPage.Loading.Start(); - if (device.CommonDevice == null) + if (device == null) { CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain)); return; } - if (device.CommonDevice.Type == DeviceType.OnOffOutput || device.CommonDevice.Type == DeviceType.AirSwitch) + if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch) { if (device.IsCustomizeImage == false) { - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { - device.CommonDevice.IconPath = "Device/Switch.png"; + device.IconPath = "Device/Switch.png"; } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { - device.CommonDevice.IconPath = "Device/Socket1.png"; + device.IconPath = "Device/Socket1.png"; } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鐏厜) + else if (device.DfunctionType == DeviceFunctionType.A鐏厜) { - device.CommonDevice.IconPath = "Device/Light.png"; + device.IconPath = "Device/Light.png"; } } else { //鏀瑰浘鐗� - device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath; + device.IconPath = deviceIMG.UnSelectedImagePath; } } else { //鏀瑰浘鐗� - device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath; + device.IconPath = deviceIMG.UnSelectedImagePath; } bool result; new System.Threading.Thread(async () => { - result = await LocalDevice.Current.ReName(device.CommonDevice, nameRow.NameText.Text.Trim()); + result = await LocalDevice.Current.ReName(device, nameRow.NameText.Text.Trim()); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); if (result) { //鏀规埧闂� - Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, curRoom.Id); - device.CommonDevice.ReSave(); + HdlRoomLogic.Current.ChangedRoom(device, curRoom.Id); + device.ReSave(); EditAction?.Invoke(device, curRoom); RemoveFromParent(); } @@ -419,11 +419,11 @@ /// Init /// </summary> /// <param name="device"></param> - public void Init(DeviceUI device) + public void Init(CommonDevice device) { - roomName = device.GetZone(); - befRoom = Common.Room.CurrentRoom.GetRoomByDevice(device.CommonDevice); - curRoom = Common.Room.CurrentRoom.GetRoomByDevice(device.CommonDevice); + roomName = HdlRoomLogic.Current.GetRoomNameByDevice(device, "锛�"); + befRoom = HdlRoomLogic.Current.GetRoomByDevice(device); + curRoom = HdlRoomLogic.Current.GetRoomByDevice(device); } #endregion } diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs index 8fda258..ad3a44d 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs @@ -250,10 +250,14 @@ { X = Application.GetRealWidth(69), Width = Application.GetRealWidth(120), - Text = room.Temperatrue == 0 ? "--鈩�" : $"{room.Temperatrue}鈩�", + Text = "--鈩�", TextSize = 14, TextAlignment=TextAlignment.CenterLeft }; + if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) + { + temperatureText.Text = room.Temperatrue == 0 ? "0.0鈩�" : room.Temperatrue.ToString() + "鈩�"; + } roomTemperatureBackground.AddChidren(temperatureText); temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60); @@ -271,16 +275,20 @@ { X = humidityIcon.Right, Width = Application.GetRealWidth(120), - Text = room.Humidity == 0 ? "--%" : $"{room.Humidity}%", + Text = "--%", TextSize = 14, TextAlignment = TextAlignment.CenterLeft }; + if (string.IsNullOrEmpty(room.HumidityDevice) == false) + { + humidityText.Text = room.Humidity == 0 ? "0.0%" : room.Humidity.ToString() + "%"; + } roomTemperatureBackground.AddChidren(humidityText); humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60); roomTemperatureBackground.Width = (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)); if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) - { + { //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护 var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev); @@ -305,15 +313,12 @@ roomListBtn.MouseUpEventHandler += (send, e) => { CommonPage.Instance.IsDrawerLockMode = true; - var editRoom = new Device.Room.EditRoom(); - HomePage.Instance.AddChidren(editRoom); - HomePage.Instance.PageIndex += 1; - editRoom.temperDevice = this.temperDevice; - editRoom.humidDevice = this.humidDevice; - editRoom.Show(room); - editRoom.action += () => - { - action?.Invoke(); + + var form = new UserCenter.Residence.EditorRoomInforForm(); + form.AddForm(room); + form.FinishEditorEvent += (roomName2) => + { + action?.Invoke(); }; }; } diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs index 5f8edaa..9ddb9df 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs @@ -39,7 +39,7 @@ X = Application.GetRealWidth(x); Y = Application.GetRealHeight(y); Width = Application.GetRealWidth(1080); - Height = Application.GetRealHeight(446); + Height = Application.GetRealHeight(397 + 46); BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; } @@ -63,10 +63,9 @@ RemoveAll(); var sceneRowLayout = new RowLayout { - Y = Application.GetRealHeight(46), - Height = Application.GetRealHeight(446 - 46), + Height = Application.GetRealHeight(440), LineColor = ZigbeeColor.Current.GXCGrayBackgroundColor, - Tag= scene + Tag = scene }; AddChidren(sceneRowLayout); sceneRowLayout.SubViewWidth = Application.GetRealWidth(199); @@ -75,12 +74,16 @@ { X = Application.GetRealWidth(179), Width = Application.GetRealWidth(844), - Height = Application.GetRealHeight(400), + Height = Application.GetRealHeight(397), ImagePath = scene.IconPathType == 0 ? scene.IconPath : System.IO.Path.Combine(Config.Instance.FullPath, scene.IconPath), Radius = (uint)Application.GetRealHeight(17) }; - sceneRowLayout.AddChidren(sceneImg); - //sceneImg.SetViewShadow(true); + sceneRowLayout.AddChidren(sceneImg); + //闃村奖 + var btnShadow = new PicViewControl(sceneImg.Width + Application.GetRealWidth(14 * 2), sceneImg.Height + Application.GetRealHeight(43), false); + btnShadow.X = sceneImg.X - Application.GetRealWidth(14); + btnShadow.UnSelectedImagePath = "Scene/SceneShadow.png"; + sceneRowLayout.AddChidren(btnShadow); var leftFL = new FrameLayout { @@ -88,7 +91,7 @@ Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(251), Height = Application.GetRealHeight(282), - BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2, + BackgroundColor = 0xd6333333, Radius = (uint)Application.GetRealHeight(17) }; sceneRowLayout.AddChidren(leftFL); @@ -101,7 +104,7 @@ Height = Application.GetMinRealAverage(65), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png", - IsSelected = Common.Room.CurrentRoom.GetLoveRoom().SceneUIFilePathList.Contains(scene.FileName), + IsSelected = HdlRoomLogic.Current.IsCollectInRoom(scene), Tag = scene }; leftFL.AddChidren(collectionBtn); @@ -126,19 +129,19 @@ { if (room.IsLove) { - Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); + HdlSceneLogic.Current.DeleteScene(HdlRoomLogic.Current.GetLoveRoom(), scene); RemoveViewByTag(collectionBtn.Tag); } else { collectionBtn.IsSelected = !collectionBtn.IsSelected; if (collectionBtn.IsSelected) - { - Common.Room.CurrentRoom.GetLoveRoom().AddScene(scene); + { + HdlSceneLogic.Current.AddScene(HdlRoomLogic.Current.GetLoveRoom(), scene); } else { - Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); + HdlSceneLogic.Current.DeleteScene(HdlRoomLogic.Current.GetLoveRoom(), scene); } } }; @@ -174,7 +177,9 @@ BackgroundColor=ZigbeeColor.Current.GXCTextSelectedColor, }; delayBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight); - sceneRowLayout.AddLeftView(delayBtn); + sceneRowLayout.AddLeftView(delayBtn); + //鍙樻洿鎸夐挳鐨勯珮搴� + delayBtn.Height = sceneImg.Height; //缂栬緫 var settingBtn = new Device.CommonForm.RowLayoutEditButton() { @@ -196,13 +201,17 @@ { if (room.IsLove) { - sceneRowLayout.AddRightView(deleteBtn); + sceneRowLayout.AddRightView(deleteBtn); + //鍙樻洿鎸夐挳鐨勯珮搴� + deleteBtn.Height = sceneImg.Height; } else { sceneRowLayout.AddRightView(settingBtn); - sceneRowLayout.AddRightView(deleteBtn); - + sceneRowLayout.AddRightView(deleteBtn); + //鍙樻洿鎸夐挳鐨勯珮搴� + settingBtn.Height = sceneImg.Height; + deleteBtn.Height = sceneImg.Height; } } @@ -211,7 +220,7 @@ { if (room.IsLove) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); + HdlSceneLogic.Current.DeleteScene(HdlRoomLogic.Current.GetLoveRoom(), scene); RemoveFromParent(); } else @@ -230,7 +239,7 @@ //1鎴愬姛 if (removeSceneAllData.removeSceneData.Result == 1) { - room.RemoveScene(scene); + HdlSceneLogic.Current.RemoveScene(scene); //RefreshBodyView(); RemoveFromParent(); } @@ -242,8 +251,8 @@ } //2 娌℃湁璇ュ満鏅� else if (removeSceneAllData.removeSceneData.Result == 2) - { - room.RemoveScene(scene); + { + HdlSceneLogic.Current.RemoveScene(scene); //RefreshBodyView(); RemoveFromParent(); CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsNull)); @@ -271,8 +280,8 @@ if (sceneDeviceList.getSceneDeviceListInfo != null) { var deviceList = sceneDeviceList.getSceneDeviceListInfo.DeviceList; - var allDevice = Common.Room.AllRoomDeviceUIList; - var allScene = Common.Room.AllRoomSceneUIList; + var allDevice = HdlRoomLogic.Current.GetAllRoomListDevice(); + var allScene = HdlSceneLogic.Current.GetAllRoomSceneList(); if (deviceList != null && allDevice.Count != 0) { @@ -338,7 +347,7 @@ sceneView.Show(); sceneView.EditorAction = (s, r) => { - if(r.Id!=room.Id) + if (r.Id != room.Id) { RemoveFromParent(); } @@ -373,8 +382,6 @@ { scene.SceneDelayTime = t; delayTimeBtn.Text = CommonFormResouce.GetTimeString(t); - - room.ModifySceneDelayTime(scene); }; }; } @@ -424,7 +431,6 @@ scene.RemainTime = scene.SceneDelayTime; scene.SceneDelayTime = 0; - room.ModifySceneDelayTime(scene); new System.Threading.Thread(() => { while (scene.RemainTime > 0) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs index 0defd1b..f70df74 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs @@ -167,7 +167,7 @@ SetTimeByDelayTime(scene.SceneDelayTime); SetSceneNameText(scene.Name); SetIcon(scene.IconPath); - SetCollect(Common.Room.CurrentRoom.GetLoveRoom().SceneUIFilePathList.Contains(scene.FileName)); + SetCollect(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(scene)); TimeButton.MouseUpEventHandler += SetTimeEvents; CollectButton.MouseUpEventHandler += CollectionEvent; @@ -288,7 +288,6 @@ scene.RemainTime = scene.SceneDelayTime; scene.SceneDelayTime = 0; - Common.Room.CurrentRoom.ModifySceneDelayTime(scene); new System.Threading.Thread(() => { while (scene.RemainTime > 0) @@ -315,21 +314,22 @@ /// <param name="mouseEventArgs"></param> private void CollectionEvent(object sender,MouseEventArgs mouseEventArgs) { - if (Common.Room.CurrentRoom.IsLove) + var roomLove = UserCenter.HdlRoomLogic.Current.GetLoveRoom(); + if (UserCenter.HdlRoomLogic.Current.CurrentRoom.IsLove) { - Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); + UserCenter.HdlSceneLogic.Current.DeleteScene(roomLove, scene); CollectionAction?.Invoke(); } else { (sender as Button).IsSelected = !(sender as Button).IsSelected; if ((sender as Button).IsSelected) - { - Common.Room.CurrentRoom.GetLoveRoom().AddScene(scene); + { + UserCenter.HdlSceneLogic.Current.AddScene(roomLove, scene); } else - { - Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); + { + UserCenter.HdlSceneLogic.Current.DeleteScene(roomLove, scene); } } } @@ -354,8 +354,6 @@ { scene.SceneDelayTime = t; SetTimeByDelayTime(t); - - Common.Room.CurrentRoom.ModifySceneDelayTime(scene); }; } diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectFunctionView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectFunctionView.cs index ecb15c4..786f546 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectFunctionView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectFunctionView.cs @@ -123,9 +123,9 @@ var line = new Button() { X = Application.GetRealWidth(180), - Y = this.Height - 2, + Y = this.Height - 1, Width = Application.GetRealWidth(841), - Height = 2, + Height = 1, BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor, Tag = Tag }; diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs index 6f5a522..f83aec4 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SelectZone.cs @@ -30,13 +30,13 @@ { foreach (var floor in Config.Instance.Home.FloorDics) { - if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0) + if (UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floor.Key).Count > 0) { floorIds.Add(floor.Key); floorNames.Add(floor.Value); - roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); - rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); + roomNames.Add(UserCenter.HdlRoomLogic.Current.GetRoomNamesByFloorId(floor.Key)); + rooms.Add(UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floor.Key)); } } PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => @@ -49,9 +49,10 @@ } else { - for (int i = 0; i < Common.Room.Lists.Count; i++) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + for (int i = 0; i < listAllRoom.Count; i++) { - var r = Common.Room.Lists[i]; + var r = listAllRoom[i]; if (r.IsLove) { continue; diff --git a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs index 8ce3b44..ff4d23b 100755 --- a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs @@ -13,7 +13,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI,Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// 鏀惰棌鎸夐挳 @@ -22,7 +22,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -125,12 +125,12 @@ { var deviceUI = this.device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } @@ -139,10 +139,10 @@ if (common.DeviceStatusReport.AttriBute[0].AttributeId == 8) { //绐楀笜鐧惧垎姣� - var rollerShade = deviceUI.CommonDevice as Rollershade; + var rollerShade = deviceUI as Rollershade; rollerShade.DeviceStatusReport = common.DeviceStatusReport; rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}"; + StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)}"; if(rollerShade.WcdType==0) { curtainRollSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage; @@ -156,7 +156,7 @@ else if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0) { ////绐楀笜绫诲瀷 - var rollerShade = device.CommonDevice as Rollershade; + var rollerShade = device as Rollershade; rollerShade.DeviceStatusReport = common.DeviceStatusReport; rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData; rollerShade.LastDateTime = DateTime.Now; @@ -265,10 +265,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev, Shared.Common.Room room) + public void Show(CommonDevice dev, Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -276,7 +276,7 @@ AddBodyView(device); - var rollerShade = device.CommonDevice as ZigBee.Device.Rollershade; + var rollerShade = device as ZigBee.Device.Rollershade; //涓嶄笂闈炶繙绋� if (rollerShade.Gateway == null) { @@ -286,7 +286,7 @@ { UserHomeView.ReadStatus(rollerShade, () => { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device); }); } else @@ -294,11 +294,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device); } } - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -346,7 +346,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -384,7 +384,7 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold=true @@ -398,7 +398,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", + Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}", TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -414,7 +414,7 @@ itemView.AddChidren(OpenOrUpBtn); OpenOrUpBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as Rollershade).CurtainUpDownStopControl(0); + (device as Rollershade).CurtainUpDownStopControl(0); }; StopBtn = new Button @@ -429,7 +429,7 @@ itemView.AddChidren(StopBtn); StopBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as Rollershade).CurtainUpDownStopControl(2); + (device as Rollershade).CurtainUpDownStopControl(2); }; CloseOrDownBtn = new Button @@ -442,19 +442,19 @@ itemView.AddChidren(CloseOrDownBtn); CloseOrDownBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as Rollershade).CurtainUpDownStopControl(1); + (device as Rollershade).CurtainUpDownStopControl(1); }; - if ((device.CommonDevice as Rollershade).WcdType == -1) + if ((device as Rollershade).WcdType == -1) { CommonPage.Loading.Start(); new System.Threading.Thread(() => { - Rollershade.ReadWcdTypeAction(device.CommonDevice, () => + Rollershade.ReadWcdTypeAction(device, () => { Application.RunOnMainThread(() => { - SetRollerShadeIcon((device.CommonDevice as Rollershade).WcdType); + SetRollerShadeIcon((device as Rollershade).WcdType); CommonPage.Loading.Hide(); }); }); @@ -462,7 +462,7 @@ { IsBackground = true }.Start(); } - SetCurtainType(itemView, (device.CommonDevice as Rollershade).WcdType); + SetCurtainType(itemView, (device as Rollershade).WcdType); var roomBG = new Button { @@ -533,9 +533,9 @@ { sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -544,7 +544,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -558,9 +558,9 @@ { sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -569,7 +569,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -583,9 +583,9 @@ { sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2); + (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2); //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -594,7 +594,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -615,7 +615,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; @@ -708,13 +708,13 @@ curtainRollSeekBar.Width = Application.GetRealWidth(438); curtainRollSeekBar.Height = Application.GetRealHeight(576); curtainRollSeekBar.Gravity = Gravity.CenterHorizontal; - curtainRollSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage; + curtainRollSeekBar.Progress = (device as Rollershade).WcdCurrentPositionLiftPercentage; layout.AddChidren(curtainRollSeekBar); curtainRollSeekBar.IsProgressTextShow = false; curtainRollSeekBar.CurtainPaddingTop = Application.GetRealHeight(110); curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) => { - (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress); + (device as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress); }; curtainRollSeekBar.OnStartTrackingTouchEvent += (sender, e) => @@ -748,12 +748,12 @@ curtainSeekBar.Height = Application.GetRealHeight(513); curtainSeekBar.Gravity = Gravity.CenterHorizontal; curtainSeekBar.IsProgressTextShow = false; - curtainSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage; + curtainSeekBar.Progress = (device as Rollershade).WcdCurrentPositionLiftPercentage; layout.AddChidren(curtainSeekBar); curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) => { - (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainSeekBar.Progress); + (device as Rollershade).WcdGoToTiltValue(curtainSeekBar.Progress); }; curtainSeekBar.OnStartTrackingTouchEvent += (sender, e) => @@ -855,12 +855,12 @@ { if (collectionBtn.IsSelected) { - Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); collectionBtn.IsSelected = false; } else { - Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); collectionBtn.IsSelected = true; } } diff --git a/ZigbeeApp/Shared/Phone/Device/Light/AirSwitchControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/AirSwitchControl.cs index 1aa2240..7f279dc 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/AirSwitchControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/AirSwitchControl.cs @@ -20,7 +20,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -33,7 +33,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -123,20 +123,20 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.AirSwitch) + if (deviceUI.Type == DeviceType.AirSwitch) { if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as AirSwitch; + var light = deviceUI as AirSwitch; light.DeviceStatusReport = common.DeviceStatusReport; //璁板綍銆佹洿鏂扮姸鎬� if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) @@ -144,13 +144,13 @@ return; } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { SetONOFFStatu(light.OnOffStatus == 1); } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; } @@ -178,18 +178,18 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.IsOnline = common.IsOnline; //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -230,10 +230,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev, Shared.Common.Room room) + public void Show(CommonDevice dev, Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -241,7 +241,7 @@ AddBodyView(device); - var light = dev.CommonDevice as AirSwitch; + var light = dev as AirSwitch; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -251,7 +251,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -259,11 +259,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -310,7 +310,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -348,7 +348,7 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold = true @@ -362,7 +362,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -415,11 +415,11 @@ /// </summary> private void AddByFunctionType(FrameLayout itemView) { - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { AddOnOff(itemView); } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { AddPlug(itemView); } @@ -452,7 +452,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/OFF.png", SelectedImagePath = "Light/OFFSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 0 + IsSelected = (device as AirSwitch).OnOffStatus == 0 }; itemView.AddChidren(OffBtn); @@ -464,7 +464,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/ON.png", SelectedImagePath = "Light/ONSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 + IsSelected = (device as AirSwitch).OnOffStatus == 1 }; itemView.AddChidren(OnBtn); @@ -486,7 +486,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/DeskLamp.png", SelectedImagePath = "Light/DeskLampSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 + IsSelected = (device as AirSwitch).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -498,7 +498,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 + IsSelected = (device as AirSwitch).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -520,7 +520,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/Plug.png", SelectedImagePath = "Light/PlugSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 + IsSelected = (device as AirSwitch).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -532,7 +532,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 + IsSelected = (device as AirSwitch).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -566,18 +566,26 @@ zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); + } + else + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } if (switchBtn.IsSelected == true) { - (device.CommonDevice as AirSwitch).SwitchControl(1); + (device as AirSwitch).SwitchControl(1); } else { - (device.CommonDevice as AirSwitch).SwitchControl(0); + (device as AirSwitch).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -586,7 +594,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -599,10 +607,10 @@ private void ON(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(true); - (device.CommonDevice as AirSwitch).SwitchControl(1); + (device as AirSwitch).SwitchControl(1); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -611,7 +619,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -623,10 +631,10 @@ private void OFF(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(false); - (device.CommonDevice as AirSwitch).SwitchControl(0); + (device as AirSwitch).SwitchControl(0); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -635,7 +643,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -645,18 +653,20 @@ /// </summary> /// <param name="statu"></param> private void SetONOFFStatu(bool statu) - { + { + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; if (statu) { OnBtn.IsSelected = true; - OffBtn.IsSelected = false; + OffBtn.IsSelected = false; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); } else { OnBtn.IsSelected = false; - OffBtn.IsSelected = true; + OffBtn.IsSelected = true; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); } - StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; } @@ -693,12 +703,12 @@ //collection if ((sender as Button).IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); (sender as Button).IsSelected = false; } else { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); (sender as Button).IsSelected = true; } } @@ -723,7 +733,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; diff --git a/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs index f33ba2a..c0f6072 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs @@ -13,7 +13,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; ///// <summary> ///// The top view. ///// </summary> @@ -21,7 +21,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑ac /// </summary> @@ -124,20 +124,20 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) + if (deviceUI.Type == DeviceType.DimmableLight) { if (common.DeviceStatusReport.CluterID == 6) { - dimmableLight = deviceUI.CommonDevice as DimmableLight; + dimmableLight = deviceUI as DimmableLight; dimmableLight.DeviceStatusReport = common.DeviceStatusReport; if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0) { @@ -145,7 +145,7 @@ } dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; switchBtn.IsSelected = dimmableLight.OnOffStatus == 1; - StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} {UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; if (switchBtn.IsSelected == true) { @@ -162,7 +162,7 @@ //浜害 if (common.DeviceStatusReport.CluterID == 8) { - dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; + dimmableLight = deviceUI as ZigBee.Device.DimmableLight; dimmableLight.DeviceStatusReport = common.DeviceStatusReport; var attriButeList = dimmableLight.DeviceStatusReport.AttriBute; if (attriButeList == null || attriButeList.Count == 0) @@ -176,7 +176,7 @@ dimmableLight.Level = attriButeList[0].AttriButeData; dimmableLight.LastDateTime = DateTime.Now; levelSeekBar.Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100); - StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; break; } } @@ -236,11 +236,11 @@ /// </summary> /// <param name="device">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI device, Shared.Common.Room room) + public void Show(CommonDevice device, Shared.Common.Room room) { this.device = device; this.room = room; - this.dimmableLight = device.CommonDevice as ZigBee.Device.DimmableLight; + this.dimmableLight = device as ZigBee.Device.DimmableLight; //娣诲姞topview AddTopView(); @@ -256,7 +256,7 @@ //鍙戦�佽鍙栫姸鎬佸懡浠� UserView.UserHomeView.ReadStatus(dimmableLight, () => { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); }); } else @@ -264,7 +264,7 @@ //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); } } } @@ -322,7 +322,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -371,7 +371,7 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold=true @@ -385,7 +385,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = dimmableLight.Level>0?$"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" :$"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}", + Text = dimmableLight.Level>0?$"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" :$"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}", TextSize=10 }; @@ -451,7 +451,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as DimmableLight).OnOffStatus == 1 + IsSelected = (device as DimmableLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -550,7 +550,7 @@ private void Switch_MouseUpEvent(object sender, MouseEventArgs eventArgs) { switchBtn.IsSelected = !switchBtn.IsSelected; - StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; if (switchBtn.IsSelected == true) { dimmableLight.SwitchControl(1); @@ -574,7 +574,7 @@ /// </summary> private void InitCollection() { - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -593,12 +593,12 @@ //collection if ((sender as Button).IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); (sender as Button).IsSelected = false; } else - { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + { + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); (sender as Button).IsSelected = true; } } diff --git a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs index 8e5497c..b08c627 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs @@ -20,7 +20,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -33,7 +33,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -115,20 +115,20 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) + if (deviceUI.Type == DeviceType.OnOffOutput) { if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; light.DeviceStatusReport = common.DeviceStatusReport; //璁板綍銆佹洿鏂扮姸鎬� if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) @@ -137,7 +137,7 @@ } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); light.LastDateTime = DateTime.Now; } } @@ -156,18 +156,17 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - deviceUI.CommonDevice.IsOnline = common.IsOnline; - //deviceIMG.IsSelected = switchBtn.IsSelected = deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -208,10 +207,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev,Shared.Common.Room room) + public void Show(CommonDevice dev,Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -219,7 +218,7 @@ AddBodyView(device); - var light = dev.CommonDevice as ToggleLight; + var light = dev as ToggleLight; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -229,7 +228,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -237,11 +236,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - if(Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -289,7 +288,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -327,7 +326,7 @@ Width=Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize=15, IsBold=true @@ -341,8 +340,8 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text= $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", - TextSize =10 + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), + TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -355,7 +354,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/DeskLamp.png", SelectedImagePath = "Light/DeskLampSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -367,7 +366,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -440,18 +439,26 @@ zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); + } + else + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } if (switchBtn.IsSelected == true) { - (device.CommonDevice as ToggleLight).SwitchControl(1); + (device as ToggleLight).SwitchControl(1); } else { - (device.CommonDevice as ToggleLight).SwitchControl(0); + (device as ToggleLight).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if(Parent==null) { @@ -460,7 +467,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand==false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -500,12 +507,12 @@ //collection if ((sender as Button).IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); (sender as Button).IsSelected = false; } else - { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + { + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); (sender as Button).IsSelected = true; } } @@ -530,7 +537,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; diff --git a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs index bbc4894..9baac28 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs @@ -20,7 +20,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -33,7 +33,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -123,20 +123,20 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) + if (deviceUI.Type == DeviceType.OnOffOutput) { if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; light.DeviceStatusReport = common.DeviceStatusReport; //璁板綍銆佹洿鏂扮姸鎬� if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) @@ -144,13 +144,13 @@ return; } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { SetONOFFStatu(light.OnOffStatus == 1); } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; } @@ -178,18 +178,18 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.IsOnline = common.IsOnline; //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -230,10 +230,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev, Shared.Common.Room room) + public void Show(CommonDevice dev, Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -241,7 +241,7 @@ AddBodyView(device); - var light = dev.CommonDevice as ToggleLight; + var light = dev as ToggleLight; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -251,7 +251,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -259,11 +259,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - if(Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -310,7 +310,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -348,7 +348,7 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold=true @@ -362,7 +362,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -415,11 +415,11 @@ /// </summary> private void AddByFunctionType(FrameLayout itemView) { - if(device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if(device.DfunctionType == DeviceFunctionType.A寮�鍏�) { AddOnOff(itemView); } - else if(device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if(device.DfunctionType == DeviceFunctionType.A鎻掑骇) { AddPlug(itemView); } @@ -452,7 +452,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/OFF.png", SelectedImagePath = "Light/OFFSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 0 + IsSelected = (device as ToggleLight).OnOffStatus == 0 }; itemView.AddChidren(OffBtn); @@ -464,7 +464,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/ON.png", SelectedImagePath = "Light/ONSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(OnBtn); @@ -486,7 +486,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/DeskLamp.png", SelectedImagePath = "Light/DeskLampSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -498,7 +498,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -520,7 +520,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/Plug.png", SelectedImagePath = "Light/PlugSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -532,7 +532,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -565,19 +565,26 @@ sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; - deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; - - if (switchBtn.IsSelected == true) + deviceIMG.IsSelected = !deviceIMG.IsSelected; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) { - (device.CommonDevice as ToggleLight).SwitchControl(1); + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); } else { - (device.CommonDevice as ToggleLight).SwitchControl(0); + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } + if (switchBtn.IsSelected == true) + { + (device as ToggleLight).SwitchControl(1); + } + else + { + (device as ToggleLight).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -586,7 +593,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -599,10 +606,10 @@ private void ON(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(true); - (device.CommonDevice as ToggleLight).SwitchControl(1); + (device as ToggleLight).SwitchControl(1); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -611,7 +618,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -623,10 +630,10 @@ private void OFF(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(false); - (device.CommonDevice as ToggleLight).SwitchControl(0); + (device as ToggleLight).SwitchControl(0); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -635,7 +642,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -645,18 +652,20 @@ /// </summary> /// <param name="statu"></param> private void SetONOFFStatu(bool statu) - { + { + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; if (statu) { OnBtn.IsSelected = true; OffBtn.IsSelected = false; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); } else { OnBtn.IsSelected = false; - OffBtn.IsSelected = true; + OffBtn.IsSelected = true; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); } - StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; } @@ -693,12 +702,12 @@ //collection if ((sender as Button).IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); (sender as Button).IsSelected = false; } else { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); (sender as Button).IsSelected = true; } } @@ -723,7 +732,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; diff --git a/ZigbeeApp/Shared/Phone/Device/Light/PlugControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/PlugControl.cs index c03683d..6ef1e93 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/PlugControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/PlugControl.cs @@ -21,7 +21,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -34,7 +34,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -116,20 +116,20 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) + if (deviceUI.Type == DeviceType.OnOffOutput) { if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; light.DeviceStatusReport = common.DeviceStatusReport; //璁板綍銆佹洿鏂扮姸鎬� if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) @@ -138,7 +138,7 @@ } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); light.LastDateTime = DateTime.Now; } } @@ -157,18 +157,18 @@ { var deviceUI = device; //璁惧涓虹┖ - if (deviceUI.CommonDevice == null) + if (deviceUI == null) { return; } //鏄惁涓哄綋鍓嶈澶� - if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) + if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) { return; } - deviceUI.CommonDevice.IsOnline = common.IsOnline; + deviceUI.IsOnline = common.IsOnline; //deviceIMG.IsSelected = switchBtn.IsSelected = deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -209,10 +209,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev, Shared.Common.Room room) + public void Show(CommonDevice dev, Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -220,7 +220,7 @@ AddBodyView(device); - var light = dev.CommonDevice as ToggleLight; + var light = dev as ToggleLight; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -230,7 +230,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -238,11 +238,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -289,7 +289,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -327,7 +327,7 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15, IsBold=true @@ -341,7 +341,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -354,7 +354,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/Plug.png", SelectedImagePath = "Light/PlugSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -366,7 +366,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -438,18 +438,26 @@ sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; - deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; + deviceIMG.IsSelected = !deviceIMG.IsSelected; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); + } + else + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } if (switchBtn.IsSelected == true) { - (device.CommonDevice as ToggleLight).SwitchControl(1); + (device as ToggleLight).SwitchControl(1); } else { - (device.CommonDevice as ToggleLight).SwitchControl(0); + (device as ToggleLight).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -458,7 +466,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -498,12 +506,12 @@ //collection if ((sender as Button).IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); + UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); (sender as Button).IsSelected = false; } else - { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); + { + UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); (sender as Button).IsSelected = true; } } @@ -528,7 +536,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs index 2f34fb8..12402f0 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs @@ -102,11 +102,12 @@ Y = Application.GetRealHeight(92), UnSelectedImagePath = "ZigeeLogic/drop-down.png", }; - topRowLayout.AddChidren(dropdown); + topRowLayout.AddChidren(dropdown); #endregion - + ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -283,7 +284,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -349,7 +350,7 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - SceneView(room.SceneUIList); + SceneView(room.ListSceneId); } @@ -367,7 +368,7 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - SceneView(room.SceneUIList); + SceneView(room.ListSceneId); }; roomnameBtn.MouseUpEventHandler += roomclick; roombjBtn.MouseUpEventHandler += roomclick; @@ -378,11 +379,16 @@ /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉� /// </summary> /// <param name="scenelist"></param> - void SceneView(List<SceneUI>scenelist) + void SceneView(List<int>scenelist) { middle.RemoveAll(); - foreach (var scene in scenelist) + foreach (var sceneId in scenelist) { + var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); + if (scene == null) + { + continue; + } var sceneFramelayout = new FrameLayout { Height = Application.GetRealHeight(160), diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs index 6a87aa5..f0fe357 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs @@ -105,12 +105,13 @@ Y = Application.GetRealHeight(92), UnSelectedImagePath = "ZigeeLogic/drop-down.png", }; - topRowLayout.AddChidren(dropdown); - + topRowLayout.AddChidren(dropdown); + #endregion - + ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -264,7 +265,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -330,14 +331,15 @@ roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -371,14 +373,15 @@ roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) - { - if (device.CommonDevice == null) + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) + { + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -409,34 +412,34 @@ /// 鍔犺浇璇ュ尯鍩熸墍鏈夎澶囪鍥炬柟娉� /// </summary>0 /// <param name="devicelist">Devicelist.</param> - void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); #region ------鎺掑垪璁惧绫诲瀷------ ///鏆傛椂闅愯棌鐏厜鍜岀獥甯樿澶� - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone || device.CommonDevice.Type == DeviceType.TemperatureSensor); + var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor); if (iASZonejosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); } - var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch); + var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch); if (onOffSwitchjson != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); } - var doorLock = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DoorLock); + var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock); if (doorLock != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); @@ -571,14 +574,14 @@ /// </summary> /// <param name="deviceTypelist">Device typelist.</param> /// <param name="devicelist">璁惧鍒楄〃</param> - void ConditionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + void ConditionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { - if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) { continue; } @@ -623,14 +626,14 @@ var devicename = new Button { - Text = common.CommonDevice.DeviceEpointName, + Text = common.DeviceEpointName, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicAddColor, TextSize = 14, }; deviceRow.AddChidren(devicename); - switch (common.CommonDevice.Type) + switch (common.Type) { case DeviceType.OnOffOutput: { @@ -640,7 +643,7 @@ break; case DeviceType.IASZone: { - var iASZonedevice = common.CommonDevice as IASZone; + var iASZonedevice = common as IASZone; if (iASZonedevice.DeviceID != 1026) { break; @@ -653,7 +656,7 @@ break; case DeviceType.TemperatureSensor: { - var temperatureSensor = common.CommonDevice as TemperatureSensor; + var temperatureSensor = common as TemperatureSensor; if (temperatureSensor.SensorDiv == 1) { deviceIconBtn.UnSelectedImagePath = $"ZigeeLogic/temperature.png"; @@ -693,7 +696,7 @@ devicename.IsSelected = true; var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); - CurrentDeviceView(flMain, common.CommonDevice, false); + CurrentDeviceView(flMain, common, false); }; deviceFramelayout.MouseUpEventHandler += devicclick; bjFramelayout.MouseUpEventHandler += devicclick; diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs index 1344c2a..e48fe6c 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs @@ -107,7 +107,8 @@ ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -266,7 +267,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -331,14 +332,15 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -370,14 +372,15 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -408,29 +411,29 @@ /// <summary> ///鍔犺浇璇ュ尯鍩熸墍鏈夎澶囩殑瑙嗗浘鏂规硶 /// </summary> - void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); #region ------鎺掑垪璁惧绫诲瀷------ - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat); + var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat); if (ac != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); } - var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch); + var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch); if (airSwitch != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); @@ -553,13 +556,13 @@ /// 鍔犺浇璇ョ被鍨嬭澶囪鍥炬柟娉� /// </summary> /// <param name="devicelist">璁惧鍒楄〃</param> - void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + void ActionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { - if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) { continue; } @@ -603,14 +606,14 @@ var devicename = new Button { - Text = common.CommonDevice.DeviceEpointName, + Text = common.DeviceEpointName, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicAddColor, TextSize = 14, }; deviceRow.AddChidren(devicename); - switch (common.CommonDevice.Type) + switch (common.Type) { case DeviceType.OnOffOutput: @@ -660,7 +663,7 @@ var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); - CurrentDeviceStateView(flMain, common.CommonDevice, false); + CurrentDeviceStateView(flMain, common, false); }; deviceFramelayout.MouseUpEventHandler += devicclick; bjFramelayout.MouseUpEventHandler += devicclick; diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddScene.cs index 48def34..0aa4040 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddScene.cs @@ -104,7 +104,8 @@ #endregion ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -279,7 +280,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -346,7 +347,7 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - SceneView(room.SceneUIList); + SceneView(room.ListSceneId); } @@ -365,7 +366,7 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - SceneView(room.SceneUIList); + SceneView(room.ListSceneId); }; roomnameBtn.MouseUpEventHandler += roomclick; roombjBtn.MouseUpEventHandler += roomclick; @@ -376,11 +377,16 @@ /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉� /// </summary> /// <param name="scenelist"></param> - void SceneView(List<SceneUI> scenelist) + void SceneView(List<int> scenelist) { - middle.RemoveAll(); - foreach (var scene in scenelist) + middle.RemoveAll(); + foreach (var sceneId in scenelist) { + var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); + if (scene == null) + { + continue; + } var sceneFramelayout = new FrameLayout { Height = Application.GetRealHeight(160), diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs index 1642b5c..b6b4f84 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs @@ -865,7 +865,7 @@ { //鍦ㄦ湰鍦版煡鎵捐鍦烘櫙; - var sceneinof = Common.Room.AllRoomSceneUIList.Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); }); + var sceneinof = UserCenter.HdlSceneLogic.Current.GetAllRoomSceneList().Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); }); //鏈湴娌℃湁瀛樺湪; if (sceneinof == null) { @@ -919,7 +919,7 @@ actionsrowLayout.AddChidren(btnregionname); /////閫氳繃璁惧鎵惧埌鍖哄煙(鎴块棿)鍚嶇О Common.Room room = new Common.Room(); - btnregionname.Text = room.GetRoomNameBySceneId(sceneinof.Id); + btnregionname.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameBySceneId(sceneinof.Id); //Send.RoomNmae(btnregionname, deviceinof); diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs index 4be4e81..1bb7ea7 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs @@ -1532,7 +1532,7 @@ case 2: { //鍦ㄦ湰鍦版煡鎵捐鍦烘櫙; - var sceneinof = Common.Room.AllRoomSceneUIList.Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); }); + var sceneinof = UserCenter.HdlSceneLogic.Current.GetAllRoomSceneList().Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); }); //鏈湴娌℃湁瀛樺湪; if (sceneinof == null) { @@ -1583,7 +1583,7 @@ actionsrowLayout.AddChidren(btnregionname); /////閫氳繃璁惧鎵惧埌鍖哄煙(鎴块棿)鍚嶇О Common.Room room = new Common.Room(); - btnregionname.Text = room.GetRoomNameBySceneId(sceneinof.Id); + btnregionname.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameBySceneId(sceneinof.Id); //Send.RoomNmae(btnregionname, deviceinof); diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs index e3d9fca..7ff994e 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs @@ -107,7 +107,8 @@ ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -264,7 +265,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -329,14 +330,15 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -365,15 +367,16 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; - roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + roomnameBtn.IsSelected = true; + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -402,29 +405,29 @@ /// <summary> ///鍔犺浇璇ュ尯鍩熸墍鏈夎澶囩殑瑙嗗浘鏂规硶 /// </summary> - void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); #region ------鎺掑垪璁惧绫诲瀷------ - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat); + var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat); if (ac != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); } - var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch); + var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch); if (airSwitch != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); @@ -547,13 +550,12 @@ /// 鍔犺浇璇ョ被鍨嬭澶囪鍥炬柟娉� /// </summary> /// <param name="devicelist">璁惧鍒楄〃</param> - void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + void ActionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { - - if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) { continue; } @@ -597,14 +599,14 @@ var devicename = new Button { - Text = common.CommonDevice.DeviceEpointName, + Text = common.DeviceEpointName, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicAddColor, TextSize = 14, }; deviceRow.AddChidren(devicename); - switch (common.CommonDevice.Type) + switch (common.Type) { case DeviceType.OnOffOutput: @@ -654,7 +656,7 @@ var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); - CurrentDeviceStateView(flMain, common.CommonDevice, false); + CurrentDeviceStateView(flMain, common, false); }; deviceFramelayout.MouseUpEventHandler += devicclick; bjFramelayout.MouseUpEventHandler += devicclick; diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs index ef0c136..0ba7ad3 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs @@ -722,7 +722,7 @@ public static void RoomNmae(Button btnregionname, CommonDevice device) { var room = new Common.Room(); - btnregionname.Text = room.GetRoomNameByDevice(device); + btnregionname.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device); } /// <summary> /// 鎵惧嚭妤煎眰鎵�鏈夋埧闂� @@ -731,7 +731,7 @@ /// <returns></returns> public static List<Common.Room> GetRoomList(string floorId) { - return Common.Room.Lists.FindAll((obj) => obj.FloorId == floorId); + return UserCenter.HdlRoomLogic.Current.GetAllListRooms().FindAll((obj) => obj.FloorId == floorId); //var list1 = new List<Common.Room>(); /////鎵惧埌鏌愭ゼ灞傛埧闂村垪琛紱 //var list = Common.Room.Lists.FindAll((obj) => obj.FloorId == floorId); diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs b/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs index 0552373..14b9580 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs @@ -107,7 +107,8 @@ ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -265,7 +266,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -325,15 +326,16 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; - roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + roomnameBtn.IsSelected = true; + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -364,15 +366,16 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; - roomnameBtn.IsSelected = true; - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + roomnameBtn.IsSelected = true; + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -403,29 +406,29 @@ /// <summary> ///鍔犺浇璇ュ尯鍩熸墍鏈夎澶囩殑瑙嗗浘鏂规硶 /// </summary> - void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); #region ------鎺掑垪璁惧绫诲瀷------ - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat); + var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat); if (ac != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); } - var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch); + var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch); if (airSwitch != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); @@ -548,13 +551,13 @@ /// 鍔犺浇璇ョ被鍨嬭澶囪鍥炬柟娉� /// </summary> /// <param name="devicelist">璁惧鍒楄〃</param> - void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + void ActionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { - if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) { continue; } @@ -598,14 +601,14 @@ var devicename = new Button { - Text = common.CommonDevice.DeviceEpointName, + Text = common.DeviceEpointName, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicAddColor, TextSize = 14, }; deviceRow.AddChidren(devicename); - switch (common.CommonDevice.Type) + switch (common.Type) { case DeviceType.OnOffOutput: @@ -655,7 +658,7 @@ var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); - CurrentDeviceStateView(flMain, common.CommonDevice, false); + CurrentDeviceStateView(flMain, common, false); }; deviceFramelayout.MouseUpEventHandler += devicclick; bjFramelayout.MouseUpEventHandler += devicclick; diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs index 75fd4f9..686050c 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs @@ -107,7 +107,8 @@ #endregion ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 - if (Common.Room.Lists.Count == 0) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count == 0) { return; } @@ -262,7 +263,7 @@ dropdown.Visible = false; if (Config.Instance.Home.FloorDics.Count == 0) { - roomlists.AddRange(Common.Room.Lists); + roomlists.AddRange(listAllRoom); } else { @@ -325,16 +326,17 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; - roomnameBtn.IsSelected = true; - - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + roomnameBtn.IsSelected = true; + + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -367,16 +369,17 @@ roomTextButton.IsSelected = false; roomTextButton = roomnameBtn; - roomnameBtn.IsSelected = true; - - var list = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + roomnameBtn.IsSelected = true; + + var list = new List<CommonDevice>(); + foreach (var deviceKeys in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (!deviceTypeList.Contains(device.CommonDevice.Type)) + if (!deviceTypeList.Contains(device.Type)) { continue; } @@ -407,34 +410,34 @@ /// 鍔犺浇璇ュ尯鍩熸墍鏈夎澶囪鍥炬柟娉� /// </summary>0 /// <param name="devicelist">Devicelist.</param> - void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); #region ------鎺掑垪璁惧绫诲瀷------ ///鏆傛椂闅愯棌鐏厜鍜岀獥甯樿澶� - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone); + var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone); if (iASZonejosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); } - var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch); + var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch); if (onOffSwitchjson != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); } - var doorLock = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DoorLock); + var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock); if (doorLock != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); @@ -568,20 +571,20 @@ /// </summary> /// <param name="deviceTypelist">Device typelist.</param> /// <param name="devicelist">璁惧鍒楄〃</param> - void ConditionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + void ConditionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { - if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) { continue; } - if (common.CommonDevice.Type == DeviceType.IASZone) + if (common.Type == DeviceType.IASZone) { - var iASZonedevice = common.CommonDevice as IASZone; + var iASZonedevice = common as IASZone; if (iASZonedevice.DeviceID != 1026 || iASZonedevice.IasDeviceType != 13) { continue; @@ -627,14 +630,14 @@ var devicename = new Button { - Text = common.CommonDevice.DeviceEpointName, + Text = common.DeviceEpointName, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, SelectedTextColor = ZigbeeColor.Current.LogicAddColor, TextSize = 14, }; deviceRow.AddChidren(devicename); - switch (common.CommonDevice.Type) + switch (common.Type) { case DeviceType.OnOffOutput: { @@ -644,7 +647,7 @@ break; case DeviceType.IASZone: { - var iASZonedevice = common.CommonDevice as IASZone; + var iASZonedevice = common as IASZone; if (iASZonedevice.DeviceID != 1026) { break; @@ -682,7 +685,7 @@ devicename.IsSelected = true; var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); - CurrentDeviceView(flMain, common.CommonDevice, false); + CurrentDeviceView(flMain, common, false); }; deviceFramelayout.MouseUpEventHandler += devicclick; bjFramelayout.MouseUpEventHandler += devicclick; diff --git a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs index d7d3742..e5f57fc 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs @@ -308,7 +308,7 @@ { infoFL.AddChidren(floorRow); } - floorRow.SetTitle(room.FloorName); + floorRow.SetTitle(HdlResidenceLogic.Current.GetFloorNameById(room.FloorId)); floorRow.ClickBtn.MouseUpEventHandler += (sender, e) => { if (Config.Instance.Home.FloorDics != null) @@ -324,7 +324,7 @@ PickerView.Show(floorNames, (index) => { room.FloorId = floorIds[index]; - floorRow.SetTitle(room.FloorName); + floorRow.SetTitle(HdlResidenceLogic.Current.GetFloorNameById(room.FloorId)); }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); } }; diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs index 82a4850..89fc274 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs @@ -120,7 +120,7 @@ devRow.Init(); devRow.SetIcon(device.IconPath); devRow.SetName(Common.LocalDevice.Current.GetDeviceEpointName(device)); - devRow.SetZone(Common.Room.CurrentRoom.GetRoomNameByDevice(device)); + devRow.SetZone(UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device)); if (i == deviceList.Count - 1) { devRow.HideLine(true); diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs index 3fa6ec0..afd3ceb 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs @@ -149,13 +149,13 @@ try { - if (Common.Room.Lists.Count <= 1) + if (UserCenter.HdlRoomLogic.Current.GetAllListRooms().Count <= 1) { return; } var roomScrolView = new VerticalScrolViewLayout { }; bodyFrameLayout.AddChidren(roomScrolView); - var roomList = Common.Room.CurrentRoom.GetRoomsByFloorId(floorId); + var roomList = UserCenter.HdlRoomLogic.Current.GetRoomsByFloorId(floorId); if (roomList == null || roomList.Count == 0) { itemView = new FrameLayout() @@ -214,7 +214,7 @@ return; } CommonPage.Instance.CloseLeftMenu(); - Common.Room.CurrentRoom = room; + UserCenter.HdlRoomLogic.Current.CurrentRoom = room; Config.Instance.Home.CurrentFloorId = room.FloorId; UserPage.Instance.Fresh(); }; diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs index d47fa9d..60d6d8f 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs @@ -116,7 +116,7 @@ devRow.Init(); devRow.SetIcon(device.IconPath); devRow.SetName(Common.LocalDevice.Current.GetDeviceEpointName(device)); - devRow.SetZone(Common.Room.CurrentRoom.GetRoomNameByDevice(device)); + devRow.SetZone(UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device)); if (i == deviceList.Count - 1) { devRow.HideLine(true); diff --git a/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs index 6916f59..67b09b3 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs @@ -21,19 +21,6 @@ private TopFrameLayout top; private Button selectAllBtn; - private FrameLayout itemView; - /// <summary> - /// low_High - /// </summary> - private const int low_High = 127; - /// <summary> - /// 鍔熻兘 - /// </summary> - private ButtonLineForm functionBtn; - /// <summary> - /// 鍦烘櫙 - /// </summary> - private ButtonLineForm sceneBtn; /// <summary> /// 涓儴鑳屾櫙bodyView /// </summary> @@ -61,7 +48,7 @@ /// <summary> /// dList /// </summary> - private List<DeviceUI> devList; + private List<CommonDevice> devList; /// <summary> /// sceneList /// </summary> @@ -70,11 +57,15 @@ /// <summary> /// 鐩稿悓绫诲瀷鐨勮澶囧垪琛� /// </summary> - private Dictionary<int ,List<DeviceUI>> typeDeviceDic; + private Dictionary<int ,List<CommonDevice>> typeDeviceDic; /// <summary> /// 璁惧绫诲瀷鐨勫浘id /// </summary> private Dictionary<int, DeviceConcreteType> typeIdDic; + /// <summary> + /// 褰撳墠閫夋嫨鐨勫垎鏀� 1:鍦烘櫙 2:鍔熻兘 + /// </summary> + private int NowSelectIndex = 1; #endregion @@ -102,7 +93,7 @@ /// </summary> private void InitData() { - typeDeviceDic = new Dictionary<int, List<DeviceUI>> { }; + typeDeviceDic = new Dictionary<int, List<CommonDevice>> { }; typeIdDic = new Dictionary<int, DeviceConcreteType> { }; RefreshData(); @@ -113,8 +104,8 @@ /// </summary> private void RefreshData() { - devList = Shared.Common.Room.CurrentRoom.GetUnalloctedDeviceUIs(); - sceneList = Shared.Common.Room.CurrentRoom.GetUnalloctedScenes(); + devList = UserCenter.HdlRoomLogic.Current.GetUnalloctedDevice(); + sceneList = UserCenter.HdlSceneLogic.Current.GetUnalloctedScenes(); typeDeviceDic.Clear(); typeIdDic.Clear(); if (devList == null) @@ -123,10 +114,10 @@ } foreach (var device in devList) { - var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device?.CommonDevice); + var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false) { - var sameDevList = new List<DeviceUI> { }; + var sameDevList = new List<CommonDevice> { }; sameDevList.Add(device); typeDeviceDic[info.BeloneTextId] = sameDevList; } @@ -137,15 +128,6 @@ typeIdDic[info.BeloneTextId] = info.ConcreteType; } } - - ///// <summary> - ///// RefreshView - ///// </summary> - //public void RefreshView() - //{ - // InitData(); - // RefreshBodyView(); - //} #region Add____________________________________ @@ -177,68 +159,27 @@ }; AddChidren(bodyFrameLayout); - var functionSceneBG = new FrameLayout() - { - Height = Application.GetRealHeight(low_High), - BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor + //鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + var btnSceneFunctionSwitch = new UserCenter.SceneFunctionSwitchControl(); + btnSceneFunctionSwitch.Y = Application.GetRealHeight(43); + bodyFrameLayout.AddChidren(btnSceneFunctionSwitch); + btnSceneFunctionSwitch.SelectTabEvent += (index) => + { + this.NowSelectIndex = index; + this.RefreshBodyView(); }; - bodyFrameLayout.AddChidren(functionSceneBG); - - //鍦烘櫙 - sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left, 43); - functionSceneBG.AddChidren(sceneBtn); - sceneBtn.Init(); - sceneBtn.SetTitle(R.MyInternationalizationString.Scence); - sceneBtn.IsSelected = true; - - //鍔熻兘 - functionBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 43); - functionSceneBG.AddChidren(functionBtn); - functionBtn.Init(); - functionBtn.SetTitle(R.MyInternationalizationString.Function); - functionBtn.IsSelected = false; - functionBtn.X = sceneBtn.Right; - - //閫夋嫨鍔熻兘鍒嗘爮 - functionBtn.NameBtn.MouseUpEventHandler += FunctionBtn_MouseUpEventHandler; - //閫夋嫨鍦烘櫙鍒嗘爮 - sceneBtn.NameBtn.MouseUpEventHandler += SceneBtn_MouseUpEventHandler; //鍔熻兘鍜屽満鏅痓odyView functionSceneBodyView = new FrameLayout() { - Y= Application.GetRealHeight(127), + Y = Application.GetRealHeight(127), Height = Application.GetRealHeight(1607), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor }; bodyFrameLayout.AddChidren(functionSceneBodyView); - RefreshBodyView(); - - } - - /// <summary> - /// 閫夋嫨鍔熻兘鍒嗘爮 - /// </summary> - /// <param name="sender">Sender.</param> - /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> - private void FunctionBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) - { - functionBtn.IsSelected = true; - sceneBtn.IsSelected = false; - RefreshBodyView(); - } - - /// <summary> - /// 閫夋嫨鍦烘櫙鍒嗘爮 - /// </summary> - /// <param name="sender">Sender.</param> - /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> - private void SceneBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) - { - functionBtn.IsSelected = false; - sceneBtn.IsSelected = true; - RefreshBodyView(); + //寮�濮嬪垵濮嬪寲鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + btnSceneFunctionSwitch.InitControl(); } #endregion @@ -251,11 +192,11 @@ { functionSceneBodyView.RemoveAll(); - if (functionBtn.IsSelected) + if (this.NowSelectIndex == 2) { ShowFunction(); } - else if (sceneBtn.IsSelected) + else if (this.NowSelectIndex == 1) { ShowScene(); } @@ -363,8 +304,8 @@ deviceListScrolView.RemoveAll(); - var sameTypeList = new List<DeviceUI> { }; - var selectedList = new List<DeviceUI> { }; + var sameTypeList = new List<CommonDevice> { }; + var selectedList = new List<CommonDevice> { }; sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())]; foreach (var deviceUI in sameTypeList) @@ -378,7 +319,7 @@ var deviceRow = new SelectFunctionView(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice)); + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); deviceTypeRowLayout.AddChidren(deviceRow); EventHandler<MouseEventArgs> eventHandler = (sender, e) => @@ -474,7 +415,7 @@ { foreach (var d in selectedList) { - r.AddDevice(d.CommonDevice, true); + UserCenter.HdlRoomLogic.Current.AddDevice(r, d, true); deviceListScrolView.RemoveViewByTag(d); } @@ -539,7 +480,7 @@ { var sceneScrolView = new VerticalScrolViewLayout { - Y = Application.GetRealHeight(22), + Y = Application.GetRealHeight(81), Height=Application.GetRealHeight(1405-22) }; functionSceneBodyView.AddChidren(sceneScrolView); @@ -548,7 +489,7 @@ var sceneFL = new FrameLayout() { Width = Application.GetRealWidth(CommonFormResouce.AppRealWidth), - Height = Application.GetRealHeight(397 + 58), + Height = Application.GetRealHeight(397 + 46), Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, Tag = sceneUI, @@ -559,18 +500,23 @@ var sceneImg = new ImageView() { X = Application.GetRealWidth(179), - Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(844), Height = Application.GetRealHeight(397), ImagePath = sceneUI.IconPath, Radius = (uint)Application.GetRealHeight(17) }; - sceneFL.AddChidren(sceneImg); + sceneFL.AddChidren(sceneImg); + + //闃村奖 + var btnShadow = new UserCenter.PicViewControl(sceneImg.Width + Application.GetRealWidth(14 * 2), sceneImg.Height + Application.GetRealHeight(43), false); + btnShadow.X = sceneImg.X - Application.GetRealWidth(14); + btnShadow.UnSelectedImagePath = "Scene/SceneShadow.png"; + sceneFL.AddChidren(btnShadow); var selectedBtn = new Button { X = Application.GetRealWidth(919), - Y = Application.GetRealHeight(92), + Y = Application.GetRealHeight(45), Width = Application.GetMinRealAverage(60), Height = Application.GetMinRealAverage(60), UnSelectedImagePath = "Room/ItemUnSelected.png", @@ -581,10 +527,11 @@ var leftFL = new FrameLayout { X = Application.GetRealWidth(CommonFormResouce.X_Left), - Y = Application.GetRealHeight(58 + 58), + Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(251), Height = Application.GetRealHeight(282), - BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2 + BackgroundColor = 0xd6333333, + Radius = (uint)Application.GetRealHeight(17) }; sceneFL.AddChidren(leftFL); @@ -705,7 +652,7 @@ { foreach (var s in selectedList) { - r.AddScene(s); + UserCenter.HdlSceneLogic.Current.AddScene(r, s); sceneScrolView.RemoveViewByTag(s); } RefreshData(); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/AccountOption.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/AccountOption.cs index 368d3c0..4ea33c1 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/AccountOption.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/AccountOption.cs @@ -7,8 +7,10 @@ /// <summary> /// 璐﹀彿璁剧疆淇℃伅 /// </summary> - public class AccountOption + public class AccountOptionClass { + #region 鈻� 鍙橀噺澹版槑___________________________ + /// <summary> /// 鏄惁浣跨敤鎸囩汗楠岃瘉 /// </summary> @@ -25,10 +27,6 @@ /// 鏄惁浣跨敤杩滅▼寮�閿� /// </summary> public bool DoorUnLockByRemote = false; - /// <summary> - /// 鏄惁浣跨敤瀹夐槻蹇嵎鏂瑰紡 - /// </summary> - public bool SafetyShortcut = false; /// <summary> /// 瀵嗙爜鍓╀綑鍙緭鍏ユ鏁� /// </summary> @@ -59,26 +57,8 @@ /// </summary> [Newtonsoft.Json.JsonIgnore] public string UserPictruePath = string.Empty; - /// <summary> - /// 瀹夐槻鎶ヨ淇℃伅璁板綍涓�澶╁唴鏈�澶х殑鎶ヨ鏁� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public int SafetyOnedayMaxAlarmMsgCount = 50; - /// <summary> - /// 瀹夐槻鎶ヨ淇℃伅璁板綍鏈�澶уぉ鏁� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public int SafetyMaxAlarmMsgDay = 5; - /// <summary> - /// 闂ㄩ攣鎶ヨ淇℃伅璁板綍涓�澶╁唴鏈�澶х殑鎶ヨ鏁� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public int DoorLockOnedayMaxAlarmMsgCount = 200; - /// <summary> - /// 闂ㄩ攣鎶ヨ淇℃伅璁板綍鏈�澶уぉ鏁� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public int DoorLockMaxAlarmMsgDay = 5; + + #endregion #region 鈻� 涓�鑸柟娉昣__________________________ @@ -87,40 +67,47 @@ /// </summary> public void Save() { - //鍔犲瘑瀵嗙爜 - string hdlKey = "hD1(La3o"; - string oldPswAuthentication = PswAuthentication; - PswAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldPswAuthentication); + try + { + //鍔犲瘑瀵嗙爜 + string hdlKey = "hD1(La3o"; + string oldPswAuthentication = PswAuthentication; + PswAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldPswAuthentication); - string oldGestureAuthentication = GestureAuthentication; - GestureAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldGestureAuthentication); + string oldGestureAuthentication = GestureAuthentication; + GestureAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldGestureAuthentication); - var data = Newtonsoft.Json.JsonConvert.SerializeObject(this); - var byteData = System.Text.Encoding.UTF8.GetBytes(data); - string fullName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile); - //鍐欏叆鍐呭 - Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData); - //杩樺師鏄庣爜 - PswAuthentication = oldPswAuthentication; - GestureAuthentication = oldGestureAuthentication; + var data = Newtonsoft.Json.JsonConvert.SerializeObject(this); + var byteData = System.Text.Encoding.UTF8.GetBytes(data); + string fullName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile); + //鍐欏叆鍐呭 + Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData); + //杩樺師鏄庣爜 + PswAuthentication = oldPswAuthentication; + GestureAuthentication = oldGestureAuthentication; + } + catch (Exception ex) + { + HdlLogLogic.Current.WriteLog(ex); + } } /// <summary> /// 鍔犺浇鏁版嵁 /// </summary> /// <returns></returns> - public AccountOption Load() + public AccountOptionClass Load() { string fileName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile); if (System.IO.File.Exists(fileName) == false) { - return new AccountOption(); + return new AccountOptionClass(); } try { var varByte = Shared.IO.FileUtils.ReadFile(fileName); string strValue = System.Text.Encoding.UTF8.GetString(varByte); - var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountOption>(strValue); + var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountOptionClass>(strValue); //瑙e瘑瀵嗙爜 string hdlKey = "hD1(La3o"; info.PswAuthentication = UserCenterLogic.DecryptPassword(hdlKey, info.PswAuthentication); @@ -131,7 +118,7 @@ catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); - return new AccountOption(); + return new AccountOptionClass(); } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/ResidenceOption.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/ResidenceOption.cs new file mode 100755 index 0000000..2461b93 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/ResidenceOption.cs @@ -0,0 +1,90 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 浣忓畢鐨勯厤缃� + /// </summary> + public class ResidenceOptionClass + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鏄惁浣跨敤瀹夐槻蹇嵎鏂瑰紡 + /// </summary> + public bool SafetyShortcut = false; + /// <summary> + /// 瀹夐槻鎶ヨ淇℃伅璁板綍涓�澶╁唴鏈�澶х殑鎶ヨ鏁� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int SafetyOnedayMaxAlarmMsgCount = 50; + /// <summary> + /// 瀹夐槻鎶ヨ淇℃伅璁板綍鏈�澶уぉ鏁� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int SafetyMaxAlarmMsgDay = 5; + /// <summary> + /// 闂ㄩ攣鎶ヨ淇℃伅璁板綍涓�澶╁唴鏈�澶х殑鎶ヨ鏁� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int DoorLockOnedayMaxAlarmMsgCount = 200; + /// <summary> + /// 闂ㄩ攣鎶ヨ淇℃伅璁板綍鏈�澶уぉ鏁� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int DoorLockMaxAlarmMsgDay = 5; + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 淇濆瓨 + /// </summary> + public void Save() + { + try + { + var data = Newtonsoft.Json.JsonConvert.SerializeObject(this); + var byteData = System.Text.Encoding.UTF8.GetBytes(data); + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ResidenceOptionFile); + //鍐欏叆鍐呭 + Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData); + } + catch (Exception ex) + { + HdlLogLogic.Current.WriteLog(ex); + } + } + + /// <summary> + /// 鍔犺浇鏁版嵁 + /// </summary> + /// <returns></returns> + public ResidenceOptionClass Load() + { + string fileName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ResidenceOptionFile); + if (System.IO.File.Exists(fileName) == false) + { + return new ResidenceOptionClass(); + } + try + { + var varByte = Shared.IO.FileUtils.ReadFile(fileName); + string strValue = System.Text.Encoding.UTF8.GetString(varByte); + var info = Newtonsoft.Json.JsonConvert.DeserializeObject<ResidenceOptionClass>(strValue); + + return info; + } + catch (Exception ex) + { + HdlLogLogic.Current.WriteLog(ex); + return new ResidenceOptionClass(); + } + } + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs index cef4eaa..cf4ba8c 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs @@ -1177,6 +1177,10 @@ /// </summary> public bool IsReading = false; /// <summary> + /// 鏄惁宸茶(listMsg鍖归厤,瀵瑰簲涓�鏉℃暟鎹噷闈㈠寘鍚涓姤璀�) + /// </summary> + public List<bool> ListReading = new List<bool>(); + /// <summary> /// 鏃堕棿 2019-09-10T13:11:55 /// </summary> public string CreatedOnUtc = string.Empty; @@ -1189,9 +1193,9 @@ /// </summary> public string MsgObjectText = string.Empty; /// <summary> - /// 娑堟伅鏂囨湰 + /// 娑堟伅鏂囨湰(瀵瑰簲涓�鏉℃暟鎹噷闈㈠寘鍚涓姤璀�) /// </summary> - public string MsgText = string.Empty; + public List<string> listMsg = new List<string>(); } /// <summary> @@ -1246,6 +1250,10 @@ /// 鏄剧ず璁惧鍘嗗彶鐗堟湰 1 -> 鏄剧ず /// </summary> public int DeviceHistory = 0; + /// <summary> + /// 妫�娴嬭兘鍚﹀箍鎾緱鍒扮綉鍏� + /// </summary> + public int CheckCanReceiveGateway = 0; } #endregion } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/BelongAreaControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/BelongAreaControl.cs index b0aca49..0557f56 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/BelongAreaControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/BelongAreaControl.cs @@ -61,7 +61,7 @@ /// <param name="i_device">璁惧瀵硅薄</param> public void InitControl(string i_caption, ZigBee.Device.CommonDevice i_device) { - var room = Common.Room.CurrentRoom.GetRoomByDevice(i_device); + var room = HdlRoomLogic.Current.GetRoomByDevice(i_device); this.InitControl(i_caption, room); } @@ -158,10 +158,10 @@ /// </summary> private void InitData() { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); if (dicFloor.Count == 0) { - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(string.Empty, false); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty, false); if (listRoom.Count > 0) { //鎴块棿鍚嶅瓧鍜屼富閿敹闆� @@ -180,7 +180,7 @@ { foreach (string fKeys in dicFloor.Keys) { - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(fKeys, false); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(fKeys, false); if (listRoom.Count > 0) { //妤煎眰鍚嶅瓧鍜屼富閿敹闆� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs index 1ec9341..e74e709 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafeguardLogControl.cs @@ -105,13 +105,18 @@ var listRow = dicRowFrame[listId[i]]; foreach (var alarmInfo in dicInfo[listId[i]]) { - //娣诲姞鎶ヨ淇℃伅 - var contr = this.AddAlarmInfoControl(alarmInfo); - if (listRow.Count != 0) + //涓�鏉′俊鎭噷闈紝瀹冨彲鑳藉寘鍚涓姤璀� + var listMsg = HdlAlarmsLogic.Current.GetSensorListAlarmMsg(alarmInfo); + foreach (var strMsg in listMsg) { - contr.Y = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(23); + //娣诲姞鎶ヨ淇℃伅鎺т欢 + var contr = this.AddAlarmInfoControl(alarmInfo, strMsg); + if (listRow.Count != 0) + { + contr.Y = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(23); + } + listRow.Add(contr); } - listRow.Add(contr); } //鍙樻洿楂樺害 frame1.Height = listRow[listRow.Count - 1].Bottom + Application.GetRealHeight(55); @@ -193,8 +198,34 @@ /// <summary> /// 娣诲姞鎶ヨ淇℃伅 /// </summary> + /// <param name="alarmInfo"></param> /// <returns></returns> public int AddSafeguardAlarmInfo(SafeguardAlarmInfo alarmInfo) + { + if (dicFrame.ContainsKey(alarmInfo.ZoneId) == false) + { + return -1; + } + //涓�鏉′俊鎭噷闈紝瀹冨彲鑳藉寘鍚涓姤璀� + var listMsg = HdlAlarmsLogic.Current.GetSensorListAlarmMsg(alarmInfo); + int valueCount = 0; + foreach (var strMsg in listMsg) + { + //涓�涓姤璀︿俊鎭紝涓�涓帶浠� + int value = this.AddSafeguardAlarmInfo2(alarmInfo, strMsg); + //杩欎釜value鏄帶浠跺鍔犵殑楂樺害鍊� + valueCount += value; + } + return valueCount; + } + + /// <summary> + /// 娣诲姞鎶ヨ淇℃伅(涓�涓姤璀︿俊鎭紝涓�涓帶浠�) + /// </summary> + /// <param name="alarmInfo"></param> + /// <param name="strMsg">閽堝涓�鏉℃暟鎹噷闈㈠寘鍚涓姤璀︾殑闂锛岃拷鍔犵殑鎶ヨ鏂囨湰</param> + /// <returns></returns> + private int AddSafeguardAlarmInfo2(SafeguardAlarmInfo alarmInfo, string strMsg) { if (dicFrame.ContainsKey(alarmInfo.ZoneId) == false) { @@ -223,7 +254,7 @@ } //娣诲姞鎶ヨ淇℃伅鎺т欢 - var frameRow = this.AddAlarmInfoControl(alarmInfo); + var frameRow = this.AddAlarmInfoControl(alarmInfo, strMsg); if (listRow.Count >= 100) { //绉婚櫎鏈�鍚庝竴涓� @@ -282,7 +313,7 @@ /// </summary> /// <param name="alarmInfo"></param> /// <returns></returns> - private FrameLayout AddAlarmInfoControl(SafeguardAlarmInfo alarmInfo) + private FrameLayout AddAlarmInfoControl(SafeguardAlarmInfo alarmInfo, string strMsg) { var frame = dicFrame[alarmInfo.ZoneId]; @@ -309,20 +340,7 @@ var btnMsg = new NormalViewControl(303, 58, true); btnMsg.X = Application.GetRealWidth(469); btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; - //鐢垫睜鐢甸噺 - if (alarmInfo.BatteryMsg != null) - { - btnMsg.Text = alarmInfo.BatteryMsg; - } - //琚媶鎶ヨ - else if (alarmInfo.DemolishmentMsg != null) - { - btnMsg.Text = alarmInfo.DemolishmentMsg; - } - else - { - btnMsg.Text = alarmInfo.AlarmMsg; - } + btnMsg.Text = strMsg; rowFrame.AddChidren(btnMsg); //鏃堕棿锛氭椂鍒嗙 var btnTime = new NormalViewControl(190, 58, true); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs index 34b3443..01d604f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetySensorStatuControl.cs @@ -53,7 +53,7 @@ btnArea.X = Application.GetRealWidth(46); btnArea.TextSize = 12; btnArea.TextColor = UserCenterColor.Current.TextGrayColor3; - btnArea.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + btnArea.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device); this.AddChidren(btnArea); //鐘舵�� var btnStatu = new NormalViewControl(200, 49, true); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs index 1bb995a..f6e6474 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs @@ -114,7 +114,7 @@ frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); if (tempDevice != null) { - btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(tempDevice); + btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(tempDevice); } else { @@ -140,7 +140,7 @@ return; } btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(tempDevice); - btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(tempDevice); + btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(tempDevice); string unSelectPath = string.Empty; string selectPath = string.Empty; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceSelectControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceSelectControl.cs index 9d27099..bcd071a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceSelectControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceSelectControl.cs @@ -90,7 +90,7 @@ this.AddTopView(eName, 850); //鎴块棿 - string roomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + string roomName = HdlRoomLogic.Current.GetRoomNameByDevice(device); this.AddBottomView(roomName, 850); btnSelect = this.AddMostRightEmptyIcon(58, 58); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/TopLayoutTitleControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/TopLayoutTitleControl.cs deleted file mode 100755 index fd82360..0000000 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/NormalControls/TopLayoutTitleControl.cs +++ /dev/null @@ -1,26 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 鍋氭垚涓�涓瓨鍦ㄤ簬TopFrameLayout閲岄潰鐨勬爣棰樻帶浠垛湬 - /// </summary> - public class TopLayoutTitleControl : ButtonBase - { - /// <summary> - /// 鍋氭垚涓�涓瓨鍦ㄤ簬TopFrameLayout閲岄潰鐨勬爣棰樻帶浠� - /// </summary> - public TopLayoutTitleControl() - { - this.Name = "txtTitle"; - this.TextSize = 17; - this.X = Application.GetRealWidth(161); - this.Height = Application.GetRealHeight(69); - this.Width = Application.GetRealWidth(850); - this.Gravity = Gravity.CenterVertical; - this.TextColor = UserCenterColor.Current.TopLayoutTitleText; - } - } -} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/RowLayoutControls/RowMostRightTextView.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/RowLayoutControls/RowMostRightTextView.cs deleted file mode 100755 index 18b8736..0000000 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/RowLayoutControls/RowMostRightTextView.cs +++ /dev/null @@ -1,26 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 鍋氭垚涓�涓綅浜嶳owlayout閲岄潰锛屾渶鍙宠竟鐨勬枃鏈樉绀烘帶浠�. - /// 鍒濆鍊硷細鎺т欢涓婁笅灞呬腑,鏂囧瓧鍚戝彸闈犻綈,鏍囧噯瀛椾綋鍙婇鑹� - /// </summary> - public class RowMostRightTextView : ButtonBase - { - /// <summary> - /// 鍋氭垚涓�涓綅浜嶳owlayout閲岄潰锛屾渶鍙宠竟鐨勬枃鏈樉绀烘帶浠�. - /// 鍒濆鍊硷細浣嶇疆涓婁笅灞呬腑,鏂囧瓧鍚戝彸闈犻綈,鏍囧噯瀛椾綋鍙婇鑹� - /// </summary> - public RowMostRightTextView() - { - this.X = Application.GetRealWidth(700); - this.Height = ControlCommonResourse.NormalControlHeight; - this.Width = Application.GetRealWidth(320); - this.TextAlignment = TextAlignment.CenterRight; - this.Gravity = Gravity.CenterVertical; - } - } -} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneRoomControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneRoomControl.cs index bf86249..f9d213d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneRoomControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneRoomControl.cs @@ -26,7 +26,7 @@ { get { - return Common.Room.CurrentRoom.GetSceneUIBySceneId(SceneId); + return HdlSceneLogic.Current.GetSceneUIBySceneId(SceneId); } } @@ -76,7 +76,7 @@ btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1; frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); - var room = Common.Room.CurrentRoom.GetRoomBySceneId(this.SceneId); + var room = HdlRoomLogic.Current.GetRoomBySceneId(this.SceneId); if (room != null) { btnRoom.Text = room.Name; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneSimpleSelectControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneSimpleSelectControl.cs index 5c792d1..4f68e92 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneSimpleSelectControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/SceneControls/SceneSimpleSelectControl.cs @@ -20,7 +20,7 @@ /// </summary> public Common.SceneUI Scene { - get { return Common.Room.CurrentRoom.GetSceneUIBySceneId(SceneId); } + get { return HdlSceneLogic.Current.GetSceneUIBySceneId(SceneId); } } /// <summary> /// 閫夋嫨鎺т欢 @@ -90,7 +90,7 @@ this.AddTopView(SceneTemp.Name, 850); //鎴块棿 - string roomName = Common.Room.CurrentRoom.GetRoomNameBySceneId(SceneId); + string roomName = HdlRoomLogic.Current.GetRoomNameBySceneId(SceneId); this.AddBottomView(roomName, 850); btnSelect = this.AddMostRightEmptyIcon(58, 58); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/Base/EditorCommonForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/Base/EditorCommonForm.cs index f62992d..d152b43 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/Base/EditorCommonForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/Base/EditorCommonForm.cs @@ -129,10 +129,18 @@ topFrameLayout.AddTag("btnBack", btnBack); //鏍囬 - var txttitle = new TopLayoutTitleControl(); - topFrameLayout.AddChidren(txttitle); - //绮椾綋 + var txttitle = new Button(); + txttitle.Name = "txtTitle"; + txttitle.TextSize = 17; + txttitle.X = Application.GetRealWidth(161); + txttitle.Height = Application.GetRealHeight(69); + txttitle.Width = Application.GetRealWidth(850); + txttitle.Gravity = Gravity.CenterVertical; + txttitle.TextColor = UserCenterColor.Current.TopLayoutTitleText; + txttitle.TextAlignment = TextAlignment.CenterLeft; txttitle.IsBold = true; + topFrameLayout.AddChidren(txttitle); + topFrameLayout.AddTag("txtTitle", txttitle); } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswGestureSecirityForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswGestureSecirityForm.cs index f7d274e..310d994 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswGestureSecirityForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswGestureSecirityForm.cs @@ -59,10 +59,10 @@ }; gestureControl.FinishInputEvent += (Password, pswLeng) => { - if (UserCenterResourse.Option.GestureAuthentication != Password) + if (UserCenterResourse.AccountOption.GestureAuthentication != Password) { - UserCenterResourse.Option.PasswordGestureInputCount--; - if (UserCenterResourse.Option.PasswordGestureInputCount <= 0) + UserCenterResourse.AccountOption.PasswordGestureInputCount--; + if (UserCenterResourse.AccountOption.PasswordGestureInputCount <= 0) { //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰� string msg2 = Language.StringByID(R.MyInternationalizationString.uCheckAdministratorFailAndReload); @@ -75,7 +75,7 @@ return; } //閲嶇疆鍓╀綑瀵嗙爜娆℃暟 - UserCenterResourse.Option.ResetPasswordCount(); + UserCenterResourse.AccountOption.ResetPasswordCount(); //鐣岄潰鍏抽棴 this.CloseForm(); SuccessAction?.Invoke(); @@ -86,7 +86,7 @@ var btnTouch = new BottomLeftClickButton(frameBack.Width / 2, Application.GetRealHeight(127)); frameBack.AddChidren(btnTouch); btnTouch.InitControl(i_TouchText); - if (UserCenterResourse.Option.FingerprintAuthentication == false) + if (UserCenterResourse.AccountOption.FingerprintAuthentication == false) { //娌℃湁鍚敤Touch ID btnTouch.CanClick = false; @@ -117,13 +117,13 @@ TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; //瀵嗙爜楠岃瘉 - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { var form = new PswSecondarySecurityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } //鎵嬪娍楠岃瘉 - else if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { var form = new PswGestureSecirityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); @@ -142,7 +142,7 @@ var btnPsw = new BottomRightClickButton(frameBack.Width - btnTouch.Width, btnTouch.Height); frameBack.AddChidren(btnPsw); btnPsw.InitControl(i_PasswordText); - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true) { //娌℃湁鍚敤瀵嗙爜寮�閿� btnPsw.CanClick = false; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswSecondarySecurityForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswSecondarySecurityForm.cs index f04784f..cfcdc6e 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswSecondarySecurityForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Form/PswSecondarySecurityForm.cs @@ -62,10 +62,10 @@ }; pswControl.FinishInputEvent += (strPsw) => { - if (UserCenterResourse.Option.PswAuthentication != strPsw) + if (UserCenterResourse.AccountOption.PswAuthentication != strPsw) { - UserCenterResourse.Option.PasswordInputCount--; - if (UserCenterResourse.Option.PasswordInputCount <= 0) + UserCenterResourse.AccountOption.PasswordInputCount--; + if (UserCenterResourse.AccountOption.PasswordInputCount <= 0) { //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰� string msg2 = Language.StringByID(R.MyInternationalizationString.uCheckAdministratorFailAndReload); @@ -78,7 +78,7 @@ return; } //閲嶇疆鍓╀綑瀵嗙爜娆℃暟 - UserCenterResourse.Option.ResetPasswordCount(); + UserCenterResourse.AccountOption.ResetPasswordCount(); //鐣岄潰鍏抽棴 this.CloseForm(); SuccessAction?.Invoke(); @@ -89,7 +89,7 @@ var btnGesture = new BottomLeftClickButton(frameBack.Width / 2, Application.GetRealHeight(127)); frameBack.AddChidren(btnGesture); btnGesture.InitControl(i_GestureText); - if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true) { //娌℃湁鍚敤鎵嬪娍寮�閿� btnGesture.CanClick = false; @@ -105,7 +105,7 @@ var btnTouch = new BottomRightClickButton(frameBack.Width - btnGesture.Width, btnGesture.Height); frameBack.AddChidren(btnTouch); btnTouch.InitControl(i_TouchText); - if (UserCenterResourse.Option.FingerprintAuthentication == false) + if (UserCenterResourse.AccountOption.FingerprintAuthentication == false) { //娌℃湁鍚敤Touch ID btnTouch.CanClick = false; @@ -138,13 +138,13 @@ TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; //瀵嗙爜楠岃瘉 - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { var form = new PswSecondarySecurityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } //鎵嬪娍楠岃瘉 - else if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { var form = new PswGestureSecirityForm(); this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAlarmsLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAlarmsLogic.cs index ead7ba5..27d7bf4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAlarmsLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAlarmsLogic.cs @@ -125,7 +125,7 @@ data.DeviceEpoint = device.DeviceEpoint; data.DeviceName = device.DeviceName; data.Time = DateTime.Now.ToString("HH:mm:ss"); - data.RoomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + data.RoomName = HdlRoomLogic.Current.GetRoomNameByDevice(device); //鎶ヨ缁撴潫 data.AlarmMsg = msgInfo.AlarmMsg != string.Empty ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uAlarmFinish); //鐢垫睜鎶ヨ @@ -135,7 +135,7 @@ //闄愬埗瀹冪殑闀垮害 this.listSafetyAlarmInfo.Insert(0, data); - if (this.listSafetyAlarmInfo.Count > UserCenterResourse.Option.SafetyOnedayMaxAlarmMsgCount) + if (this.listSafetyAlarmInfo.Count > UserCenterResourse.ResidenceOption.SafetyOnedayMaxAlarmMsgCount) { this.listSafetyAlarmInfo.RemoveAt(this.listSafetyAlarmInfo.Count - 1); } @@ -211,7 +211,7 @@ //闄愬埗瀹冪殑闀垮害 this.listSafetyAlarmInfo.Insert(0, data); - if (this.listSafetyAlarmInfo.Count > UserCenterResourse.Option.SafetyOnedayMaxAlarmMsgCount) + if (this.listSafetyAlarmInfo.Count > UserCenterResourse.ResidenceOption.SafetyOnedayMaxAlarmMsgCount) { this.listSafetyAlarmInfo.RemoveAt(this.listSafetyAlarmInfo.Count - 1); } @@ -266,7 +266,7 @@ var listInfo = new List<SafeguardAlarmInfo>(); for (int j = 0; j < info.Count; j++) { - if (j == UserCenterResourse.Option.SafetyOnedayMaxAlarmMsgCount) + if (j == UserCenterResourse.ResidenceOption.SafetyOnedayMaxAlarmMsgCount) { //姣忓ぉ鏈�澶氫笁鍗佹潯鏁版嵁 break; @@ -275,7 +275,7 @@ } dic[listFile[i]] = listInfo; - if (dic.Count == UserCenterResourse.Option.SafetyMaxAlarmMsgDay) + if (dic.Count == UserCenterResourse.ResidenceOption.SafetyMaxAlarmMsgDay) { //鍙涓夊ぉ鐨勯噺 break; @@ -403,6 +403,34 @@ return alarmInfo; } + /// <summary> + /// 鑾峰彇鍗曚釜Json鏁版嵁閲岄潰,鍖呭惈鐨勫叏閮ㄦ姤璀︿俊鎭潯鏁� + /// </summary> + /// <param name="alarmInfo"></param> + /// <returns></returns> + public List<string> GetSensorListAlarmMsg(SafeguardAlarmInfo alarmInfo) + { + var listMsg = new List<string>(); + //涓�鏉′俊鎭噷闈紝瀹冨彲鑳藉寘鍚涓姤璀� + if (string.IsNullOrEmpty(alarmInfo.AlarmMsg) == false) + { + //鎶ヨ淇℃伅 + listMsg.Add(alarmInfo.AlarmMsg); + } + if (alarmInfo.BatteryMsg != null) + { + //鐢垫睜鐢甸噺 + listMsg.Add(alarmInfo.BatteryMsg); + } + if (alarmInfo.DemolishmentMsg != null) + { + //琚媶鎶ヨ + listMsg.Add(alarmInfo.DemolishmentMsg); + } + + return listMsg; + } + #endregion @@ -437,11 +465,11 @@ msgInfo.DeviceEpoint = device.DeviceEpoint; msgInfo.DeviceName = device.DeviceName; msgInfo.Time = DateTime.Now.ToString("HH:mm:ss"); - msgInfo.RoomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + msgInfo.RoomName = HdlRoomLogic.Current.GetRoomNameByDevice(device); //闄愬埗瀹冪殑闀垮害 this.listDoorLockAlarmInfo.Insert(0, msgInfo); - if (this.listDoorLockAlarmInfo.Count > UserCenterResourse.Option.DoorLockOnedayMaxAlarmMsgCount) + if (this.listDoorLockAlarmInfo.Count > UserCenterResourse.ResidenceOption.DoorLockOnedayMaxAlarmMsgCount) { this.listDoorLockAlarmInfo.RemoveAt(this.listDoorLockAlarmInfo.Count - 1); } @@ -481,7 +509,7 @@ var listInfo = new List<DeviceAlarmInfo>(); for (int j = 0; j < info.Count; j++) { - if (j == UserCenterResourse.Option.DoorLockOnedayMaxAlarmMsgCount) + if (j == UserCenterResourse.ResidenceOption.DoorLockOnedayMaxAlarmMsgCount) { //姣忓ぉ鏈�澶氫笁鍗佹潯鏁版嵁 break; @@ -490,7 +518,7 @@ } dic[listFile[i]] = listInfo; - if (dic.Count == UserCenterResourse.Option.DoorLockMaxAlarmMsgDay) + if (dic.Count == UserCenterResourse.ResidenceOption.DoorLockMaxAlarmMsgDay) { //鍙涓夊ぉ鐨勯噺 break; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs index 2bc0020..7a1f143 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs @@ -95,7 +95,7 @@ { //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; //棣栧厛鍏堝垱寤轰竴涓复鏃舵枃浠跺す,瀛樺湪鏂囦欢鍒欐竻绌� string newDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadBackupTempDirectory); @@ -109,7 +109,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } @@ -132,7 +132,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } @@ -145,7 +145,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } //灏嗚緭鍏ュ啓鍏ユ湰鍦扮殑涓存椂鏂囦欢澶� @@ -157,7 +157,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return newDir; } @@ -287,7 +287,7 @@ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; //浣犺涓轰粈涔堣繖閲屼笉鍒嗕竴涓嚱鏁板嚭鏉ワ紙鐞嗚涓婃槸鍒嗗嚱鏁板嚭鏉ョ殑锛� //鏄洜涓哄鏋滃垎鍑芥暟鐨勮瘽锛屼細鍑虹幇鍙岄噸寮傛锛屽鑷翠富绾跨▼鐨勮繘搴︽潯鐨勭櫨鍒嗘瘮姘歌繙瀹氭0% @@ -301,7 +301,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //鍒ゆ柇鏄惁鏄簲璇ヤ笂浼犵殑鏂囦欢 @@ -326,7 +326,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //璁剧疆杩涘害鍊� @@ -343,7 +343,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } @@ -358,7 +358,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //璁剧疆杩涘害鍊� @@ -369,7 +369,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return true; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs index 2ca8eb4..86f3969 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs @@ -239,7 +239,7 @@ TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); - if (type == TouchIDUtils.TouchIDSupperType.TouchID && UserCenterResourse.Option.FingerprintAuthentication == true) + if (type == TouchIDUtils.TouchIDSupperType.TouchID && UserCenterResourse.AccountOption.FingerprintAuthentication == true) { //Touch ID楠岃瘉 TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent += (sender2, e2) => @@ -254,13 +254,13 @@ else if (e2 == TouchIDUtils.TouchIDState.InputPassword) { //瀵嗙爜楠岃瘉 - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { var form = new PswSecondarySecurityForm(); form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); } //鎵嬪娍楠岃瘉 - else if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { var form = new PswGestureSecirityForm(); form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); @@ -276,14 +276,14 @@ TouchIDUtils.Instance.showTouchIDWithDescribe(null, null); FailAction = null; } - else if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { //瀵嗙爜楠岃瘉 var form = new PswSecondarySecurityForm(); form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); FailAction = null; } - else if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { //鎵嬪娍楠岃瘉 var form = new PswGestureSecirityForm(); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceOtherLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceOtherLogic.cs new file mode 100755 index 0000000..25ed175 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceOtherLogic.cs @@ -0,0 +1,310 @@ +锘縰sing Shared.Common; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 璁惧鐨勫叾浠栭�昏緫(鐩墠鐢ㄦ潵瀛樻斁閮洩鍩庣殑浠g爜) + /// </summary> + public class HdlDeviceOtherLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧鐨勫叾浠栭�昏緫 + /// </summary> + private static HdlDeviceOtherLogic m_Current = null; + /// <summary> + /// 璁惧鐨勫叾浠栭�昏緫 + /// </summary> + public static HdlDeviceOtherLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlDeviceOtherLogic(); + } + return m_Current; + } + } + + /// <summary> + /// 鎺у埗寤舵椂榛樿鍙嶉鐨勭嚎绋嬪垪琛� + /// </summary> + private List<System.Threading.Thread> ListThreads = new List<System.Threading.Thread> { }; + + #endregion + + #region 鈻� 鍙戦�佹帶鍒跺懡浠ゅ欢鏃跺弽棣坃______________ + + /// <summary> + /// 鍙戦�佹帶鍒跺懡浠ゅ欢鏃跺弽棣� + /// </summary> + /// <param name="commonDevice">Common device.</param> + /// <param name="action">Action.</param> + /// <param name="delayTime">Delay time.</param> + public void SendCommandDelayAction(CommonDevice commonDevice, Action action, int delayTime = 3) + { + var threadName = commonDevice.GetHashCode().ToString(); + if (ListThreads.Find((obj) => obj.Name == threadName) == null) + { + var thread = new System.Threading.Thread(() => + { + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalSeconds < delayTime) + { + System.Threading.Thread.Sleep(100); + } + lock (ListThreads) + { + ListThreads.RemoveAll((obj) => obj.Name == threadName); + } + action?.Invoke(); + }) + { IsBackground = true, Name = threadName }; + lock (ListThreads) + { + ListThreads.Add(thread); + } + thread.Start(); + } + } + + #endregion + + #region 鈻� 鏄剧ず鎺у埗璁惧鏄惁鎴愬姛鐨勬彁绀篲________ + + /// <summary> + /// 鏄剧ず鎺у埗璁惧鏄惁鎴愬姛鐨勬彁绀� + /// </summary> + /// <param name="r">The red component.</param> + public void ShowStatuTip(int r) + { + Application.RunOnMainThread(() => + { + string msg = Language.StringByID(r); + var tip = new ShowMsgControl(ShowMsgType.Tip, msg); + tip.Show(); + }); + } + + #endregion + + #region 鈻� 鑾峰彇璁惧鐘舵�佺殑缈昏瘧_________________ + + /// <summary> + /// GetDeviceStatu + /// </summary> + /// <returns></returns> + public string GetDeviceStatu(CommonDevice device) + { + if (device.Type == DeviceType.OnOffOutput) + { + if ((device as ToggleLight).OnOffStatus == 1) + { + return Language.StringByID(R.MyInternationalizationString.uOpen1); + } + return Language.StringByID(R.MyInternationalizationString.Close); + } + else if (device.Type == DeviceType.AirSwitch) + { + if ((device as AirSwitch).OnOffStatus == 1) + { + return Language.StringByID(R.MyInternationalizationString.uOpen1); + } + return Language.StringByID(R.MyInternationalizationString.Close); + } + else if (device.Type == DeviceType.DimmableLight) + { + if ((device as DimmableLight).OnOffStatus == 0 || (device as DimmableLight).Level == 0) + { + return Language.StringByID(R.MyInternationalizationString.Close); + } + return $"{(int)((device as DimmableLight).Level * 1.0 / 254 * 100)}%"; + } + else if (device.Type == DeviceType.WindowCoveringDevice) + { + if ((device as Rollershade).WcdCurrentPositionLiftPercentage == 0) + { + return Language.StringByID(R.MyInternationalizationString.Close); + } + return $"{(device as Rollershade).WcdCurrentPositionLiftPercentage}%"; + } + else if (device.Type == DeviceType.Thermostat) + { + //娓╁害锛屾ā寮忥紝椋庨�� + string tempareture = string.Empty; + string model = string.Empty; + string wind = string.Empty; + + var ac = device as AC; + + if (ac.currentSystemMode == 0) + { + return Language.StringByID(R.MyInternationalizationString.Close); + } + else if (ac.currentSystemMode == 1) + { + model = Language.StringByID(R.MyInternationalizationString.Mode_Auto); + tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; + } + else if (ac.currentSystemMode == 3) + { + model = Language.StringByID(R.MyInternationalizationString.Mode_Cool); + tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; + } + else if (ac.currentSystemMode == 4) + { + model = Language.StringByID(R.MyInternationalizationString.Mode_Heat); + tempareture = $"{ac.currentHeatingSetpoint} 鈩�"; + } + else if (ac.currentSystemMode == 7) + { + model = Language.StringByID(R.MyInternationalizationString.Mode_FanOnly); + } + else if (ac.currentSystemMode == 8) + { + model = Language.StringByID(R.MyInternationalizationString.Mode_Dry); + tempareture = $"{ac.currentCoolingSetpoint} 鈩�"; + } + + if (ac.currentFanMode == 1) + { + wind = Language.StringByID(R.MyInternationalizationString.Fan_Low); + } + else if (ac.currentFanMode == 2) + { + wind = Language.StringByID(R.MyInternationalizationString.Fan_Middle); + } + else + { + wind = Language.StringByID(R.MyInternationalizationString.Fan_Height); + } + + if (string.IsNullOrEmpty(tempareture)) + { + return $"{model},{wind}"; + } + return $"{model},{wind},{tempareture}"; + } + else if (device.Type == DeviceType.IASZone) + { + var ias = device as IASZone; + //鍖哄垎浼犳劅鍣ㄥ叿浣撶被鍨� + var info = LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { device }); + if (info.ConcreteType == DeviceConcreteType.Sensor_Infrared) + { + //绾㈠ + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HavePerson); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_NoPerson); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_Water) + { + //姘存蹈 + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_HaveWater); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_DoorWindow) + { + //闂ㄧ獥 + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Open); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Close); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_CarbonMonoxide) + { + //鐕冩皵 + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_Fire) + { + //鐑熼浘 + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_Pir) + { + //pir + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Safe); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_Keyfob) + { + //閽ュ寵鎵� + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_Motion) + { + //杩愬姩浼犳劅鍣� + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); + } + else if (info.ConcreteType == DeviceConcreteType.Sensor_EmergencyButton) + { + //绱ф�ユ寜閽� + if (ias.iASInfo?.Alarm1 == 1) + { + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Alarm); + } + return Language.StringByID(R.MyInternationalizationString.IASZone_Statu_Normal); + } + return null; + } + else if (device.Type == DeviceType.TemperatureSensor) + { + var tempera = device as TemperatureSensor; + if (tempera.SensorDiv == 1) + { + if (tempera.Temperatrue == 0) + { + return "--鈩�"; + } + return $"{tempera.Temperatrue}鈩�"; + } + else if (tempera.SensorDiv == 2) + { + if (tempera.Humidity == 0) + { + return "--%"; + } + return $"{tempera.Humidity}%"; + } + return null; + } + else + { + return null; + } + } + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs index 5fafb97..ae0efbe 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs @@ -767,14 +767,15 @@ //濡傛灉鏄富缃戝叧 if (this.IsMainGateway(zbGatewayID) == 1) { - foreach (var room in Shared.Common.Room.Lists) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { //鍒犻櫎鍦烘櫙鏂囦欢 - foreach (var scene in room.SceneUIFilePathList) + foreach (var sceneId in room.ListSceneId) { - if (Global.IsExistsByHomeId(scene) == true) + if (Global.IsExistsByHomeId($"Scene_{sceneId}.json") == true) { - Global.DeleteFilebyHomeId(scene); + Global.DeleteFilebyHomeId($"Scene_{sceneId}.json"); } } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs index 303e827..a498bb4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs @@ -422,7 +422,7 @@ #region 鈻� 娣诲姞璁惧浜嬩欢_______________________ /// <summary> - /// 娣诲姞鑾峰彇璁惧灞炴�х殑浜嬩欢(鎺ㄩ�佸凡缁忓己鍒舵寚瀹氳繍琛屼簬涓荤嚎绋嬶紝灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport) + /// 娣诲姞鑾峰彇璁惧灞炴�х殑浜嬩欢(灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport) /// </summary> /// <param name="mainKeys">鏍囪瘑浜嬩欢鐨勪富閿�(鍙互闅忎究濉�,涓昏鏄拡瀵瑰涓晫闈竴璧蜂娇鐢ㄧ殑鎯呭喌)</param> /// <param name="comand">鍛戒护鍖哄垎</param> diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs new file mode 100755 index 0000000..50863d1 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs @@ -0,0 +1,49 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 浣忓畢瀵硅薄鐨勯�昏緫 + /// </summary> + public class HdlResidenceLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 浣忓畢瀵硅薄鐨勯�昏緫 + /// </summary> + private static HdlResidenceLogic m_Current = null; + /// <summary> + /// 浣忓畢瀵硅薄鐨勯�昏緫 + /// </summary> + public static HdlResidenceLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlResidenceLogic(); + } + return m_Current; + } + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鑾峰彇妤煎眰鍚嶇О + /// </summary> + /// <param name="i_FloorId">妤煎眰ID</param> + /// <returns></returns> + public string GetFloorNameById(string i_FloorId) + { + return Common.Config.Instance.Home.GetFloorNameById(i_FloorId); + } + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs new file mode 100755 index 0000000..a44eb08 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs @@ -0,0 +1,1009 @@ +锘縰sing Shared.Common; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 鎴块棿鐨勯�昏緫 + /// </summary> + public class HdlRoomLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鎴块棿鐨勯�昏緫 + /// </summary> + private static HdlRoomLogic m_Current = null; + /// <summary> + /// 鎴块棿鐨勯�昏緫 + /// </summary> + public static HdlRoomLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlRoomLogic(); + } + return m_Current; + } + } + + /// <summary> + /// 褰撳墠閫夋嫨鐨勬埧闂� + /// </summary> + private Room m_CurrentRoom = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勬埧闂� + /// </summary> + public Room CurrentRoom + { + get + { + if (m_CurrentRoom == null && dicRooms.Count > 0) + { + //璁剧疆鍒濆鍊� + foreach (var room in dicRooms.Values) + { + m_CurrentRoom = room; + break; + } + } + return m_CurrentRoom; + } + set { m_CurrentRoom = value; } + } + + /// <summary> + /// 鎵�鏈夌殑鎴块棿淇℃伅 + /// </summary> + private Dictionary<string, Room> dicRooms = new Dictionary<string, Room>(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍒濆鍖栨埧闂翠俊鎭� + /// 浠庢枃浠朵腑鍏ㄩ儴璇诲彇鎵�鏈夌殑鎴块棿鏁版嵁鍒板唴瀛� + /// </summary> + public void InitAllRoom() + { + //娓呯┖鏈湴缂撳瓨 + this.dicRooms.Clear(); + //妫�娴嬫垜鐨勫枩鐖辫繖涓埧闂村璞� + this.CheckLoveRoom(); + + foreach (var roomId in Config.Instance.Home.ListRooms) + { + //浠庢枃浠堕噷闈㈣幏鍙栨埧闂村璞� + var room = this.GetRoomByFilePath($"Room_{roomId}.json"); + if (room != null) + { + this.dicRooms[room.Id] = (room); + } + } + //璁剧疆褰撳墠妤煎眰鐨処D + Config.Instance.Home.SetCurrentFloorId(); + //椤轰究鍒锋柊鍦烘櫙 + HdlSceneLogic.Current.ReFreshByLocal(); + //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 + this.RefreshRoomListView(); + } + + /// <summary> + /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 + /// </summary> + public void RefreshAllRoomByLocation() + { + var homeTemp = Config.Instance.Home; + homeTemp.ListRooms.Clear(); + + var listFile = Global.FileListByHomeId(); + + //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� + string fRoom = "Room_Favorite.json"; + if (listFile.Contains(fRoom) == true) + { + listFile.Remove(fRoom); + homeTemp.ListRooms.Add("Favorite"); + } + + var listRoomFile = new List<string>(); + foreach (string fileName in listFile) + { + if (fileName.StartsWith("Room_")) + { + string roomId = fileName.Replace("Room_", string.Empty).Replace(".json", string.Empty); + homeTemp.ListRooms.Add(roomId); + listRoomFile.Add(fileName); + } + } + //妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬� + this.CheckFloorData(listRoomFile); + + homeTemp.Save(false); + InitAllRoom(); + } + + /// <summary> + /// 鍒锋柊鎴块棿瑙嗗浘鍒楄〃 + /// </summary> + public void RefreshRoomListView() + { + Application.RunOnMainThread(() => + { + Phone.Device.Room.RoomManagement.Instance.Show(); + }); + } + + /// <summary> + /// 妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬� + /// </summary> + /// <param name="listRoomFile"></param> + private void CheckFloorData(List<string> listRoomFile) + { + for (int i = 0; i < listRoomFile.Count; i++) + { + try + { + var byteData = Global.ReadFileByHomeId(listRoomFile[i]); + string valueData = System.Text.Encoding.UTF8.GetString(byteData); + var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData); + + //妫�娴嬪涓墜鏈烘潵鍥炲垱寤�,鐒跺悗鍙堝垹闄や箣鍚�,妤煎眰鏁版嵁涓嶈兘淇濊瘉100%鍚屾鐨勯棶棰� + if (roomTemp.FloorId != string.Empty && Config.Instance.Home.FloorDics.ContainsKey(roomTemp.FloorId) == false) + { + //鏈煡妤煎眰 + Config.Instance.Home.FloorDics[roomTemp.FloorId] = Language.StringByID(R.MyInternationalizationString.uUnKnownFloor); + } + } + catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } + } + } + + #endregion + + #region 鈻� 娣诲姞鎴块棿___________________________ + + /// <summary> + /// 澧炲姞鎴块棿 + /// </summary> + /// <param name="room">Room.</param> + public void AddRoom(Room room) + { + if (Global.IsExistsByHomeId(room.FileName) == true + || Config.Instance.Home.ListRooms.Contains(room.Id) == true) + { + return; + } + //娣诲姞鍒扮紦瀛� + this.dicRooms[room.Id] = room; + //鎶婃埧闂碔D娣诲姞鍒颁綇瀹� + Config.Instance.Home.AddRoomId(room.Id); + //鐢熸垚鏂囦欢 + room.Save(); + //澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(room.FileName); + //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 + this.RefreshRoomListView(); + } + + #endregion + + #region 鈻� 鍒犻櫎鎴块棿___________________________ + + /// <summary> + /// 鍒犻櫎鎴块棿 + /// </summary> + /// <param name="roomId">鎴块棿ID</param> + /// <returns></returns> + public void RemoveRoom(string roomId) + { + //鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞� + var room = this.GetRoomById(roomId); + if (room == null) + { + return; + } + //鍒犻櫎鏉ヨ嚜鎷嶇収鎴栬�呯郴缁熷浘搴撶殑鎴块棿鑳屾櫙鍥剧墖 + if (room.BackgroundImageType == 1 || room.BackgroundImageType == 2) + { + //鍒犻櫎鎺夊師鏉ョ殑鑷畾涔夊浘鐗� + if (Global.IsExistsByHomeId(room.BackgroundImage) == true) + { + Global.DeleteFilebyHomeId(room.BackgroundImage); + //鍒犻櫎澶囦唤 + HdlAutoBackupLogic.DeleteFile(room.BackgroundImage); + } + } + //鎴戠殑鍠滅埍 + var loveRoom = this.GetLoveRoom(); + if (loveRoom != null) + { + //绉婚櫎鎴戠殑鍠滅埍閲岄潰鐨勮澶� + for (int i = 0; i < room.ListDevice.Count; i++) + { + loveRoom.ListDevice.Remove(room.ListDevice[i]); + } + //绉婚櫎鎴戠殑鍠滅埍閲岄潰鐨勫満鏅� + for (int i = 0; i < room.ListSceneId.Count; i++) + { + loveRoom.ListSceneId.Remove(room.ListSceneId[i]); + } + loveRoom.Save(false); + } + + Config.Instance.Home.RemoveRoomId(roomId); + this.dicRooms.Remove(roomId); + + string roomFilePath = room.FileName; + if (Global.IsExistsByHomeId(roomFilePath) == true) + { + //鍒犻櫎鏂囦欢 + Global.DeleteFilebyHomeId(roomFilePath); + } + HdlAutoBackupLogic.DeleteFile(roomFilePath); + //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 + this.RefreshRoomListView(); + } + + #endregion + + #region 鈻� 鑾峰彇鎴块棿___________________________ + + /// <summary> + /// 鑾峰彇鍠滅埍鎴块棿 + /// </summary> + /// <returns></returns> + public Room GetLoveRoom() + { + //妫�娴嬫垜鐨勫枩鐖辫繖涓埧闂村璞� + this.CheckLoveRoom(); + + return this.dicRooms["Favorite"]; + } + + /// <summary> + /// 閫氳繃璺緞鑾峰彇鎴块棿 + /// </summary> + /// <returns>The room by file path.</returns> + /// <param name="roomFilePath">Room file path.</param> + private Room GetRoomByFilePath(string roomFilePath) + { + try + { + var roomFile = Global.ReadFileByHomeId(roomFilePath); + var nowRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(Encoding.UTF8.GetString(roomFile)); + + return nowRoom; + } + catch (Exception ex) + { + HdlLogLogic.Current.WriteLog(ex); + return null; + } + } + + /// <summary> + /// 鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞� + /// </summary> + /// <returns>The room by name.</returns> + /// <param name="roomId">鎴块棿ID</param> + public Room GetRoomById(string roomId) + { + if (this.dicRooms.ContainsKey(roomId) == false) + { + return null; + } + return this.dicRooms[roomId]; + } + + /// <summary> + /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(妤煎眰+鎴块棿鍚�) + /// </summary> + /// <returns>鎴块棿鍚�</returns> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="append">鍦ㄦゼ灞傚拰鎴块棿鍚嶅瓧鐨勪腑闂存坊鍔犵殑瀛楃(浠呴檺鏈夋ゼ灞傜殑鏃跺�欐湁鏁�)</param> + public string GetRoomNameByDevice(CommonDevice device, string append = " ") + { + var room = this.GetRoomByDevice(device); + if (room == null) + { + //鏈垎閰嶅尯鍩� + return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); + } + if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) + { + //(妤煎眰+鎴块棿鍚�) + return Config.Instance.Home.FloorDics[room.FloorId] + append + room.Name; + } + return room.Name; + } + + /// <summary> + /// 鑾峰彇璁惧鎵�鍦ㄧ殑鎴块棿(娌℃湁璁剧疆鏈夋埧闂村垯杩斿洖null) + /// </summary> + /// <returns>The room by device.</returns> + /// <param name="device">璁惧瀵硅薄</param> + public Room GetRoomByDevice(CommonDevice device) + { + string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); + foreach (var room in this.dicRooms.Values) + { + if (room.IsLove == true) + { + //鍠滅埍鎴块棿涓嶅鐞� + continue; + } + if (room.ListDevice.Contains(mainKeys) == true) + { + return room; + } + } + return null; + } + + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿鍚� + /// </summary> + /// <returns>The room name by scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public string GetRoomNameBySceneId(int sceneId) + { + var room = GetRoomBySceneId(sceneId); + if (room == null) + { + return null; + } + return room.Name; + } + + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿瀵硅薄 + /// </summary> + /// <returns>The room by scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public Room GetRoomBySceneId(int sceneId) + { + foreach (var room in this.dicRooms.Values) + { + if (room.IsLove == true) + { + //鍠滅埍鎴块棿涓嶅鐞� + continue; + } + if (room.ListSceneId.Contains(sceneId) == true) + { + return room; + } + } + return null; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂� + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public List<Room> GetRoomsByFloorId(string id) + { + var listRoom = new List<Room>(); + if (Config.Instance.Home.FloorDics.Count == 0) + { + //娌℃湁妤煎眰 + foreach (var room in this.dicRooms.Values) + { + listRoom.Add(room); + } + } + else + { + foreach (var room in this.dicRooms.Values) + { + if (room.FloorId == id) + { + listRoom.Add(room); + } + } + } + return listRoom; + } + + /// <summary> + /// 鑾峰彇鍏ㄩ儴鐨勬埧闂� + /// </summary> + /// <returns></returns> + public List<Room> GetAllListRooms() + { + var listRoom = new List<Room>(); + foreach (var room in this.dicRooms.Values) + { + listRoom.Add(room); + } + return listRoom; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉� + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public List<string> GetRoomNamesByFloorId(string id) + { + var listName = new List<string>(); + if (Config.Instance.Home.FloorDics.Count == 0) + { + //娌℃湁妤煎眰 + foreach (var room in this.dicRooms.Values) + { + listName.Add(room.Name); + } + } + else + { + foreach (var room in this.dicRooms.Values) + { + if (room.FloorId == id) + { + listName.Add(room.Name); + } + } + } + return listName; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�) + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id) + { + var listRoom = new List<Room>(); + if (Config.Instance.Home.FloorDics.Count == 0) + { + //娌℃湁妤煎眰 + foreach (var room in this.dicRooms.Values) + { + if (room.IsLove == false) + { + listRoom.Add(room); + } + } + } + else + { + foreach (var room in this.dicRooms.Values) + { + if (room.FloorId == id && room.IsLove == false) + { + listRoom.Add(room); + } + } + } + listRoom.Insert(0, GetLoveRoom()); + return listRoom; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�) + /// </summary> + /// <returns></returns> + public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() + { + return this.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId); + } + + #endregion + + #region 鈻� 鎴块棿鏂规硶___________________________ + + /// <summary> + /// 璁惧鐨勬埧闂村彉鏇� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="roomId">鏂版埧闂碔d</param> + /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> + public void ChangedRoom(CommonDevice device, string roomId, bool saveRealRoom = true) + { + //鎴块棿鏄惁淇敼 + if (this.IsRoomChanged(device, roomId) == false) + { + return; + } + //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧 + this.DeleteDevice(device); + + //娣诲姞鍒版柊鐨勬埧闂� + var room = this.GetRoomById(roomId); + if (room != null) + { + this.AddDevice(room, device, saveRealRoom); + } + } + + /// <summary> + /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="roomId">鏂版埧闂碔d</param> + /// <returns></returns> + public bool IsRoomChanged(CommonDevice device, string roomId) + { + var room = this.GetRoomByDevice(device); + if (room == null || room.Id != roomId) + { + return true; + } + return false; + } + + /// <summary> + /// 鑾峰彇鎴块棿鎵�鍦ㄥ尯鍩� + /// 妤煎眰,鎴块棿鍚� + /// </summary> + /// <returns></returns> + public string GetZoneName(Room i_room) + { + if (string.IsNullOrEmpty(i_room.FloorId)) + { + return i_room.Name; + } + var floorName = Config.Instance.Home.GetFloorNameById(i_room.FloorId); + if (floorName == null) + { + return i_room.Name; + } + return $"{floorName}锛寋i_room.Name}"; + } + + #endregion + + #region 鈻� 娣诲姞璁惧___________________________ + + /// <summary> + /// 娣诲姞璁惧 + /// </summary> + /// <param name="i_room">鎴块棿瀵硅薄</param> + /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> + /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> + public void AddDevice(Room i_room, CommonDevice device, bool saveRealRoom) + { + if (device == null) + { + return; + } + //璁惧淇℃伅淇濆瓨鍒版湰鍦� + device.Save(); + + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + if (i_room.ListDevice.Contains(mainkeys) == false) + { + //淇濆瓨鍒版湰鍦� + i_room.ListDevice.Add(mainkeys); + i_room.Save(); + + if (i_room.IsLove == false && saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) + { + //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿 + LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, i_room.Id, false); + } + } + } + + /// <summary> + /// 娣诲姞鍠滅埍璁惧 + /// </summary> + /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> + public void AddLoveDevice(CommonDevice device) + { + if (device == null) + { + return; + } + //鎴戠殑鍠滅埍 + var loveRoom = this.GetLoveRoom(); + if (loveRoom != null) + { + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + if (loveRoom.ListDevice.Contains(mainkeys) == false) + { + //淇濆瓨鍒版湰鍦� + loveRoom.ListDevice.Add(mainkeys); + loveRoom.Save(); + } + } + } + + #endregion + + #region 鈻� 鍒犻櫎璁惧___________________________ + + /// <summary> + /// 鍒犻櫎璁惧(杩欎釜鍑芥暟涓嶅垹闄ゆ垜鐨勫枩鐖�) + /// </summary> + /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> + public void DeleteDevice(CommonDevice device) + { + if (device == null) + { + return; + } + //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿 + var room = this.GetRoomByDevice(device); + if (room == null) + { + return; + } + //绉婚櫎缂撳瓨 + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + room.ListDevice.Remove(mainkeys); + room.Save(); + //鏇存敼鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(room.FileName); + + //閫掑綊锛氬垹闄ゆ帀浠ュ墠鐨勬棫鏁版嵁瀵艰嚧鐨勫涓埧闂寸殑闂 + this.DeleteDevice(device); + } + + /// <summary> + /// 鍒犻櫎鎴戠殑鍠滅埍鐨勮澶� + /// </summary> + /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> + public void DeleteLoveDevice(CommonDevice device) + { + if (device == null) + { + return; + } + //鎴戠殑鍠滅埍 + var loveRoom = this.GetLoveRoom(); + if (loveRoom != null) + { + //绉婚櫎缂撳瓨 + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + loveRoom.ListDevice.Remove(mainkeys); + loveRoom.Save(); + //鏇存敼鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(loveRoom.FileName); + } + } + + #endregion + + #region 鈻� 鑾峰彇璁惧___________________________ + + /// <summary> + /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧 + /// </summary> + /// <returns></returns> + public List<CommonDevice> GetRoomListDevice(Room i_room) + { + var listDevice = new List<CommonDevice>(); + foreach (var mainKeys in i_room.ListDevice) + { + var device = LocalDevice.Current.GetDevice(mainKeys); + if (device != null) + { + listDevice.Add(device); + } + } + return listDevice; + } + + /// <summary> + /// 鑾峰彇鎴块棿璁惧绫诲瀷 + /// </summary> + /// <param name="room"></param> + /// <returns></returns> + public List<DeviceType> GetDeviceTypes(Room i_room) + { + var typeList = new List<DeviceType>(); + foreach (var mainKeys in i_room.ListDevice) + { + var device = LocalDevice.Current.GetDevice(mainKeys); + if (device != null) + { + typeList.Add(device.Type); + } + } + return typeList; + } + + /// <summary> + /// 鑾峰彇璇ョ被鍨嬬殑璁惧 + /// </summary> + /// <param name="room"></param> + /// <param name="deviceType"></param> + /// <returns></returns> + public List<CommonDevice> GetRoomListDevice(Room room, DeviceType deviceType) + { + List<CommonDevice> typeList = new List<CommonDevice>(); + foreach (var mainKeys in room.ListDevice) + { + var device = LocalDevice.Current.GetDevice(mainKeys); + if (device != null && device.Type == deviceType) + { + typeList.Add(device); + } + } + + return typeList; + } + + /// <summary> + /// 鑾峰彇鏈垎閰嶅尯鍩熻澶� + /// </summary> + /// <returns></returns> + public List<CommonDevice> GetUnalloctedDevice() + { + var listDevice = new List<CommonDevice>(); + + //宸茬粡瀛樺湪鐨勮澶� + var listEsxit = new HashSet<string>(); + foreach (var room in this.dicRooms.Values) + { + foreach (string mainkeys in room.ListDevice) + { + if (listEsxit.Contains(mainkeys) == false) + { + listEsxit.Add(mainkeys); + } + } + } + + //鎵�鏈夎澶� + var commonDeviceList = LocalDevice.Current.listAllDevice; + foreach (var device in commonDeviceList) + { + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + if (listEsxit.Contains(mainkeys) == false) + { + listDevice.Add(device); + } + } + if (listDevice.Count == 0) + { + return null; + } + return listDevice; + } + + /// <summary> + /// 鑾峰彇鍏ㄩ儴鎴块棿鍏ㄩ儴鐨勮澶� + /// </summary> + /// <returns></returns> + public List<CommonDevice> GetAllRoomListDevice() + { + var listDevice = new List<CommonDevice>(); + foreach (var room in this.dicRooms.Values) + { + if (room.IsSharedRoom || room.IsLove) + { + continue; + } + listDevice.AddRange(this.GetRoomListDevice(room)); + } + return listDevice; + } + + #endregion + + #region 鈻� 璁惧鏄惁鏀惰棌_______________________ + + /// <summary> + /// 鏄惁鏄敹钘忚澶� + /// </summary> + /// <param name="filePath"></param> + /// <returns></returns> + public bool IsCollectInRoom(CommonDevice device) + { + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); + //鍠滅埍鎴块棿 + var room = this.GetLoveRoom(); + return room.ListDevice.Contains(mainkeys); + } + + /// <summary> + /// 鏄惁鏄敹钘忚澶� + /// </summary> + /// <param name="filePath"></param> + /// <returns></returns> + public bool IsCollectInRoom(SceneUI scene) + { + //鍠滅埍鎴块棿 + var room = this.GetLoveRoom(); + return room.ListSceneId.Contains(scene.Id); + } + + #endregion + + #region 鈻� 妤煎眰鍜屾埧闂撮『搴忕浉鍏砡________________ + + /// <summary> + /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� + /// </summary> + /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> + /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> + /// <returns></returns> + public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } + + var listRoomSort = new List<string>(); + if (dicAllSort.ContainsKey(i_floorKeys) == true) + { + listRoomSort = dicAllSort[i_floorKeys]; + } + else + { + dicAllSort[i_floorKeys] = listRoomSort; + } + + var dicRoom = new Dictionary<string, Common.Room>(); + foreach (var room in this.dicRooms.Values) + { + if (room.FloorId != i_floorKeys || room.IsLove == true) + { + //涓嶆槸鍚屼竴涓ゼ灞� + continue; + } + if (listRoomSort.Contains(room.Id) == false) + { + //鏂版坊鍔犵殑鎴块棿 + listRoomSort.Add(room.Id); + } + if (getShard == false && room.IsSharedRoom == true) + { + //涓嶈鍒嗕韩鐨勬埧闂� + continue; + } + dicRoom[room.Id] = room; + } + + var listSortRoom = new List<Room>(); + for (int i = 0; i < listRoomSort.Count; i++) + { + if (dicRoom.ContainsKey(listRoomSort[i]) == true) + { + listSortRoom.Add(dicRoom[listRoomSort[i]]); + } + } + + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + return listSortRoom; + } + + /// <summary> + /// 淇濆瓨鎴块棿鐨勯『搴� + /// </summary> + /// <param name="i_floorKeys">妤煎眰涓婚敭</param> + /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> + public void SaveRoomSort(string i_floorKeys, List<string> listSort) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } + + //淇濆瓨椤哄簭 + dicAllSort[i_floorKeys] = listSort; + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + dicAllSort.Clear(); + } + + /// <summary> + /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 + /// </summary> + /// <returns></returns> + public Dictionary<string, string> GetFloorSortList() + { + //璇诲彇妤煎眰椤哄簭 + var listFloorSort = new List<string>(); + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); + } + foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) + { + if (listFloorSort.Contains(keys) == false) + { + //鏂版坊鍔犵殑妤煎眰 + listFloorSort.Add(keys); + } + } + + var dic = new Dictionary<string, string>(); + for (int i = 0; i < listFloorSort.Count; i++) + { + if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) + { + dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; + } + } + + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listFloorSort); + return dic; + } + + /// <summary> + /// 淇濆瓨妤煎眰鐨勯『搴� + /// </summary> + /// <param name="listSort">妤煎眰鐨勪富閿�</param> + public void SaveFloorSort(List<string> listSort) + { + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listSort); + } + + #endregion + + #region 鈻� 鍏嬮殕鎴块棿瀵硅薄_______________________ + + /// <summary> + /// 鍏嬮殕鎴块棿瀵硅薄 + /// </summary> + /// <returns></returns> + public Room CloneRoomClass(Room i_room) + { + var newRoom = new Room(); + //鍏嬮殕灞炴�� + newRoom.Id = i_room.Id; + newRoom.FloorId = i_room.FloorId; + newRoom.TemperatrueDevice = i_room.TemperatrueDevice; + newRoom.Temperatrue = i_room.Temperatrue; + newRoom.HumidityDevice = i_room.HumidityDevice; + newRoom.Humidity = i_room.Humidity; + newRoom.Name = i_room.Name; + newRoom.BackgroundImage = i_room.BackgroundImage; + newRoom.BackgroundImageType = i_room.BackgroundImageType; + + return newRoom; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 妫�娴嬫垜鐨勫枩鐖辫繖涓埧闂村璞� + /// </summary> + private void CheckLoveRoom() + { + if (Config.Instance.Home.ListRooms.Contains("Favorite") == false) + { + //榛樿娣诲姞鍠滅埍鐨勬埧闂�--绂佹淇敼鎴块棿鍚� + var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.JPG", Id = "Favorite" }; + love.Save(false); + //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃 + var currentHome = Config.Instance.Home; + currentHome.ListRooms.Insert(0, love.Id); + currentHome.Save(false); + + this.dicRooms["Favorite"] = love; + } + } + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlSceneLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlSceneLogic.cs new file mode 100755 index 0000000..6bfcf49 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlSceneLogic.cs @@ -0,0 +1,490 @@ +锘縰sing Shared.Common; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 鍦烘櫙鐨勯�昏緫 + /// </summary> + public class HdlSceneLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鍦烘櫙鐨勯�昏緫 + /// </summary> + private static HdlSceneLogic m_Current = null; + /// <summary> + /// 鍦烘櫙鐨勯�昏緫 + /// </summary> + public static HdlSceneLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlSceneLogic(); + } + return m_Current; + } + } + + /// <summary> + /// 鍦烘櫙瀵硅薄 + /// </summary> + private Dictionary<int, SceneUI> dicScenes = new Dictionary<int, SceneUI>(); + + #endregion + + #region 鈻� 鍒锋柊鍦烘櫙___________________________ + + /// <summary> + /// 浠庢湰鍦板埛鏂板満鏅� + /// </summary> + public void ReFreshByLocal() + { + //娓呯┖鍦烘櫙 + this.dicScenes.Clear(); + //鑾峰彇鍏ㄩ儴鏂囦欢 + var listFile = this.GetAllSceneFile(); + foreach (string fileName in listFile) + { + try + { + var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(fileName)); + var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); + if (tempScene == null) + { + continue; + } + this.dicScenes[tempScene.Id] = tempScene; + } + catch(Exception ex) + { + HdlLogLogic.Current.WriteLog(ex); + try + { + //鍒犳帀閿欒鏂囦欢 + Global.DeleteFilebyHomeId(fileName); + } + catch { } + } + } + } + + /// <summary> + /// 鍒锋柊鎴块棿鐨勫満鏅垪琛� + /// </summary> + public async Task<bool> RefreshSceneUIList() + { + //鑾峰彇缃戝叧瀛樺湪鐨勫満鏅� + var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); + if (sceneList == null) + { + return false; + } + var listEsxit = new HashSet<int>(); + foreach (var scene in sceneList) + { + if (scene == null) + { + continue; + } + listEsxit.Add(scene.ScenesId); + } + + var listDelete = new List<SceneUI>(); + foreach (var scId in this.dicScenes.Keys) + { + if (listEsxit.Contains(scId) == false) + { + //鍒犻櫎鐨勫璞� + listDelete.Add(this.dicScenes[scId]); + } + } + foreach (var sceneui in listDelete) + { + //鎵ц鍒犻櫎 + this.RemoveScene(sceneui); + } + + return true; + } + + #endregion + + #region 鈻� 娣诲姞鍦烘櫙___________________________ + + /// <summary> + /// 娣诲姞鍦烘櫙(鏇存柊缃戝叧) 0澶辫触 1鎴愬姛 -1宸茬粡瀛樺湪 + /// </summary> + /// <returns>The scene.</returns> + /// <param name="sceneName">Scene name.</param> + /// <param name="sceneIconPath">鑳屾櫙鍥剧墖锛屼笉鍖呭惈浣忓畢璺緞 濡傛灉iconPathType=1鎴栬��2 闇�瑕佹嫾鎺ヤ綇瀹� 鍙樻垚 浣忓畢/sceneIconPath</param> + /// <param name="commons">Commons.</param> + /// <param name="iconPathType">I鍦烘櫙鑳屾櫙鍥剧墖鏉ユ簮绫诲瀷 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 榛樿0</param> + public async Task<int> AddScene(Room i_room, string sceneName, string sceneIconPath, List<Scene.AddSceneMemberData> commons, int iconPathType) + { + var getSceneIdAllData = await Scene.GetSceneNewIdAsync(sceneName); + if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) + { + return 0; + } + var getSceneIdData = getSceneIdAllData.getSceneIdData; + + bool result = true; + foreach (var common in commons) + { + //娣诲姞鏂版垚鍛� + var addSceneMemberData = new Scene.AddSceneMemberData + { + Type = common.Type, + DeviceAddr = common.DeviceAddr, + Epoint = common.Epoint, + ScenesId = getSceneIdData.NewScenesId, + TaskList = common.TaskList, + DelayTime = common.DelayTime, + MemberNumber = common.MemberNumber, + ElseScenesId = common.ElseScenesId + }; + //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 + var addSceneMemberResponseAllData = await Scene.AddSceneMemberAsync(addSceneMemberData); + if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) + { + continue; + } + var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; + if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) + { + result = false; + } + } + //鍔犲叆鎴愬姛 + if (result) + { + var sceneUI = new SceneUI + { + Name = sceneName, + Id = getSceneIdData.NewScenesId, + IconPath = sceneIconPath, + IconPathType = iconPathType, + AddSceneMemberDataList = commons + }; + //娣诲姞缂撳瓨 + sceneUI.Save(); + this.dicScenes[sceneUI.Id] = sceneUI; + if (i_room.ListSceneId.Contains(sceneUI.Id) == false) + { + i_room.ListSceneId.Add(sceneUI.Id); + i_room.Save(); + } + return 1; + } + return 0; + } + + /// <summary> + /// 娣诲姞鍦烘櫙(杩欎釜鍗曠函鍙敼鎴块棿) + /// </summary> + /// <param name="scene">Scene.</param> + public void AddScene(Room i_room, SceneUI scene) + { + //娣诲姞缂撳瓨 + if (i_room.ListSceneId.Contains(scene.Id) == false) + { + i_room.ListSceneId.Add(scene.Id); + i_room.Save(); + } + } + + /// <summary> + /// 鍒犻櫎鍦烘櫙(杩欎釜鍙Щ闄ゅ唴瀛�) + /// </summary> + /// <param name="scene"></param> + public void DeleteScene(Room i_room, SceneUI scene) + { + //绉婚櫎缂撳瓨 + if (i_room.ListSceneId.Contains(scene.Id) == true) + { + i_room.ListSceneId.Remove(scene.Id); + i_room.Save(); + } + } + + #endregion + + #region 鈻� 淇敼鍦烘櫙___________________________ + + /// <summary> + /// 淇敼鍦烘櫙璁惧 0澶辫触 1鎴愬姛 + /// </summary> + /// <returns>The scene.</returns> + /// <param name="sceneUI">Scene user interface.</param> + /// <param name="sceneRemoveMemberData">Scene remove member data.</param> + /// <param name="addCommons">Add commons.</param> + public async Task<int> ModifyScene(SceneUI sceneUI, Scene.SceneRemoveMemberData sceneRemoveMemberData, List<Scene.AddSceneMemberData> addCommons) + { + bool result = true; + //绉婚櫎鎴愬憳 杩斿洖缁撴灉 + var removeSceneMemberResponseAllData = await ZigBee.Device.Scene.RemoveSceneMemberAsync(sceneRemoveMemberData); + if (removeSceneMemberResponseAllData == null || removeSceneMemberResponseAllData.removeSceneMemberResponseData == null) + { + return 0; + } + var removeSceneMemberResponseData = removeSceneMemberResponseAllData.removeSceneMemberResponseData; + if (removeSceneMemberResponseData == null) + { + return 0; + } + if (removeSceneMemberResponseData.Result != 0) + { + result = false; + } + //娣诲姞 + foreach (var addCommon in addCommons) + { + //娣诲姞鏂版垚鍛� + var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData + { + DeviceAddr = addCommon.DeviceAddr, + Type = addCommon.Type, + Epoint = addCommon.Epoint, + ScenesId = sceneUI.Id, + TaskList = addCommon.TaskList, + DelayTime = addCommon.DelayTime, + ElseScenesId = addCommon.ElseScenesId, + MemberNumber = addCommon.MemberNumber + }; + //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 + var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); + if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) + { + result = false; + System.Console.WriteLine("娣诲姞鍦烘櫙澶辫触"); + continue; + } + var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; + if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) + { + result = false; + } + } + //鍔犲叆鎴愬姛 + if (result) + { + sceneUI.AddSceneMemberDataList = addCommons; + sceneUI.Save(); + return 1; + } + return 0; + } + + #endregion + + #region 鈻� 鍒犻櫎鍦烘櫙___________________________ + + /// <summary> + /// 绉婚櫎鍦烘櫙--璇ヤ粎杩涜浜嗗鏈湴鍦烘櫙鏁版嵁鐨勫垹闄� + /// </summary> + /// <param name="sceneUI">Scene user interface.</param> + public void RemoveScene(SceneUI sceneUI) + { + //绉婚櫎缂撳瓨 + this.dicScenes.Remove(sceneUI.Id); + var room = HdlRoomLogic.Current.GetRoomBySceneId(sceneUI.Id); + if (room != null) + { + room.ListSceneId.Remove(sceneUI.Id); + room.Save(); + } + + //绉婚櫎鍠滅埍 + var roomLove = HdlRoomLogic.Current.GetLoveRoom(); + if (roomLove.ListSceneId.Contains(sceneUI.Id) == true) + { + roomLove.ListSceneId.Remove(sceneUI.Id); + roomLove.Save(); + } + + //鍒犻櫎鏂囦欢 + if (Global.IsExistsByHomeId(sceneUI.FileName) == true) + { + Global.DeleteFilebyHomeId(sceneUI.FileName); + HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); + } + //鍒犻櫎鍥剧墖 + if (sceneUI.IconPathType == 1 || sceneUI.IconPathType == 2) + { + if (Global.IsExistsByHomeId(sceneUI.IconPath)) + { + Global.DeleteFilebyHomeId(sceneUI.IconPath); + HdlAutoBackupLogic.DeleteFile(sceneUI.IconPath); + } + } + } + + #endregion + + #region 鈻� 鑾峰彇鍦烘櫙___________________________ + + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鍦烘櫙 + /// </summary> + /// <returns>The scene UIB y scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public SceneUI GetSceneUIBySceneId(int sceneId) + { + if (this.dicScenes.ContainsKey(sceneId) == true) + { + return this.dicScenes[sceneId]; + } + return null; + } + + /// <summary> + /// 鑾峰彇璇ユゼ灞傛墍鏈夊満鏅� + /// </summary> + /// <param name="floorId"></param> + /// <returns></returns> + public List<SceneUI> GetSameFloorScenes(string floorId) + { + List<SceneUI> sceneUIs = new List<SceneUI>(); + var rooms = HdlRoomLogic.Current.GetRoomsByFloorId(floorId); + foreach (var r in rooms) + { + foreach (int sceneId in r.ListSceneId) + { + if (this.dicScenes.ContainsKey(sceneId) == true) + { + sceneUIs.Add(this.dicScenes[sceneId]); + } + } + } + return sceneUIs; + } + + /// <summary> + /// 鏍规嵁鍦烘櫙Id锛岃幏鍙栨ゼ灞傚拰鎴块棿鍚嶅瓧(妤煎眰,鎴块棿鍚嶅瓧) + /// </summary> + /// <returns></returns> + public string GetZoneById(int sceneId) + { + var room =HdlRoomLogic.Current.GetRoomBySceneId(sceneId); + if (room == null) + { + return null; + } + var floorName = Shared.Common.Config.Instance.Home.GetFloorNameById(room.FloorId); + if (floorName == null) + { + return room.Name; + } + return $"{floorName},{room.Name}"; + } + + /// <summary> + /// 鑾峰彇鏈垎閰嶅尯鍩熷満鏅� + /// </summary> + /// <returns></returns> + public List<SceneUI> GetUnalloctedScenes() + { + List<SceneUI> sceneUIs = new List<SceneUI>(); + //宸茬粡瀛樺湪鐨勫満鏅� + var listEsxit = new HashSet<int>(); + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) + { + foreach (int sceneId in room.ListSceneId) + { + if (listEsxit.Contains(sceneId) == false) + { + listEsxit.Add(sceneId); + } + } + } + foreach (var myScene in this.dicScenes.Values) + { + if (listEsxit.Contains(myScene.Id) == false) + { + sceneUIs.Add(myScene); + } + } + + if (sceneUIs.Count == 0) + { + return null; + } + return sceneUIs; + } + + /// <summary> + /// 鑾峰彇鍏ㄩ儴鎴块棿鐨勫叏閮ㄥ満鏅� + /// </summary> + /// <returns></returns> + public List<SceneUI> GetAllRoomSceneList() + { + List<SceneUI> sceneUIs = new List<SceneUI>(); + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) + { + foreach (int sceneId in room.ListSceneId) + { + if (this.dicScenes.ContainsKey(sceneId) == true) + { + sceneUIs.Add(this.dicScenes[sceneId]); + } + } + } + + return sceneUIs; + } + + /// <summary> + /// 鑾峰彇鎸囧畾鎴块棿鐨勫叏閮ㄥ満鏅� + /// </summary> + /// <returns></returns> + public List<SceneUI> GetRoomSceneList(Room i_room) + { + List<SceneUI> sceneUIs = new List<SceneUI>(); + foreach (int sceneId in i_room.ListSceneId) + { + if (this.dicScenes.ContainsKey(sceneId) == true) + { + sceneUIs.Add(this.dicScenes[sceneId]); + } + } + + return sceneUIs; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鑾峰彇鏈湴鍏ㄩ儴鐨勫満鏅枃浠� + /// </summary> + /// <returns></returns> + public List<string> GetAllSceneFile() + { + List<string> listSceneFile = new List<string>(); + List<string> listAllFile = Global.FileListByHomeId(); + + foreach (string file in listAllFile) + { + if (file.StartsWith("Scene_") == false) + { + //濡傛灉涓嶆槸鍦烘櫙鏂囦欢 + continue; + } + listSceneFile.Add(file); + } + return listSceneFile; + } + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs index 0919c1e..8ec74ce 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs @@ -67,7 +67,7 @@ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; for (int i = 0; i < listDistributedMark.Count; i++) { @@ -78,7 +78,7 @@ { //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } var dataResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetShardInfoResult>(result); @@ -92,7 +92,7 @@ //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return listFile; } @@ -309,7 +309,7 @@ if (fileName.StartsWith("Room_") == true) { //鎴块棿鏂囦欢鐗规畩澶勭悊 - Config.Instance.Home.AddRoomListFilePath(fileName); + Config.Instance.Home.AddRoomId(fileName.Replace("Room_", string.Empty).Replace(".json", string.Empty)); } } //娓呯┖鍏变韩鏂囦欢澶� @@ -407,10 +407,8 @@ //鍒犻櫎鎺夎繖涓埧闂存枃浠� Global.DeleteFilebyHomeId(fileName); dicUpdateTime.Remove(fileName); - if (Config.Instance.Home.RoomFilePathList.Contains(fileName) == true) - { - Config.Instance.Home.RemoveRoomListFilePath(fileName); - } + + Config.Instance.Home.RemoveRoomId(nowRoom.Id); } //妫�娴嬫湰鍦板満鏅枃浠�,鏄惁瀛樺湪宸茬粡鍙栨秷浜嗗叡浜簡鐨� else if (fileName.StartsWith("Scene_") == true) @@ -565,8 +563,10 @@ memberShardInfo.dicShardRoom = new Dictionary<string, Common.Room>(); this.dicShardDeviceFile.Clear(); - var listDeviceFile = new HashSet<string>(); - var listSceneFile = new HashSet<string>(); + //keys:涓婚敭 value:鏂囦欢鍚� + var dicDeviceFile = new Dictionary<string, string>(); + //keys:鍦烘櫙id value:鏂囦欢鍚� + var dicSceneFile = new Dictionary<int, string>(); var listFile = this.GetLocalAllShardFile(); //鍏堝垵濮嬪寲鎴块棿 @@ -602,54 +602,57 @@ this.dicShardDeviceFile[mainKeys] = fileName; //璁惧鏂囦欢 - listDeviceFile.Add(fileName); + dicDeviceFile[mainKeys] = fileName; } else if (fileName.StartsWith("Scene_") == true) { //鍦烘櫙鏂囦欢 - listSceneFile.Add(fileName); + dicSceneFile[(Convert.ToInt32(fileName.Replace("Scene_", string.Empty).Replace(".json", string.Empty)))] = fileName; } } catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } } - //璁剧疆鎴块棿閲岄潰璁惧鐨刄I瀵硅薄(鍥犱负杩欎釜涓滆タ鏄弽搴忓垪鍖栧嚭鏉ョ殑,璁惧UI瀵硅薄鏄笉搴忓垪鍖栧璞�) + //妫�鏌ヨ澶囩殑鍖归厤鎯呭喌 foreach (var tempRoom in memberShardInfo.dicShardRoom.Values) { - //杩樺師璁惧瀵硅薄 - tempRoom.DeviceUIList.Clear(); - for (int i = 0; i < tempRoom.DeviceUIFilePathList.Count; i++) + //妫�鏌ヨ澶� + for (int i = 0; i < tempRoom.ListDevice.Count; i++) { - string deviceFile = tempRoom.DeviceUIFilePathList[i]; - //杩欎釜璁惧鏂囦欢鍖归厤寰楀埌鎴块棿 - listDeviceFile.Remove(deviceFile); - if (this.IsFileExists(deviceFile) == false) + string deviceKeys = tempRoom.ListDevice[i]; + if (dicDeviceFile.ContainsKey(deviceKeys) == false) { //绉婚櫎鎺夎繖涓笉瀵瑰姴鐨勮矾寰� - tempRoom.DeviceUIFilePathList.RemoveAt(i); + tempRoom.ListDevice.RemoveAt(i); i--; continue; } - tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFile)); + //杩欎釜璁惧鏂囦欢鍖归厤寰楀埌鎴块棿 + dicDeviceFile.Remove(deviceKeys); } - //杩樺師鍦烘櫙瀵硅薄 - tempRoom.SceneUIList.Clear(); - for (int i = 0; i < tempRoom.SceneUIFilePathList.Count; i++) + //妫�鏌ュ満鏅� + for (int i = 0; i < tempRoom.ListSceneId.Count; i++) { - string uiPath = tempRoom.SceneUIFilePathList[i]; + int intId = tempRoom.ListSceneId[i]; + if (dicSceneFile.ContainsKey(intId) == false) + { + //绉婚櫎鎺夎繖涓笉瀵瑰姴鐨勮矾寰� + tempRoom.ListSceneId.RemoveAt(i); + i--; + continue; + } + var byteData = this.GetShardFileContent(dicSceneFile[intId]); //杩欎釜鍦烘櫙鏂囦欢鍖归厤寰楀埌鎴块棿 - listSceneFile.Remove(uiPath); - var byteData = this.GetShardFileContent(uiPath); + dicSceneFile.Remove(intId); if (byteData == null) { //绉婚櫎鎺夎繖涓笉瀵瑰姴鐨勮矾寰� - tempRoom.SceneUIFilePathList.RemoveAt(i); + tempRoom.ListSceneId.RemoveAt(i); i--; continue; } string valueData = System.Text.Encoding.UTF8.GetString(byteData); var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData); - tempRoom.SceneUIList.Add(tempUi); //鑾峰彇鍦烘櫙閲岄潰鐨勫叏閮ㄧ洰鏍�(2019.11.05杩藉姞鎿嶄綔,鏈夊彲鑳介偅涓澶囨槸鐢卞満鏅祵濂楁潵鐨�,鎵�浠ュ畠鏈夊彲鑳戒笉灞炰簬浠讳綍鎴块棿) foreach (var data in tempUi.AddSceneMemberDataList) @@ -661,21 +664,19 @@ if (dicShardDeviceFile.ContainsKey(mainkey) == true ) { //杩欎釜璁惧鏂囦欢鍖归厤寰楀埌 - listDeviceFile.Remove(dicShardDeviceFile[mainkey]); + dicDeviceFile.Remove(mainkey); } } if (data.Type == 1) { - var temp = new SceneUI(); - temp.Id = data.ElseScenesId; //杩欎釜鍦烘櫙鏂囦欢鍖归厤寰楀埌 - listSceneFile.Remove(temp.FileName); + dicSceneFile.Remove(data.ElseScenesId); } } } } //濡傛灉瀛樺湪鍖归厤涓嶄笂鐨勬枃浠� - if (listDeviceFile.Count != 0 || listSceneFile.Count != 0) + if (dicDeviceFile.Count != 0 || dicSceneFile.Count != 0) { //鍒涘缓涓�涓复鏃舵埧闂存潵瀛樺偍 var roomTemp = new Room(); @@ -684,22 +685,36 @@ memberShardInfo.dicShardRoom[roomTemp.FileName] = roomTemp; roomTemp.Name = Language.StringByID(R.MyInternationalizationString.uUnallocated); //杩樺師璁惧瀵硅薄 - foreach (string deviceFile in listDeviceFile) + foreach (string deviceKeys in dicDeviceFile.Keys) { - roomTemp.DeviceUIFilePathList.Add(deviceFile); - roomTemp.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFile)); + roomTemp.ListDevice.Add(deviceKeys); } //杩樺師鍦烘櫙瀵硅薄 - foreach (string uiPath in listSceneFile) + foreach (int intId in dicSceneFile.Keys) { - var byteData = this.GetShardFileContent(uiPath); - string valueData = System.Text.Encoding.UTF8.GetString(byteData); - var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData); - roomTemp.SceneUIList.Add(tempUi); + roomTemp.ListSceneId.Add(intId); } } } + + #endregion + + #region 鈻� 鑾峰彇璁惧鏂囦欢鍚峗____________________ + + /// <summary> + /// 鑾峰彇璁惧鏂囦欢鍚�,涓嶅瓨鍦ㄦ椂,杩斿洖绌哄瓧绗︿覆(浠呴檺鍒嗕韩浜嗙殑璁惧) + /// </summary> + /// <param name="deviceKeys">璁惧涓婚敭</param> + /// <returns></returns> + public string GetShardDeviceFileName(string deviceKeys) + { + if (this.dicShardDeviceFile.ContainsKey(deviceKeys) == true) + { + return this.dicShardDeviceFile[deviceKeys]; + } + return string.Empty; + } #endregion @@ -744,7 +759,7 @@ } //闃叉鍑虹幇閿欒,鏆傛椂淇濆瓨涓や釜鍒楄〃(铏界劧娌¢偅涔堥夯鐑︼紝涓嶈繃鏃㈢劧宸茬粡杩欐牱鍐欎簡灏辫繖鏍蜂簡) var dicBackDevice = new Dictionary<string, List<string>>(); - var dicBackScene = new Dictionary<string, List<string>>(); + var dicBackScene = new Dictionary<string, List<int>>(); //涓存椂澶囦唤鎴块棿璁惧鍒楄〃 this.BackupRoomDevicelistTemporary(memberShardInfo, dicBackDevice, dicBackScene); @@ -754,7 +769,7 @@ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; if (BarMaxValue == -1) { @@ -784,7 +799,7 @@ //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; if (result == false) { @@ -829,7 +844,7 @@ if (memberShardInfo.dicShardRoom.ContainsKey(nowRoom.FileName) == false) { //鍏嬮殕涓�涓璞� - roomTemp = nowRoom.CloneRoomClass(); + roomTemp = HdlRoomLogic.Current.CloneRoomClass(nowRoom); memberShardInfo.TempRoom = roomTemp; //鏂板垎浜殑鎴块棿,濡傛灉鍥剧墖鏄嚜瀹氫箟鐨�,骞朵笖杩欎釜鍥剧墖鏄瓨鍦ㄧ殑,鍒欎笂浼犲浘鐗� if (roomTemp.BackgroundImageType != 0 && Common.Global.IsExistsByHomeId(roomTemp.BackgroundImage) == true) @@ -869,13 +884,12 @@ this.AddShardFile(device.FilePath); //鍔犵偣缂撳瓨 - this.dicShardDeviceFile[LocalDevice.Current.GetDeviceMainKeys(device)] = device.FilePath; + string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); + this.dicShardDeviceFile[mainKeys] = device.FilePath; - //璁惧鐨刄I - var deviceUi = device.FilePath; - if (roomTemp.DeviceUIFilePathList.Contains(deviceUi) == false) + if (roomTemp.ListDevice.Contains(mainKeys) == false) { - roomTemp.DeviceUIFilePathList.Add(deviceUi); + roomTemp.ListDevice.Add(mainKeys); } } //閫掑綊鑾峰彇鐨勮澶囦笉闇�瑕佸姞鍏ュ埌鎴块棿 @@ -902,9 +916,9 @@ listFile.Add(secene.FileName); this.AddShardFile(secene); - if (roomTemp.SceneUIFilePathList.Contains(secene.FileName) == false) + if (roomTemp.ListSceneId.Contains(secene.Id) == false) { - roomTemp.SceneUIFilePathList.Add(secene.FileName); + roomTemp.ListSceneId.Add(secene.Id); } } //閫掑綊鑾峰彇鐨勫満鏅笉闇�瑕佸姞鍏ュ埌鎴块棿 @@ -920,7 +934,7 @@ //鍙嶆妤煎眰鏂囦欢寰堝皬,涓�璧风粰杩囧幓鍚� if (roomTemp.FloorId != string.Empty) { - memberShardInfo.dicShardFloor[roomTemp.FloorId] = roomTemp.FloorName; ; + memberShardInfo.dicShardFloor[roomTemp.FloorId] = HdlResidenceLogic.Current.GetFloorNameById(roomTemp.FloorId); } this.AddShardFile(memberShardInfo.dicShardFloor); listFile.Add(DirNameResourse.ShardFloorFile); @@ -969,7 +983,7 @@ listCheck.Add(mainKeys); //鑾峰彇鍦烘櫙瀵硅薄 - var sceneUi = Room.CurrentRoom.GetSceneUIBySceneId(data.ElseScenesId); + var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(data.ElseScenesId); if (sceneUi != null) { listSceneUI.Add(sceneUi); @@ -1197,15 +1211,15 @@ /// <param name="dicBackDevice">绌虹殑璁惧澶囦唤鍒楄〃</param> /// <param name="dicBackScene">绌虹殑鍦烘櫙澶囦唤鍒楄〃</param> private void BackupRoomDevicelistTemporary(MemberShardInfoData memberShardInfo, Dictionary<string, List<string>> dicBackDevice, - Dictionary<string, List<string>> dicBackScene) + Dictionary<string, List<int>> dicBackScene) { foreach (var roomKeys in memberShardInfo.dicShardRoom.Keys) { dicBackDevice[roomKeys] = new List<string>(); - dicBackScene[roomKeys] = new List<string>(); + dicBackScene[roomKeys] = new List<int>(); - dicBackDevice[roomKeys].AddRange(memberShardInfo.dicShardRoom[roomKeys].DeviceUIFilePathList); - dicBackScene[roomKeys].AddRange(memberShardInfo.dicShardRoom[roomKeys].SceneUIFilePathList); + dicBackDevice[roomKeys].AddRange(memberShardInfo.dicShardRoom[roomKeys].ListDevice); + dicBackScene[roomKeys].AddRange(memberShardInfo.dicShardRoom[roomKeys].ListSceneId); } } @@ -1217,7 +1231,7 @@ /// <param name="dicBackScene">涓存椂澶囦唤鐨勫満鏅浠藉垪琛�</param> /// <param name="listFile">涓婁紶鐨勬枃浠跺悕</param> private void RecoverRoomDevicelistTemporary(MemberShardInfoData memberShardInfo, Dictionary<string, List<string>> dicBackDevice, - Dictionary<string, List<string>> dicBackScene, List<string> listFile) + Dictionary<string, List<int>> dicBackScene, List<string> listFile) { foreach (string fileName in listFile) { @@ -1231,11 +1245,11 @@ { continue; } - memberShardInfo.dicShardRoom[roomKeys].DeviceUIFilePathList.Clear(); - memberShardInfo.dicShardRoom[roomKeys].DeviceUIFilePathList.AddRange(dicBackDevice[roomKeys]); + memberShardInfo.dicShardRoom[roomKeys].ListDevice.Clear(); + memberShardInfo.dicShardRoom[roomKeys].ListDevice.AddRange(dicBackDevice[roomKeys]); - memberShardInfo.dicShardRoom[roomKeys].SceneUIFilePathList.Clear(); - memberShardInfo.dicShardRoom[roomKeys].SceneUIFilePathList.AddRange(dicBackScene[roomKeys]); + memberShardInfo.dicShardRoom[roomKeys].ListSceneId.Clear(); + memberShardInfo.dicShardRoom[roomKeys].ListSceneId.AddRange(dicBackScene[roomKeys]); //瑕嗙洊鎴块棿鏂囦欢 this.AddShardFile(memberShardInfo.dicShardRoom[roomKeys]); @@ -1262,25 +1276,25 @@ var roomTemp = memberShardInfo.dicShardRoom[nowRoom.FileName]; //闃叉鍑洪敊,鍏堝浠藉垪琛� var listBackDevice = new List<string>(); - listBackDevice.AddRange(roomTemp.DeviceUIFilePathList); - var listBackScene = new List<string>(); - listBackScene.AddRange(roomTemp.SceneUIFilePathList); + listBackDevice.AddRange(roomTemp.ListDevice); + var listBackScene = new List<int>(); + listBackScene.AddRange(roomTemp.ListSceneId); var listMark = new List<string>(); //瑕佸垹闄ょ殑鏂囦欢鍚嶅瓧 var listDeleteFile = new List<string>(); //闄や簡瑕佸垹闄ょ殑鐩爣澶栵紝杩樺垎浜殑鏁版嵁 - var listHadShard = this.GetAllShardedFileNameFromDictionary(memberShardInfo, nowRoom, listDevice, listSceneUI); + var listHadShardKeys = this.GetAllShardedKeysFromDictionary(memberShardInfo, nowRoom, listDevice, listSceneUI); //鍏堝紕璁惧 foreach (var device in listDevice) { string deviceFileName = device.FilePath; - + string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); //绉婚櫎璺緞鍒楄〃 - roomTemp.DeviceUIFilePathList.Remove(device.FilePath); - if (listHadShard.Contains(deviceFileName) == true) + roomTemp.ListDevice.Remove(mainKeys); + if (listHadShardKeys.Contains(mainKeys) == true) { //鍏朵粬鍦烘櫙鍒嗕韩鏈夎繖涓澶�,鎵�浠ヤ笉鍒犻櫎杩欎釜璁惧鐨勬牴婧愭枃浠�,鍙槸鎶婃埧闂寸殑璁惧鍒楄〃璺緞绉婚櫎 continue; @@ -1298,11 +1312,11 @@ foreach (var sceneUI in listSceneUI) { //绉婚櫎缂撳瓨 - roomTemp.SceneUIFilePathList.Remove(sceneUI.FileName); + roomTemp.ListSceneId.Remove(sceneUI.Id); //鍏朵粬鍦烘櫙杩樺祵濂楃潃杩欎釜鍦烘櫙,鎵�浠ヤ笉鍒犻櫎杩欎釜鍦烘櫙鐨勬牴婧愭枃浠�,鍙槸鎶婃埧闂寸殑鍦烘櫙鍒楄〃璺緞绉婚櫎 //浣嗘槸瀹冪粦瀹氱殑璁惧鐩爣瑕佸垹闄� - if (listHadShard.Contains(sceneUI.FileName) == true) + if (listHadShardKeys.Contains(sceneUI.Id.ToString()) == true) { continue; } @@ -1326,26 +1340,31 @@ } //鎵ц鍒犻櫎宓屽鐨勮澶� - var listTemp = new HashSet<string>(); - var dicBindScene = new Dictionary<string, SceneUI>(); - this.GetSceneBindFileName(sceneUI, ref listTemp, ref dicBindScene); - foreach (var fileName in listTemp) + var dicDeviceKeys = new Dictionary<string, string>(); + var listBindScene = new List<SceneUI>(); + this.GetSceneBindListKeys(sceneUI, ref dicDeviceKeys, ref listBindScene); + //璁惧鐨� + foreach (var myKeys in dicDeviceKeys.Keys) { - if (listHadShard.Contains(fileName) == true) + if (listHadShardKeys.Contains(myKeys) == true) { continue; } //鑾峰彇瑕佸垹闄ょ殑鍒嗕韩涓婚敭 + string fileName = dicDeviceKeys[myKeys]; if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == true) { listMark.Add(memberShardInfo.dicAllShardKeys[fileName]); } listDeleteFile.Add(fileName); - - if (dicBindScene.ContainsKey(fileName) == true && dicBindScene[fileName].IconPathType != 0) + } + //鍦烘櫙鐨� + foreach (var seceUi in listBindScene) + { + if (seceUi.IconPathType != 0) { //鍒犻櫎鑷畾涔夊満鏅浘鐗�,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰� - string[] Arry = dicBindScene[fileName].IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); + string[] Arry = seceUi.IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); string sceneFile = Arry[Arry.Length - 1]; listDeleteFile.Add(sceneFile); if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneFile) == true) @@ -1357,7 +1376,7 @@ } //濡傛灉杩欎釜鎴块棿鐨勫垎浜澶囧拰鍦烘櫙鍏ㄩ儴鍒犻櫎鐨勮瘽,鎶婂垎浜埧闂存枃浠朵篃涓�璧峰垹闄� - if (roomTemp.DeviceUIFilePathList.Count == 0 && roomTemp.SceneUIFilePathList.Count == 0) + if (roomTemp.ListDevice.Count == 0 && roomTemp.ListSceneId.Count == 0) { //鎴块棿鍒犻櫎 if (memberShardInfo.dicAllShardKeys.ContainsKey(nowRoom.FileName) == true) @@ -1408,11 +1427,11 @@ if (result == false) { //鎭㈠ - roomTemp.DeviceUIFilePathList.Clear(); - roomTemp.DeviceUIFilePathList.AddRange(listBackDevice); + roomTemp.ListDevice.Clear(); + roomTemp.ListDevice.AddRange(listBackDevice); - roomTemp.SceneUIFilePathList.Clear(); - roomTemp.SceneUIFilePathList.AddRange(listBackScene); + roomTemp.ListSceneId.Clear(); + roomTemp.ListSceneId.AddRange(listBackScene); } return result; } @@ -1585,93 +1604,96 @@ #region 鈻� 绉婚櫎鍏变韩鐨勪竴鑸柟娉昣________________ /// <summary> - /// 浠庣紦瀛樺瓧鍏镐腑鑾峰彇宸茬粡鍒嗕韩浜嗙殑鍏ㄩ儴璁惧鏂囦欢鍜屽満鏅殑鏂囦欢鍚嶅瓧 + /// 浠庣紦瀛樺瓧鍏镐腑鑾峰彇宸茬粡鍒嗕韩浜嗙殑鍏ㄩ儴璁惧涓婚敭鍜屽満鏅殑ID /// </summary> /// <param name="memberShardInfo">鎴愬憳鐨勫垎浜俊鎭�</param> /// <param name="nowRoom">褰撳墠鎴块棿</param> /// <param name="listDeleteDevice">瑕佸垹闄ょ殑璁惧鍒楄〃</param> /// <param name="listDeleteScene">瑕佸垹闄ょ殑鍦烘櫙鍒楄〃</param> /// <returns></returns> - private HashSet<string> GetAllShardedFileNameFromDictionary(MemberShardInfoData memberShardInfo, Common.Room nowRoom, + private HashSet<string> GetAllShardedKeysFromDictionary(MemberShardInfoData memberShardInfo, Common.Room nowRoom, List<CommonDevice> listDeleteDevice, List<Common.SceneUI> listDeleteScene) { //鑾峰彇鍏ㄩ儴瑕佸垹闄ょ殑鏂囦欢鍚嶅瓧 - var listDeleteFile = new HashSet<string>(); + var dicDeleteDeviceFile = new Dictionary<string, string>(); foreach (var device in listDeleteDevice) { - listDeleteFile.Add(device.FilePath); + dicDeleteDeviceFile[LocalDevice.Current.GetDeviceMainKeys(device)] = device.FilePath; } + var dicDeleteSceneFile = new Dictionary<int, string>(); foreach (var scene in listDeleteScene) { - listDeleteFile.Add(scene.FileName); + dicDeleteSceneFile[scene.Id] = scene.FileName; } - var listShardFile = new HashSet<string>(); - //鑾峰彇杩樺浜庡垎浜姸鎬佺殑鏂囦欢 + var listShardKeys = new HashSet<string>(); + //鑾峰彇杩樺浜庡垎浜姸鎬佺殑涓婚敭 foreach (var roomTemp in memberShardInfo.dicShardRoom.Values) { //璁惧 - foreach (var deviceUi in roomTemp.DeviceUIFilePathList) + foreach (var deviceKeys in roomTemp.ListDevice) { - string deviceFile = deviceUi; - if (listDeleteFile.Contains(deviceFile) == true) + if (dicDeleteDeviceFile.ContainsKey(deviceKeys) == true) { //鍥犱负涓�涓洖璺彧鑳藉垎閰嶄竴涓尯鍩�,鎵�浠ュ彲浠ョ洿鎺ュ垽鏂� continue; } - if (listShardFile.Contains(deviceFile) == false) + if (listShardKeys.Contains(deviceKeys) == false) { //杩欎釜鏂囦欢杩樺垎浜潃 - listShardFile.Add(deviceFile); + listShardKeys.Add(deviceKeys); } } //鍦烘櫙 - foreach (var scene in roomTemp.SceneUIList) + foreach (var sceneId in roomTemp.ListSceneId) { - if (roomTemp.SceneUIFilePathList.Contains(scene.FileName) == false) - { - //杩欎釜鍦烘櫙宸茬粡琚垹闄� - continue; - } if (roomTemp.FileName == nowRoom.FileName) { //濡傛灉寰幆鍒颁簡褰撳墠鎴块棿 - if (listDeleteFile.Contains(scene.FileName) == true) + if (dicDeleteSceneFile.ContainsKey(sceneId) == true) { //濡傛灉鏄垹闄ょ洰鏍囷紝鍒欎笉娣诲姞 continue; } } - //鑾峰彇鍦烘櫙閲岄潰鐨勫叏閮ㄧ洰鏍� - var listTemp = new HashSet<string>(); - var dicTemp = new Dictionary<string, SceneUI>(); - this.GetSceneBindFileName(scene, ref listTemp, ref dicTemp); - - if (listShardFile.Contains(scene.FileName) == false) + var byteData = this.GetShardFileContent($"Scene_{sceneId}.json"); + if (byteData == null) { - //鍦烘櫙鑷韩鐨勬枃浠� - listShardFile.Add(scene.FileName); + continue; } - foreach (string file in listTemp) + string valueData = System.Text.Encoding.UTF8.GetString(byteData); + var sceneTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData); + + //鑾峰彇鍦烘櫙閲岄潰鐨勫叏閮ㄧ洰鏍� + var listTempKeys = new HashSet<string>(); + //浠庡満鏅璞¢噷闈㈣幏鍙栧叏閮ㄧ殑缁戝畾鐩爣鐨勪富閿�(杩欓噷闈㈢殑涓滆タ蹇呴』浠庡垎浜暟鎹腑鑾峰彇) + this.GetSceneBindListKeys(sceneTemp, ref listTempKeys); + + if (listShardKeys.Contains(sceneId.ToString()) == false) { - if (listShardFile.Contains(file) == false) + //鍦烘櫙鑷韩 + listShardKeys.Add(sceneId.ToString()); + } + foreach (string myKeys2 in listTempKeys) + { + if (listShardKeys.Contains(myKeys2) == false) { - listShardFile.Add(file); + listShardKeys.Add(myKeys2); } } } } - return listShardFile; + return listShardKeys; } /// <summary> - /// 浠庡満鏅璞¢噷闈㈣幏鍙栧叏閮ㄧ殑缁戝畾鐩爣鐨勬枃浠跺悕瀛�(杩欓噷闈㈢殑涓滆タ蹇呴』浠庡垎浜暟鎹腑鑾峰彇) + /// 浠庡満鏅璞¢噷闈㈣幏鍙栧叏閮ㄧ殑缁戝畾鐩爣鐨勪富閿�(杩欓噷闈㈢殑涓滆タ蹇呴』浠庡垎浜暟鎹腑鑾峰彇) /// </summary> /// <param name="scene">鍦烘櫙</param> - /// <param name="listFile">鏂囦欢鍒楄〃(閲岄潰瀛樼殑鏄澶嘦I鏂囦欢鍜岃澶囨枃浠跺拰鍦烘櫙鏂囦欢)</param> - /// <param name="dicBindScene">缁戝畾鐨勫満鏅璞�</param> - private void GetSceneBindFileName(Common.SceneUI scene, ref HashSet<string> listFile,ref Dictionary<string, SceneUI> dicBindScene) + /// <param name="dicDeviceKeys">璁惧涓婚敭鍒楄〃(閲岄潰娌℃湁鍦烘櫙),keys:涓婚敭,value:鏂囦欢鍚�</param> + /// <param name="listBindScene">缁戝畾鐨勫満鏅璞�</param> + private void GetSceneBindListKeys(Common.SceneUI scene, ref Dictionary<string, string> dicDeviceKeys, ref List<SceneUI> listBindScene) { foreach (var data in scene.AddSceneMemberDataList) { @@ -1679,25 +1701,47 @@ if (data.Type == 0) { string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint); - if (dicShardDeviceFile.ContainsKey(mainkey) == true && listFile.Contains(dicShardDeviceFile[mainkey]) == false) + if (dicShardDeviceFile.ContainsKey(mainkey) == true && dicDeviceKeys.ContainsKey(mainkey) == false) { - listFile.Add(dicShardDeviceFile[mainkey]); + dicDeviceKeys[mainkey] = dicShardDeviceFile[mainkey]; } } if (data.Type == 1) { - var temp = new SceneUI(); - temp.Id = data.ElseScenesId; - var byteData = this.GetShardFileContent(temp.FileName); + var byteData = this.GetShardFileContent($"Scene_{data.ElseScenesId}.json"); if (byteData != null) { string valueData = System.Text.Encoding.UTF8.GetString(byteData); - var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData); - dicBindScene[roomTemp.FileName] = roomTemp; - if (listFile.Contains(roomTemp.FileName) == false) - { - listFile.Add(roomTemp.FileName); - } + var sceneTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData); + listBindScene.Add(sceneTemp); + } + } + } + } + + /// <summary> + /// 浠庡満鏅璞¢噷闈㈣幏鍙栧叏閮ㄧ殑缁戝畾鐩爣鐨勪富閿�(杩欓噷闈㈢殑涓滆タ蹇呴』浠庡垎浜暟鎹腑鑾峰彇) + /// </summary> + /// <param name="scene">鍦烘櫙</param> + /// <param name="listKeys">涓婚敭鍒楄〃(璁惧鍜屽満鏅�)</param> + private void GetSceneBindListKeys(Common.SceneUI scene, ref HashSet<string> listKeys) + { + foreach (var data in scene.AddSceneMemberDataList) + { + //璁惧 + if (data.Type == 0) + { + string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint); + if (listKeys.Contains(mainkey) == false) + { + listKeys.Add(mainkey); + } + } + if (data.Type == 1) + { + if (listKeys.Contains(data.ElseScenesId.ToString()) == false) + { + listKeys.Add(data.ElseScenesId.ToString()); } } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs index 5aeb227..1de711b 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs @@ -554,7 +554,7 @@ //闇�浼樺厛浜庡埛鏂版埧闂�,鍚屾浜戠鐨勭綉鍏砳d锛屽鏋滄湰鍦版嫢鏈変簯绔笉瀛樺湪鐨刬d锛屽垯琛ㄧず搴旇琚崲缁戜簡锛岀洿鎺ュ垹闄� HdlGatewayLogic.Current.SynchronizeDbGateway(); //浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 - Common.Room.RefreshAllRoomByLocation(); + HdlRoomLogic.Current.RefreshAllRoomByLocation(); } /// <summary> @@ -646,7 +646,7 @@ /// <param name="noticeDb">鏄惁閫氱煡浜戠</param> public static void ReLoginAgain(string account = "", bool noticeDb = true) { - UserCenterResourse.Option.OldAccountId = string.Empty; + UserCenterResourse.AccountOption.OldAccountId = string.Empty; //鍏抽棴鎵�鏈夋帴鏀� HdlGatewayReceiveLogic.Current.RemoveAllEvent(); //娓呴櫎鍗囩骇鍒楄〃 @@ -655,7 +655,7 @@ HdlThreadLogic.Current.RunThread(async () => { //妫�娴婣PP鏄惁鑳藉閫�鍑� - while (UserCenterResourse.Option.AppCanSignout == false) + while (UserCenterResourse.AccountOption.AppCanSignout == false) { await Task.Delay(500); } @@ -840,13 +840,13 @@ public async static Task<bool> InitUserCenterMenmoryAndThread(bool ShowPrompted = true) { //APP缂撳瓨鍔犺浇寮�濮� - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; //杩樺師杩滅▼杩炴帴鍙橀噺 ZigBee.Device.ZbGateway.AllowRemoteCtrl = true; //鍙湁鍦ㄤ綇瀹匢D涓嶄竴鏍风殑鏃跺�欐墠鍋氳繖涓搷浣� - if (Common.Config.Instance.HomeId != UserCenterResourse.Option.OldHomeStringId - || Common.Config.Instance.Account != UserCenterResourse.Option.OldAccountId) + if (Common.Config.Instance.HomeId != UserCenterResourse.AccountOption.OldHomeStringId + || Common.Config.Instance.Account != UserCenterResourse.AccountOption.OldAccountId) { try { @@ -868,10 +868,13 @@ }); //鍔犺浇璐﹀彿閰嶇疆淇℃伅 - var optionInfo = UserCenterResourse.Option.Load(); - UserCenterResourse.Option = optionInfo; + var optionInfo = UserCenterResourse.AccountOption.Load(); + UserCenterResourse.AccountOption = optionInfo; //鍙樻洿鏍圭敤鎴峰浘鐗囩洰褰曡矾寰� - UserCenterResourse.Option.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory); + UserCenterResourse.AccountOption.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory); + + //鍔犺浇浣忓畢閰嶇疆淇℃伅 + UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load(); //鍒濆鍖栫櫥闄嗚处鍙风殑淇℃伅 var hadNet = await InitUserAccoutInfo(); @@ -898,8 +901,8 @@ //淇濆瓨鐢ㄦ埛鐨勭櫥闄嗕俊鎭埌鏈湴 SaveUserInformationToLocation(); - UserCenterResourse.Option.OldHomeStringId = Common.Config.Instance.HomeId; - UserCenterResourse.Option.OldAccountId = Common.Config.Instance.Account; + UserCenterResourse.AccountOption.OldHomeStringId = Common.Config.Instance.HomeId; + UserCenterResourse.AccountOption.OldAccountId = Common.Config.Instance.Account; //鍚屾鏁版嵁(浜屾璋冪敤娌″叧绯�) int result = -1; @@ -920,7 +923,7 @@ } //鍒濆鍖栨埧闂�(閮洩鍩庨偅杈逛笉鍋氬鐞�,闇�瑕佽繖閲岀壒娈婃墽琛屼竴姝�) - Room.RefreshAllRoomByLocation(); + HdlRoomLogic.Current.RefreshAllRoomByLocation(); //鍒锋柊APP鍓嶄竴娆¢�夋嫨鐨勭綉鍏矷D(鍙互鍙嶅璋冪敤,闇�瑕佸湪缃戝叧鍒濆鍖栧畬浜嗕箣鍚庢墠鑳借皟鐢�) HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId(); @@ -935,7 +938,7 @@ ShowGuideForm(result); } //APP缂撳瓨鍔犺浇瀹屾垚 - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return true; } @@ -954,7 +957,7 @@ UserCenterResourse.UserInfo.InitUserInfoSuccess = false; //鑾峰彇鏈湴璁板綍鐨勭敤鎴蜂俊鎭� UserCenterResourse.UserInfo = GetUserInformationFromLocation(); - UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png"); + UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png"); //鑾峰彇鐧诲綍璐﹀彿鐨勪俊鎭� var pra = new AccountInfoPra(); @@ -1032,7 +1035,7 @@ } UserCenterResourse.UserInfo = userInfo; - UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png"); + UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png"); if (UserCenterResourse.UserInfo.HeadImage != null) { //鍐欏叆澶村儚鍐呭 @@ -1040,10 +1043,10 @@ } UserCenterResourse.UserInfo.HeadImage = null; //鎵嬪娍瀵嗙爜 - UserCenterResourse.Option.GestureAuthentication = UserCenterResourse.UserInfo.GesturePwd == null ? string.Empty : UserCenterResourse.UserInfo.GesturePwd; + UserCenterResourse.AccountOption.GestureAuthentication = UserCenterResourse.UserInfo.GesturePwd == null ? string.Empty : UserCenterResourse.UserInfo.GesturePwd; UserCenterResourse.UserInfo.GesturePwd = null; //瀵嗙爜楠岃瘉 - UserCenterResourse.Option.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd; + UserCenterResourse.AccountOption.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd; UserCenterResourse.UserInfo.StringPwd = null; //鍒濆鍖栫鐞嗗憳鎺у埗涓讳汉鐨勮繛鎺ュ湴鍧�(鍥犱负杩欎釜杩炴帴Token鏄笉浼氭敼鍙樼殑,鎵�浠ュ彧闇�瑕佸垵濮嬪寲涓�娆�) @@ -1234,9 +1237,9 @@ Global.CreateEmptyDirectory(directory); //鐢ㄦ埛鍥剧墖鐩綍璺緞銆愭枃浠跺す銆� - if (UserCenterResourse.Option.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.Option.UserPictruePath)) + if (UserCenterResourse.AccountOption.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.AccountOption.UserPictruePath)) { - System.IO.Directory.CreateDirectory(UserCenterResourse.Option.UserPictruePath); + System.IO.Directory.CreateDirectory(UserCenterResourse.AccountOption.UserPictruePath); } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/DirectoryFileNameResourse.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/DirectoryFileNameResourse.cs index de18032..aef49cd 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/DirectoryFileNameResourse.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/DirectoryFileNameResourse.cs @@ -87,6 +87,10 @@ /// </summary> public const string AccountOptionFile = "d33690329dfdf2e5dcce0280893b95a0db47b5be13b46aa0"; /// <summary> + /// 淇濆瓨浣忓畢閰嶇疆鐨勩�愭枃浠躲�� + /// </summary> + public const string ResidenceOptionFile = "b79583bed6909a52849eaea268449aee15f29d3bdf8b5ca3"; + /// <summary> /// 淇濆瓨浣忓畢椤哄簭鐨勩�愭枃浠躲�� /// </summary> public const string ResidenceSortFile = "b79583bed6909a524e81e2461474f8dcc7a45bf99cecee93"; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/UserCenterResourse.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/UserCenterResourse.cs index 064fea3..5ee5159 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/UserCenterResourse.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Resourse/UserCenterResourse.cs @@ -34,11 +34,19 @@ /// <summary> /// 璐﹀彿鐨勮缃俊鎭� /// </summary> - public static AccountOption Option = new AccountOption(); + public static AccountOptionClass AccountOption = new AccountOptionClass(); + /// <summary> + /// 浣忓畢鐨勮缃俊鎭� + /// </summary> + public static ResidenceOptionClass ResidenceOption = new ResidenceOptionClass(); /// <summary> /// 闅愬尶閰嶇疆 /// </summary> - public static HideOptionInfo HideOption = new HideOptionInfo(); + public static HideOptionInfo HideOption = new HideOptionInfo(); + /// <summary> + /// 娴嬭瘯鑳藉惁骞挎挱寰楀埌缃戝叧,閫氬父鎯呭喌涓嬩负null + /// </summary> + public static Dictionary<string, ZbGateway> DicReceiveGatewayTest = null; /// <summary> /// 鏂囦欢鍔犲瘑绉橀挜 /// </summary> diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs index f7f00c0..1cdb3cf 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs @@ -122,7 +122,7 @@ //鏇存敼缂撳瓨 for (int i = 0; i < this.reportValue.Length; i++) { - deviceAc.listSupportMode[i] = Convert.ToInt32(reportValue[i]); + deviceAc.listSupportMode[i] = Convert.ToInt32(reportValue[i].ToString()); } deviceAc.ReSave(); this.CloseForm(); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs index d992a9e..7b1109c 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs @@ -125,7 +125,7 @@ btnRoom.Y = btnDeviceName.Bottom + Application.GetRealHeight(12); btnRoom.TextSize = 12; btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1; - btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device); frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); rowInfo.btnRoom = btnRoom; //鎽勬皬搴� @@ -340,7 +340,7 @@ { var contr = dicControl[this.actionDeviceKeys]; contr.btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device); - contr.btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device); + contr.btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device); } } this.actionDeviceKeys = null; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs index db7bcd9..5dbc59c 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs @@ -137,7 +137,7 @@ rowBeloneArea.AddBottomLine(); rowBeloneArea.SelectRoomEvent += (roomKeys) => { - Common.Room.CurrentRoom.ChangedRoom(deviceAc, roomKeys); + HdlRoomLogic.Current.ChangedRoom(deviceAc, roomKeys); }; //绌鸿皟妯″紡 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs index df44068..4c2bb2d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs @@ -58,7 +58,7 @@ /// <summary> /// 褰撳墠璁惧绫诲瀷鍒楄〃 /// </summary> - List<DeviceUI> curTypeDeviceList = new List<DeviceUI> { }; + List<CommonDevice> curTypeDeviceList = new List<CommonDevice> { }; /// <summary> /// 褰撳墠璁惧缁戝畾绫诲瀷 /// </summary> @@ -82,7 +82,7 @@ /// <summary> /// 褰撳墠鎸夐敭鐨勬墍鏈夋埧闂磋澶囧垪琛� /// </summary> - List<DeviceUI> currentKeyAllRoomDeviceList = new List<DeviceUI>(); + List<CommonDevice> currentKeyAllRoomDeviceList = new List<CommonDevice>(); /// <summary> /// 涓存椂瀛樺偍鐨勭洰鏍囧垪琛� /// </summary> @@ -221,14 +221,15 @@ #region 鏁版嵁澶勭悊 //鑾峰彇妤煎眰 - dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + dicFloor = HdlRoomLogic.Current.GetFloorSortList(); currentKey.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); if (Common.Config.Instance.Home.FloorDics.Count == 0) { // 鑾峰彇娌℃湁妤煎眰鎴块棿 - foreach (var room in Shared.Common.Room.Lists) + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { if (string.IsNullOrEmpty(room.FloorId)) { @@ -237,9 +238,10 @@ } } else - { - // 鑾峰彇妤煎眰瀵瑰簲瀵规埧闂� - foreach (var room in Shared.Common.Room.Lists) + { + // 鑾峰彇妤煎眰瀵瑰簲瀵规埧闂� + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { if (room.FloorId == currentKey.currentSelectFloorId) { @@ -255,13 +257,13 @@ { foreach (var devA in currentKeyAllRoomDeviceList) { - var id = devA.CommonDevice?.DeviceAddr + devA.CommonDevice?.DeviceEpoint; + var id = devA.DeviceAddr + devA.DeviceEpoint; var dev = currentKey.bindList.Find(obj => (obj != null) && (obj.BindMacAddr + obj.BindEpoint == id)); if (dev != null) { if (!oldTargetList.ContainsKey(id)) { - oldTargetList.Add(id, devA.CommonDevice); + oldTargetList.Add(id, devA); } } } @@ -453,15 +455,16 @@ /// 褰撳墠鎸夐敭鎵�鏈夋樉绀烘埧闂寸殑鎵�鏈夎澶囧鐞� /// </summary> /// <returns></returns> - List<DeviceUI> GetALlDispalyRoomDeviceList() + List<CommonDevice> GetALlDispalyRoomDeviceList() { - currentKeyAllRoomDeviceList.Clear(); + currentKeyAllRoomDeviceList.Clear(); + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); switch (curDeviceBindType) { case "AddSwitch": - foreach (var r in Shared.Common.Room.Lists) + foreach (var r in listAllRoom) { - if (r.DeviceUIList.Count == 0) + if (r.ListDevice.Count == 0) { continue; } @@ -469,11 +472,12 @@ { continue; } - foreach (var device in r.DeviceUIList) + foreach (var deviceKeys in r.ListDevice) { - if (device.CommonDevice != null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 6)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 6)); if (dev != null) { currentKeyAllRoomDeviceList.Add(device); @@ -483,21 +487,22 @@ } break; case "AddDimmer": - foreach (var r in Shared.Common.Room.Lists) + foreach (var r in listAllRoom) { - if (r.DeviceUIList.Count == 0) + if (r.ListDevice.Count == 0) { continue; } if (r.IsLove == true) { continue; - } - foreach (var device in r.DeviceUIList) + } + foreach (var deviceKeys in r.ListDevice) { - if (device.CommonDevice != null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 8)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 8)); if (dev != null) { currentKeyAllRoomDeviceList.Add(device); @@ -507,9 +512,9 @@ } break; case "AddCurtain": - foreach (var r in Shared.Common.Room.Lists) + foreach (var r in listAllRoom) { - if (r.DeviceUIList.Count == 0) + if (r.ListDevice.Count == 0) { continue; } @@ -517,11 +522,12 @@ { continue; } - foreach (var device in r.DeviceUIList) + foreach (var deviceKeys in r.ListDevice) { - if (device.CommonDevice != null) + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 258)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 258)); if (dev != null) { currentKeyAllRoomDeviceList.Add(device); @@ -546,11 +552,12 @@ switch (curDeviceBindType) { case "AddSwitch": - foreach (var device in curRoom.DeviceUIList) - { - if (device.CommonDevice != null) + foreach (var deviceKeys in curRoom.ListDevice) + { + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 6)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 6)); if (dev != null) { curTypeDeviceList.Add(device); @@ -558,12 +565,13 @@ } } break; - case "AddDimmer": - foreach (var device in curRoom.DeviceUIList) - { - if (device.CommonDevice != null) + case "AddDimmer": + foreach (var deviceKeys in curRoom.ListDevice) + { + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 8)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 8)); if (dev != null) { curTypeDeviceList.Add(device); @@ -571,12 +579,13 @@ } } break; - case "AddCurtain": - foreach (var device in curRoom.DeviceUIList) - { - if (device.CommonDevice != null) + case "AddCurtain": + foreach (var deviceKeys in curRoom.ListDevice) + { + var device = LocalDevice.Current.GetDevice(deviceKeys); + if (device != null) { - var dev = device.CommonDevice.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 258)); + var dev = device.InClusterList.Find(obj => (obj != null) && (obj.InCluster == 258)); if (dev != null) { curTypeDeviceList.Add(device); @@ -589,7 +598,7 @@ foreach (var device in curTypeDeviceList) { curIndex++; - if (device.CommonDevice != null && device.CommonDevice.IsOnline == 0) + if (device != null && device.IsOnline == 0) { continue; } @@ -598,7 +607,7 @@ { Height = Application.GetRealHeight(23 + 127), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, - Tag = device.CommonDevice?.DeviceEpointName, + Tag = device.DeviceEpointName, }; midVerticalScrolViewLayout.AddChidren(rowLayout); @@ -609,7 +618,7 @@ Width = Application.GetMinRealAverage(81), Height = Application.GetMinRealAverage(81), UnSelectedImagePath = device.IconPath, - Tag = device.CommonDevice?.DeviceEpointName, + Tag = device.DeviceEpointName, }; rowLayout.AddChidren(devicePic); @@ -619,7 +628,7 @@ X = devicePic.Right + Application.GetRealWidth(20), TextColor = Shared.Common.ZigbeeColor.Current.TextBlack, TextAlignment = TextAlignment.CenterLeft, - Tag = device.CommonDevice?.DeviceEpointName, + Tag = device.DeviceEpointName, TextSize = 15, }; rowLayout.AddChidren(btnBindName); @@ -633,7 +642,7 @@ SelectedImagePath = "DoorLock/SelectedIcon.png", TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, Visible = false, - Tag = device.CommonDevice?.DeviceEpointName, + Tag = device.DeviceEpointName, }; rowLayout.AddChidren(btnChoose); @@ -659,7 +668,7 @@ if (!btnChoose.IsSelected) { - targetList.Remove(device.CommonDevice); + targetList.Remove(device); btnChoose.IsSelected = false; btnChoose.Visible = false; } @@ -671,7 +680,7 @@ } else { - targetList.Add(device.CommonDevice); + targetList.Add(device); btnChoose.IsSelected = true; btnChoose.Visible = true; } @@ -692,17 +701,17 @@ btnBindName.MouseUpEventHandler += hander; btnChoose.MouseUpEventHandler += hander; - if (string.IsNullOrEmpty(device.CommonDevice?.DeviceEpointName)) + if (string.IsNullOrEmpty(device.DeviceEpointName)) { - btnBindName.Text = device.CommonDevice?.DeviceAddr + "_" + device.CommonDevice?.DeviceEpoint; + btnBindName.Text = device.DeviceAddr + "_" + device.DeviceEpoint; } else { - btnBindName.Text = device.CommonDevice?.DeviceEpointName; + btnBindName.Text = device.DeviceEpointName; } foreach (var bindedDev in targetList) { - var id = device.CommonDevice?.DeviceAddr + device.CommonDevice?.DeviceEpoint; + var id = device.DeviceAddr + device.DeviceEpoint; if (id == bindedDev.DeviceAddr + bindedDev.DeviceEpoint) { btnChoose.IsSelected = true; @@ -838,10 +847,11 @@ btnMethodText.IsSelected = true; oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; oldbuttonText.IsBold = true; - } - - //鑾峰彇妤煎眰瀵瑰簲鐨勬埧闂� - foreach (var room in Shared.Common.Room.Lists) + } + + //鑾峰彇妤煎眰瀵瑰簲鐨勬埧闂� + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { if (room.FloorId == currentKey.currentSelectFloorId) { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs index 06e29ea..7098e3d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs @@ -183,14 +183,15 @@ #region 鏁版嵁澶勭悊 //鑾峰彇妤煎眰 - dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + dicFloor = HdlRoomLogic.Current.GetFloorSortList(); currentKey.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); - btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); - + btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); + + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); if (Common.Config.Instance.Home.FloorDics.Count == 0) { // 鑾峰彇娌℃湁妤煎眰鎴块棿 - foreach (var room in Shared.Common.Room.Lists) + foreach (var room in listAllRoom) { if (string.IsNullOrEmpty(room.FloorId)) { @@ -201,7 +202,7 @@ else { // 鑾峰彇妤煎眰瀵瑰簲瀵规埧闂� - foreach (var room in Shared.Common.Room.Lists) + foreach (var room in listAllRoom) { if (room.FloorId == currentKey.currentSelectFloorId) { @@ -235,7 +236,7 @@ int index = 0; RefreshRoomList(curRoom, ref index); - if (curRoom.SceneUIList.Count == 0) + if (curRoom.ListSceneId.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; @@ -479,7 +480,7 @@ } //濡傛灉鎴块棿涓病鏈夊満鏅紝鍒欎笉鏄剧ず - if (room.SceneUIList.Count == 0) + if (room.ListSceneId.Count == 0) { continue; } @@ -549,7 +550,7 @@ } curRoom = room; currentKey.RoomId = room.Id; - if (curRoom.SceneUIList.Count == 0) + if (curRoom.ListSceneId.Count == 0) { btnFinifh.Enable = false; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; @@ -587,7 +588,7 @@ void RefreshSceneList(Shared.Common.Room curRoom) { midVerticalScrolViewLayout.RemoveAll(); - if (curRoom.SceneUIList.Count == 0) + if (curRoom.ListSceneId.Count == 0) { return; } @@ -651,7 +652,7 @@ }; rowLayout.AddChidren(line2); - if (curIndex == curRoom.SceneUIList.Count - 1) + if (curIndex == curRoom.ListSceneId.Count - 1) { line2.Visible = false; } @@ -868,10 +869,11 @@ btnMethodText.IsSelected = true; oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack; oldbuttonText.IsBold = true; - } - - //鑾峰彇妤煎眰瀵瑰簲鐨勬埧闂� - foreach (var room in Shared.Common.Room.Lists) + } + + //鑾峰彇妤煎眰瀵瑰簲鐨勬埧闂� + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { if (room.FloorId == currentKey.currentSelectFloorId) { @@ -916,9 +918,10 @@ /// <returns></returns> List<SceneUI> GetALlDispalyRoomSceneList() { - currentKeyAllRoomSceneList.Clear(); - // 鑾峰彇鎵�鏈夋埧闂� - foreach (var room in Shared.Common.Room.Lists) + currentKeyAllRoomSceneList.Clear(); + // 鑾峰彇鎵�鏈夋埧闂� + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listAllRoom) { //濡傛灉鎴块棿涓哄枩鐖憋紝鍒欎笉鏄剧ず if (room.IsLove == true) @@ -926,13 +929,18 @@ continue; } //濡傛灉鎴块棿涓病鏈夊満鏅紝鍒欎笉鏄剧ず - if (room.SceneUIList.Count == 0) + if (room.ListSceneId.Count == 0) { continue; } - foreach (var scene in room.SceneUIList) - { + foreach (var sceneId in room.ListSceneId) + { + var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); + if (scene == null) + { + continue; + } currentKeyAllRoomSceneList.Add(scene); } } @@ -946,9 +954,14 @@ List<SceneUI> GetMatchSceneUIList(Shared.Common.Room curRoom) { var tempSceneUIList = new List<SceneUI>(); - foreach (var scene in curRoom.SceneUIList) + foreach (var sceneId in curRoom.ListSceneId) { - var gwSc = gwCurScenesList.Find(obj => (obj.ScenesId == scene.Id)); + var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); + if (scene == null) + { + continue; + } + var gwSc = gwCurScenesList.Find(obj => (obj.ScenesId == sceneId)); if (gwSc != null) { tempSceneUIList.Add(scene); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs index 8d2b2fd..b22d780 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs @@ -46,7 +46,7 @@ /// <returns></returns> public static bool CheckCanShowRoom(Common.Room room, string curDeviceBindType = "AddSwitch") { - if (room.DeviceUIList.Count == 0) + if (room.ListDevice.Count == 0) { return false; } @@ -54,10 +54,11 @@ { return false; } - foreach (var deviceUi in room.DeviceUIList) + foreach (var deviceKeys in room.ListDevice) { + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); //妫�娴嬭璁惧鑳藉惁鏄剧ず - if (CheckCanShowDevice(deviceUi.CommonDevice, curDeviceBindType) == false) + if (CheckCanShowDevice(device, curDeviceBindType) == false) { continue; } @@ -127,7 +128,7 @@ /// <returns></returns> public static string GetCurrentKeyAllRoomList() { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); foreach (var floorId in dicFloor.Keys) { //绗竴涓ゼ灞� @@ -143,7 +144,7 @@ /// <returns></returns> public static string GetCurrentSelectFloorId() { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList();// + var dicFloor = HdlRoomLogic.Current.GetFloorSortList();// foreach (var floorId in dicFloor.Keys) { //绗竴涓ゼ灞� @@ -159,7 +160,7 @@ /// <returns></returns> public static string GetCurrentSelectFloorIdName() { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); foreach (var floorId in dicFloor.Keys) { //绗竴涓ゼ灞� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs index 8e3b0f0..b6a7c54 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs @@ -105,7 +105,7 @@ localDeviceList.Add(dev); } //鑾峰彇鏈湴鍦烘櫙鍒楄〃 - scList = Shared.Common.Room.AllRoomSceneUIList; + scList = HdlSceneLogic.Current.GetAllRoomSceneList(); //鑾峰彇缃戝叧鍦烘櫙琛� var gwSceneObj = await currentKey.GetSceneInfoAsync(); if (gwSceneObj != null && gwSceneObj.getSceneInfo != null) @@ -472,7 +472,7 @@ } if (isExistScene) { - curSceneUI = Room.CurrentRoom.GetSceneUIBySceneId(bindDevice.BindScenesId); + curSceneUI = HdlSceneLogic.Current.GetSceneUIBySceneId(bindDevice.BindScenesId); devicePic.UnSelectedImagePath = "Scene/SceneIcon.png"; if (curSceneUI == null) { @@ -488,9 +488,10 @@ else { btnBindNameText = curSceneUI.Name; - if (curSceneUI.GetZone() != null) + string myName = HdlSceneLogic.Current.GetZoneById(curSceneUI.Id); + if (myName != null) { - btnFloorRoomNameText = curSceneUI.GetZone(); + btnFloorRoomNameText = myName; } } } @@ -503,7 +504,7 @@ if (tempDev != null) { //鑾峰彇璁惧鎵�灞炴埧闂� - var tempDevRoom = Common.Room.CurrentRoom.GetRoomByDevice(tempDev); + var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev); if (tempDevRoom != null) { @@ -520,14 +521,12 @@ { btnFloorRoomNameText = tempDevFloorName + "," + tempDevRoomName; } - } - var deviceUi = Common.LocalDevice.Current.GetDeviceUI(tempDev); - if (deviceUi != null) - { - devicePic.UnSelectedImagePath = deviceUi.IconPath; - devicePic.Width = Application.GetRealWidth(110); - devicePic.Text = ""; - } + } + + devicePic.UnSelectedImagePath = tempDev.IconPath; + devicePic.Width = Application.GetRealWidth(110); + devicePic.Text = ""; + if (string.IsNullOrEmpty(tempDev.DeviceEpointName)) { btnBindNameText = tempDev.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs index c691a17..4d7cdf6 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs @@ -137,18 +137,18 @@ { continue; } - var room = Common.Room.CurrentRoom.GetRoomByDevice(device); + var room = HdlRoomLogic.Current.GetRoomByDevice(device); string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); if (room == null) { //杩欓噷鏈夌偣鐗规畩,濡傛灉鍥炶矾娌℃湁璁剧疆鏈夊尯鍩熺殑鏃跺��,鎵嶈缃� listCheck.Add(mainKeys); - Common.Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } else if (listCheck.Contains(mainKeys) == true) { //濡傛灉杩欎釜鍥炶矾涔嬪墠閮借繕娌℃湁鍖哄煙,鍦ㄦ湰鐣岄潰杩樻病鏈夊叧闂箣鍓�,鍙互鏃犳潯浠堕殢渚垮彉鏇� - Common.Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } } //淇濆瓨璁惧鎴块棿绱㈠紩 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs index e714476..46ead4f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs @@ -175,7 +175,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //3璺户鐢靛櫒鎴栬��1璺皟鍏夊櫒绗竷鍥炶矾鐨勯厤缃俊鎭� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs index 4398438..e21099e 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs @@ -204,7 +204,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //娣诲姞鍔熻兘绫诲瀷琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index 7fb6fe1..fe01496 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -417,6 +417,12 @@ var form = new DeviceFunctionSettionForm(); form.AddForm(device, true); } + //鏂伴闈㈡澘 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueNewWind) + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } //鏂规偊闈㈡澘 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFour @@ -433,7 +439,7 @@ else if (device.Type == DeviceType.OnOffOutput) { //鏂规偊闈㈡澘鐨勫姛鑳介厤缃� - var form = new DevicePanel.PanelFangyueButtonSettionForm(); + var form = new DevicePanel.PanelFangyueFunctionSettionForm(); form.AddForm(device); } else diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs index 68516c9..85a3db6 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs @@ -61,7 +61,7 @@ this.deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listNewDevice); //璁剧疆鏍囬淇℃伅 - base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceInfo)); + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceSettion)); //鍒濆鍖栧彸涓婅鑿滃崟 this.InitTopRightMenu(); @@ -141,18 +141,18 @@ //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶� continue; } - var room = Room.CurrentRoom.GetRoomByDevice(device); + var room = HdlRoomLogic.Current.GetRoomByDevice(device); string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); if (room == null) { //杩欓噷鏈夌偣鐗规畩,濡傛灉鍥炶矾娌℃湁璁剧疆鏈夊尯鍩熺殑鏃跺��,鎵嶈缃� listCheck.Add(mainKeys); - Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } else if (listCheck.Contains(mainKeys) == true) { //濡傛灉杩欎釜鍥炶矾涔嬪墠閮借繕娌℃湁鍖哄煙,鍦ㄦ湰鐣岄潰杩樻病鏈夊叧闂箣鍓�,鍙互鏃犳潯浠堕殢渚垮彉鏇� - Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } } //淇濆瓨璁惧鎴块棿绱㈠紩 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs index 64f5ab7..d5851af 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs @@ -174,7 +174,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //娣诲姞缁戝畾鐩爣琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs index e653cca..f381cb9 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs @@ -166,7 +166,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //娣诲姞缁戝畾鐩爣琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs index 134412c..506c793 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueEnvironmentTargetForm.cs @@ -86,7 +86,7 @@ HdlThreadLogic.Current.RunThread(() => { - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(this.nowSelectFloorId, false); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.nowSelectFloorId, false); var listDataRoom = new List<Common.Room>(); for (int i = 0; i < listRoom.Count; i++) { @@ -120,7 +120,7 @@ private void InitTopRightMenuControl() { //鑾峰彇妤煎眰 - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); if (dicFloor.Count == 0) { return; @@ -288,9 +288,9 @@ //鍏堟竻绌� this.dicShowDevice[room.Id] = new List<CommonDevice>(); - foreach (var deviceUi in room.DeviceUIList) + foreach (var deviceKeys in room.ListDevice) { - var device = deviceUi.CommonDevice; + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); if (device != null) { canShow = true; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs index d85a556..6354ba4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs @@ -198,7 +198,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //娣诲姞鍔熻兘绫诲瀷琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs index 535b174..933a9be 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs @@ -198,7 +198,7 @@ rowBeloneArea.SelectRoomEvent += (roomKeys) => { //鍙樻洿鎴块棿 - Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys); + HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys); }; //娣诲姞鍔熻兘绫诲瀷琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs index 53f7d21..a919248 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs @@ -85,9 +85,9 @@ } //杩欎釜鎵嬫満寮勫紕,閭d釜鎵嬫満寮勫紕鐨勬儏鍐典笅, //閲囩敤鍚庡鎿嶄綔 -> 鏂板缓涓�涓复鏃舵埧闂村璞″嚭鏉� - if (Common.Room.CurrentRoom.GetRoomByDevice(device) == null) + if (HdlRoomLogic.Current.GetRoomByDevice(device) == null) { - tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(device)); + tempRoom.ListDevice.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device)); } } @@ -98,7 +98,7 @@ //鍒濆鍖栨埧闂存帶浠� var listRoom = new List<Common.Room>(); listRoom.AddRange(dicRoom[nowSelectFloorId]); - if (tempRoom.DeviceUIList.Count > 0) + if (tempRoom.ListDevice.Count > 0) { //鏄剧ず鏂板缓鐨勪复鏃舵埧闂村璞� listRoom.Add(tempRoom); @@ -142,7 +142,8 @@ private void InitTopRightMenuControl() { //鎴块棿鍒嗙粍 - foreach (var room in Common.Room.Lists) + var listRoom = HdlRoomLogic.Current.GetAllListRooms(); + foreach (var room in listRoom) { //妫�娴嬭鎴块棿鑳藉惁鏄剧ず if (this.CheckCanShowRow(room) == false) @@ -162,7 +163,7 @@ } //鑾峰彇妤煎眰 - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); if (dicFloor.Count == 0) { return; @@ -239,9 +240,9 @@ frameTable.AddChidren(listView); var listDevice = new List<ZigBee.Device.CommonDevice>(); - foreach (var deviceUi in room.DeviceUIList) + foreach (var deviceKeys in room.ListDevice) { - var device = deviceUi.CommonDevice; + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); //妫�娴嬭澶� if (this.CheckCanShowDevice(device) == true) { @@ -314,7 +315,7 @@ /// <returns></returns> private bool CheckCanShowRow(Common.Room room) { - if (room.DeviceUIList.Count == 0) + if (room.ListDevice.Count == 0) { return false; } @@ -322,10 +323,11 @@ { return false; } - foreach (var deviceUi in room.DeviceUIList) + foreach (var deviceKeys in room.ListDevice) { //妫�娴嬭璁惧鑳藉惁鏄剧ず - if (this.CheckCanShowDevice(deviceUi.CommonDevice) == false) + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); + if (this.CheckCanShowDevice(device) == false) { continue; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs index 1a1a47d..1577b96 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonLayout.cs @@ -296,7 +296,7 @@ { btnNext.IsSelected = true; } - if (!UserCenterResourse.Option.DoorUnLockByRemote) + if (!UserCenterResourse.AccountOption.DoorUnLockByRemote) { string msg = Language.StringByID(R.MyInternationalizationString.RemoteUnlockBindSucessTip).Replace("{0}", "\r\n"); var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.GoSetting)); @@ -389,7 +389,7 @@ return; } - if (!UserCenterResourse.Option.DoorUnLockByRemote) + if (!UserCenterResourse.AccountOption.DoorUnLockByRemote) { string msgDoorUnLockByRemote = Language.StringByID(R.MyInternationalizationString.GoPersonalCenter).Replace("{0}", "\r\n"); var alertDoorUnLockByRemote = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msgDoorUnLockByRemote, Language.StringByID(R.MyInternationalizationString.GoSetting)); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs index 5736446..99766b2 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs @@ -174,18 +174,18 @@ { foreach (var device in this.listNewDevice) { - var room = Room.CurrentRoom.GetRoomByDevice(device); + var room = HdlRoomLogic.Current.GetRoomByDevice(device); string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); if (room == null) { //杩欓噷鏈夌偣鐗规畩,濡傛灉鍥炶矾娌℃湁璁剧疆鏈夊尯鍩熺殑鏃跺��,鎵嶈缃� listCheck.Add(mainKeys); - Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } else if (listCheck.Contains(mainKeys) == true) { //濡傛灉杩欎釜鍥炶矾涔嬪墠閮借繕娌℃湁鍖哄煙,鍦ㄦ湰鐣岄潰杩樻病鏈夊叧闂箣鍓�,鍙互鏃犳潯浠堕殢渚垮彉鏇� - Room.CurrentRoom.ChangedRoom(device, roomKeys); + HdlRoomLogic.Current.ChangedRoom(device, roomKeys); } } //淇濆瓨璁惧鎴块棿绱㈠紩 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs index da5c1cc..dd33da8 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs @@ -11,9 +11,9 @@ /// </summary> /// <param name="room"></param> /// <param name="doorLock"></param> - public UserDoorLockPage(Shared.Common.Room room, DeviceUI doorLock) + public UserDoorLockPage(Shared.Common.Room room, CommonDevice doorLock) { - this.doorLock = doorLock.CommonDevice as ZigBee.Device.DoorLock; + this.doorLock = doorLock as ZigBee.Device.DoorLock; currentRoom = room; deviceUI = doorLock; BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; @@ -36,7 +36,7 @@ /// <summary> /// 璁惧UI瀵硅薄 /// </summary> - DeviceUI deviceUI; + CommonDevice deviceUI; /// <summary> /// 璁剧疆浜屾楠岃瘉Action /// </summary> @@ -97,8 +97,8 @@ { btnDoorLockTitle.Text = deviceRename; //鏀规埧闂� - Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); - deviceUI.CommonDevice.ReSave(); + HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); + deviceUI.ReSave(); } }; }; @@ -182,8 +182,7 @@ SelectedImagePath = "Item/CollectionSelected.png" }; btnCollectFrameLayout.AddChidren(btnCollect); - var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == deviceUI.FileName); - if (de == null) + if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false) { btnCollect.IsSelected = false; } @@ -196,11 +195,11 @@ btnCollect.IsSelected = !btnCollect.IsSelected; if (btnCollect.IsSelected) { - Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(deviceUI.FileName);//鏀惰棌 + HdlRoomLogic.Current.AddLoveDevice(deviceUI);//鏀惰棌 } else { - Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); //鍙栨秷鏀惰棌 + HdlRoomLogic.Current.DeleteLoveDevice(deviceUI);//鍙栨秷鏀惰棌 } }; btnCollectFrameLayout.MouseDownEventHandler += handerCollect; @@ -373,8 +372,8 @@ { btnDoorLockTitle.Text = deviceRename; //鏀规埧闂� - Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); - deviceUI.CommonDevice.ReSave(); + HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); + deviceUI.ReSave(); } }; openFrameLayout.Enable = true; @@ -401,10 +400,10 @@ { if (!string.IsNullOrEmpty(deviceRename)) { - btnDoorLockTitle.Text = deviceRename; - //鏀规埧闂� - Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); - deviceUI.CommonDevice.ReSave(); + btnDoorLockTitle.Text = deviceRename; + //鏀规埧闂� + HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); + deviceUI.ReSave(); } }; openFrameLayout.Enable = true; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Guide/GuideForm1.cs b/ZigbeeApp/Shared/Phone/UserCenter/Guide/GuideForm1.cs index 61c6c2b..49bc1b2 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Guide/GuideForm1.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Guide/GuideForm1.cs @@ -25,7 +25,7 @@ var frameleft = new FrameLayout(); frameleft.Width = Application.GetRealWidth(115); - frameleft.BackgroundColor = 0xff747474; + frameleft.BackgroundColor = 0xff252525; frameBack.AddChidren(frameleft); //鍙虫粦杩涘叆鎴块棿鍒楄〃 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionDirectoryListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionDirectoryListForm.cs new file mode 100755 index 0000000..cfdeb44 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionDirectoryListForm.cs @@ -0,0 +1,106 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.HideOption +{ + /// <summary> + /// 鏈湴缂撳瓨鏂囦欢澶瑰垪琛ㄧ殑鐣岄潰 + /// </summary> + public class HideOptionDirectoryListForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText("鏂囦欢澶瑰垪琛�"); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + var listView = new VerticalListControl(23); + listView.BackgroundColor = UserCenterColor.Current.White; + listView.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listView); + + Type type = typeof(DirNameResourse); + + var PropertyList = type.GetFields(); + + var listFile = new List<System.Reflection.FieldInfo>(); + foreach (var item in PropertyList) + { + if (item.Name.EndsWith("Directory") == true) + { + listFile.Add(item); + } + } + for (int i = 0; i < listFile.Count; i++) + { + var item = listFile[i]; + this.AddRowControl(listView, item.Name, item.GetValue(null).ToString(), true); + } + + //鏈湴鏂囦欢 + var row1 = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(row1); + row1.AddLeftCaption("鏍圭洰褰曟枃浠�", 800); + row1.AddRightArrow(); + + row1.ButtonClickEvent += (sender, e) => + { + var form = new HideOptionFileListForm(); + form.AddForm(UserCenterLogic.CombinePath()); + }; + + listView.AdjustRealHeight(Application.GetRealHeight(23)); + } + + private void AddRowControl(VerticalListControl listView, string directory, string directoryValue, bool addLine) + { + string myPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, directoryValue); + if (directoryValue == DirNameResourse.LocalMemoryDirectory) + { + myPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory); + } + if (System.IO.Directory.Exists(myPath) == false) + { + return; + } + var row1 = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(row1); + row1.AddLeftCaption(directory, 800); + row1.AddRightArrow(); + if (addLine == true) + { + row1.AddBottomLine(); + } + + row1.ButtonClickEvent += (sender, e) => + { + var form = new HideOptionFileListForm(); + form.AddForm(myPath); + }; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs new file mode 100755 index 0000000..da5eae5 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs @@ -0,0 +1,76 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.HideOption +{ + /// <summary> + /// 鏂囦欢鍐呭 + /// </summary> + public class HideOptionFileContentForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm(string i_file) + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText("鏂囦欢鍐呭"); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(i_file); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame(string i_file) + { + if (i_file.EndsWith(".png") == true || i_file.EndsWith(".jpg") == true || i_file.EndsWith(".JPG") == true) + { + var btnPic = new ImageView(); + btnPic.Y = Application.GetRealHeight(60); + btnPic.Width = Application.GetMinRealAverage(887); + btnPic.Height = Application.GetMinRealAverage(444); + btnPic.Gravity = Gravity.CenterHorizontal; + btnPic.Radius= (uint)Application.GetRealHeight(17); + btnPic.ImageBytes = Shared.IO.FileUtils.ReadFile(i_file); + bodyFrameLayout.AddChidren(btnPic); + } + else + { + string textValue = System.Text.Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(i_file)).Trim(); + textValue = textValue.Replace(",", "\r\n"); + if (textValue.StartsWith("{") == true) + { + textValue = "{\r\n" + textValue.Substring(1); + } + if (textValue.EndsWith("}") == true) + { + textValue = textValue.Substring(0, textValue.Length - 1) + "\r\n}"; + } + + var btnText = new EditTextView(); + btnText.Width = bodyFrameLayout.Width; + btnText.Height = bodyFrameLayout.Height; + btnText.TextAlignment = TextAlignment.TopLeft; + btnText.TextColor = UserCenterColor.Current.TextColor1; + btnText.Text = textValue; + btnText.Foucs = false; + bodyFrameLayout.AddChidren(btnText); + } + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileListForm.cs new file mode 100755 index 0000000..d712c7c --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileListForm.cs @@ -0,0 +1,153 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.HideOption +{ + /// <summary> + /// 鏈湴缂撳瓨鏂囦欢鍒楄〃鐨勭晫闈� + /// </summary> + public class HideOptionFileListForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 瑙e瘑 + /// </summary> + private bool decryptPassword = false; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm(string directory) + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText("鏂囦欢鍒楄〃"); + + var btnButton = new NormalViewControl(200, 69, true); + btnButton.Gravity = Gravity.CenterVertical; + btnButton.X = bodyFrameLayout.Width - Application.GetRealWidth(200) - ControlCommonResourse.XXLeft; + btnButton.TextColor = UserCenterColor.Current.TopLayoutTitleText; + btnButton.TextAlignment = TextAlignment.BottomRight; + btnButton.TextSize = 17; + btnButton.Text = "瑙e瘑"; + topFrameLayout.AddChidren(btnButton); + btnButton.ButtonClickEvent += (sender, e) => + { + if (this.decryptPassword == false) + { + this.decryptPassword = true; + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(directory); + } + }; + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(directory); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame(string directory) + { + this.ClearBodyFrame(); + + var listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(directory); + listAllFile.Sort(); + + var listView = new VerticalListControl(23); + listView.BackgroundColor = UserCenterColor.Current.White; + listView.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listView); + + for (int i = 0; i < listAllFile.Count; i++) + { + this.AddRowControl(listView, listAllFile[i], directory, i != listAllFile.Count - 1); + } + listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(50)); + + var btnButon = new BottomClickButton(); + btnButon.Text = "鍒犻櫎鏂囦欢澶�"; + bodyFrameLayout.AddChidren(btnButon); + btnButon.ButtonClickEvent += (sender, e) => + { + this.ShowMassage(ShowMsgType.Confirm, "鏄惁娓呴櫎璇ユ枃浠跺す", () => + { + try + { + System.IO.Directory.Delete(directory, true); + this.CloseForm(); + } + catch (Exception ex) + { + this.ShowMassage(ShowMsgType.Error, "娓呴櫎缂撳瓨鏂囦欢澶瑰紓甯�"); + HdlLogLogic.Current.WriteLog(ex, "娓呴櫎缂撳瓨鏂囦欢澶瑰紓甯�"); + } + }); + }; + if (directory == UserCenterLogic.CombinePath()) + { + btnButon.CanClick = false; + } + } + + private void AddRowControl(VerticalListControl listView, string fileName, string directory, bool addLine) + { + string fileNewName = fileName; + if (decryptPassword == true && fileName.StartsWith("Device_") == false) + { + try + { + fileNewName = UserCenterLogic.DecryptPassword(UserCenterResourse.FileEncryptKey, fileName); + } + catch { fileNewName = fileName; } + } + + var row1 = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(row1); + var btnName = row1.frameTable.AddLeftCaption(fileNewName, 800); + btnName.IsMoreLines = true; + if (addLine == true) + { + row1.frameTable.AddBottomLine(); + } + row1.frameTable.AddRightArrow(); + + var btnDelete = row1.AddDeleteControl(); + btnDelete.ButtonClickEvent += (sender, e) => + { + this.ShowMassage(ShowMsgType.Confirm, "鏄惁娓呴櫎璇ョ紦瀛樻枃浠�", () => + { + var myFile = UserCenterLogic.CombinePath(directory, fileName); + try + { + System.IO.File.Delete(myFile); + row1.RemoveFromParent(); + } + catch (Exception ex) + { + this.ShowMassage(ShowMsgType.Error, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); + HdlLogLogic.Current.WriteLog(ex, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); + } + }); + }; + + row1.frameTable.ButtonClickEvent += (sender, e) => + { + var form = new HideOptionFileContentForm(); + form.AddForm(UserCenterLogic.CombinePath(directory, fileName)); + }; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionGatewayListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionGatewayListForm.cs index 5380257..39c627f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionGatewayListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionGatewayListForm.cs @@ -24,13 +24,18 @@ /// <summary> /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) /// </summary> - /// <param name="i_GatewayDiv">缃戝叧鍖哄垎,1:鏈湴缃戝叧 2:骞挎挱鎼滃埌鐨勭綉鍏�</param> + /// <param name="i_GatewayDiv">缃戝叧鍖哄垎,1:鏈湴缃戝叧 2:缂撳瓨涓殑缃戝叧 3:骞挎挱鎼滃埌鐨勭綉鍏�</param> public void ShowForm(int i_GatewayDiv) { if (i_GatewayDiv == 1) { //璁剧疆鏍囬淇℃伅 base.SetTitleText("鏈湴缃戝叧"); + } + else if (i_GatewayDiv == 2) + { + //璁剧疆鏍囬淇℃伅 + base.SetTitleText("缂撳瓨涓殑缃戝叧"); } else { @@ -73,10 +78,18 @@ //鑾峰彇鏈湴鍏ㄩ儴缃戝叧瀵硅薄 listway = HdlGatewayLogic.Current.GetAllLocalGateway(); } - else + else if (i_GatewayDiv == 2) { listway = ZbGateway.GateWayList; } + else + { + listway = new List<ZbGateway>(); + foreach (var way in UserCenterResourse.DicReceiveGatewayTest.Values) + { + listway.Add(way); + } + } for (int i = 0; i < listway.Count; i++) { //娣诲姞琛� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs index 5daaef9..8734356 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs @@ -1,6 +1,7 @@ 锘縰sing System; using System.Collections.Generic; using System.Text; +using ZigBee.Device; namespace Shared.Phone.UserCenter.HideOption { @@ -88,7 +89,7 @@ row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.UseClickStatu = false; - row1.AddLeftCaption("骞挎挱鎼滃埌鐨勭綉鍏�", 400); + row1.AddLeftCaption("缂撳瓨涓殑缃戝叧", 400); if (count > 0) { row1.UseClickStatu = true; @@ -102,6 +103,9 @@ row1.AddMostRightView(count + "涓�", 400); row1.AddBottomLine(); + //妫�娴嬭兘鍚﹀箍鎾緱鍒扮綉鍏� + this.AddCheckReceviceGatewayRow(); + row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.AddLeftCaption("娓呴櫎缂撳瓨鏂囦欢", 500); @@ -109,22 +113,8 @@ row1.AddBottomLine(); row1.ButtonClickEvent += (sender, e) => { - this.ShowMassage(ShowMsgType.Confirm, "鏄惁娓呴櫎缂撳瓨鏂囦欢", () => - { - var myPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory); - try - { - System.IO.Directory.Delete(myPath, true); - System.IO.Directory.CreateDirectory(myPath); - this.ShowMassage(ShowMsgType.Tip, "娓呴櫎缂撳瓨鏂囦欢瀹屾垚,璇烽噸鏂扮櫥闄�"); - UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account); - } - catch (Exception ex) - { - this.ShowMassage(ShowMsgType.Error, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); - HdlLogLogic.Current.WriteLog(ex, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); - } - }); + var form = new HideOptionDirectoryListForm(); + form.AddForm(); }; #if Android @@ -213,6 +203,71 @@ return row1; } + /// <summary> + /// 妫�娴嬭兘鍚﹀箍鎾緱鍒扮綉鍏� + /// </summary> + private void AddCheckReceviceGatewayRow() + { + var row1 = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(row1); + row1.AddLeftCaption("妫�娴嬭兘鍚﹀箍鎾緱鍒扮綉鍏�", 700); + row1.AddRightArrow(); + row1.AddBottomLine(); + var btnCount = row1.AddMostRightView("", 400); + row1.ButtonClickEvent += (sender, e) => + { + int waiteCount = 5; + this.ShowMassage(ShowMsgType.Confirm, "璇ユ搷浣滃皢绛夊緟" + waiteCount + "绉�,鏄惁缁х画锛�", () => + { + Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest = new Dictionary<string, ZbGateway>(); + UserCenterResourse.HideOption.CheckCanReceiveGateway = 1; + HdlThreadLogic.Current.RunThread(() => + { + while (waiteCount > 0) + { + HdlThreadLogic.Current.RunMain(() => + { + btnCount.Text = "璇风瓑寰�" + waiteCount + "绉�"; + }); + System.Threading.Thread.Sleep(1000); + waiteCount--; + } + HdlThreadLogic.Current.RunMain(() => + { + btnCount.Text = string.Empty; + }); + //缁撴潫 + UserCenterResourse.HideOption.CheckCanReceiveGateway = 0; + if (Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest.Count == 0) + { + this.ShowMassage(ShowMsgType.Normal, "鎶辨瓑,娌℃湁骞挎挱鍒颁换浣曠綉鍏�"); + return; + } + HdlThreadLogic.Current.RunMain(() => + { + var form = new HideOptionGatewayListForm(); + form.AddForm(3); + }); + }); + }); + }; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest = null; + UserCenterResourse.HideOption.CheckCanReceiveGateway = 1; + + base.CloseFormBefore(); + } + #endregion } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberInfoForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberInfoForm.cs index 5410e1f..749b70d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberInfoForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberInfoForm.cs @@ -167,7 +167,7 @@ UserCenterResourse.ListMemberInfo.Add(memberInfoRes); UserCenterLogic.SaveLocalMemberListInfo(); - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, memberInfoRes.DistributedMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfoRes.DistributedMark + ".png"); if (memberResult.HeadImage != null) { //鍐欏叆澶村儚鍐呭 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs index 3258951..f6661fe 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs @@ -57,7 +57,7 @@ bodyFrameLayout.AddChidren(frame); //鐢ㄦ埛鍥炬爣 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, i_iconMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, i_iconMark + ".png"); var btnUserIcon = new ImageView(); btnUserIcon.Height = Application.GetMinRealAverage(207); btnUserIcon.Width = Application.GetMinRealAverage(207); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs index 0ef7349..72b2353 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs @@ -281,7 +281,7 @@ listView.AddChidren(rowlayout); //鎴愬憳澶村儚鍥炬爣 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, info.DistributedMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, info.DistributedMark + ".png"); var btnIcon = new ImageView(); btnIcon.X = ControlCommonResourse.XXLeft; btnIcon.Gravity = Gravity.CenterVertical; @@ -375,7 +375,7 @@ if (infoResult.HeadImage != null) { //鍐欏叆澶村儚鍐呭 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, keys + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, keys + ".png"); Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage); HdlThreadLogic.Current.RunMain(() => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs index 382f98c..f5ddef9 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs @@ -114,7 +114,7 @@ bodyFrameLayout.AddChidren(frame); //鐢ㄦ埛鍥炬爣 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, memberInfo.DistributedMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfo.DistributedMark + ".png"); var btnUserIcon = new ImageView(); btnUserIcon.Height = Application.GetMinRealAverage(207); btnUserIcon.Width = Application.GetMinRealAverage(207); @@ -430,7 +430,7 @@ if (infoResult.HeadImage != null) { //鍐欏叆澶村儚鍐呭 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, memberInfo.DistributedMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfo.DistributedMark + ".png"); Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage); HdlThreadLogic.Current.RunMain(() => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/SubAccountLevelUpSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/SubAccountLevelUpSuccessForm.cs index f50cf44..99c148a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Member/SubAccountLevelUpSuccessForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/SubAccountLevelUpSuccessForm.cs @@ -47,7 +47,7 @@ bodyFrameLayout.AddChidren(frame); //鐢ㄦ埛鍥炬爣 - string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, memberInfo.DistributedMark + ".png"); + string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfo.DistributedMark + ".png"); var btnUserIcon = new ImageView(); btnUserIcon.Height = Application.GetMinRealAverage(207); btnUserIcon.Width = Application.GetMinRealAverage(207); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorGesturePasswordForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorGesturePasswordForm.cs index b1138df..051c3dc 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorGesturePasswordForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorGesturePasswordForm.cs @@ -35,7 +35,7 @@ //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uGestureAuthentication)); - if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { formMode = FormMode.A楠岃瘉鍓嶅洖瀵嗙爜; } @@ -151,10 +151,10 @@ } else if (formMode == FormMode.A楠岃瘉鍓嶅洖瀵嗙爜) { - if (UserCenterResourse.Option.GestureAuthentication != i_Psw) + if (UserCenterResourse.AccountOption.GestureAuthentication != i_Psw) { - UserCenterResourse.Option.PasswordGestureInputCount--; - if (UserCenterResourse.Option.PasswordGestureInputCount <= 0) + UserCenterResourse.AccountOption.PasswordGestureInputCount--; + if (UserCenterResourse.AccountOption.PasswordGestureInputCount <= 0) { //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰� string msg2 = Language.StringByID(R.MyInternationalizationString.uCheckAdministratorFailAndReload); @@ -167,14 +167,14 @@ return; } //閲嶇疆鍓╀綑瀵嗙爜娆℃暟 - UserCenterResourse.Option.ResetPasswordCount(); + UserCenterResourse.AccountOption.ResetPasswordCount(); formMode = FormMode.A淇敼瀵嗙爜; this.InitMiddleFrame(); } else if (formMode == FormMode.A淇敼瀵嗙爜) { - if (i_Psw == UserCenterResourse.Option.GestureAuthentication) + if (i_Psw == UserCenterResourse.AccountOption.GestureAuthentication) { //鏂板瘑鐮佸拰鍘熷瘑鐮佷竴鑷达紝璇烽噸鏂拌緭鍏� pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uNewPswAndOldPswIsEqual)); @@ -238,7 +238,7 @@ RequestVersion = Common.CommonPage.RequestVersion, LoginAccessToken = Common.Config.Instance.Token, GesturePwd = psw, - StringPwd = UserCenterResourse.Option.PswAuthentication + StringPwd = UserCenterResourse.AccountOption.PswAuthentication }; var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatEexpandPwd", false, pra); //鍏抽棴杩涘害鏉� @@ -250,8 +250,8 @@ } else { - UserCenterResourse.Option.GestureAuthentication = psw; - UserCenterResourse.Option.Save(); + UserCenterResourse.AccountOption.GestureAuthentication = psw; + UserCenterResourse.AccountOption.Save(); HdlThreadLogic.Current.RunMain(() => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorSecondaryPasswordForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorSecondaryPasswordForm.cs index dad60e6..1a8fa11 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorSecondaryPasswordForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/EditorSecondaryPasswordForm.cs @@ -32,7 +32,7 @@ //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPasswordAuthentication)); - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { formMode = FormMode.A楠岃瘉鍓嶅洖瀵嗙爜; } @@ -142,10 +142,10 @@ } else if (formMode == FormMode.A楠岃瘉鍓嶅洖瀵嗙爜) { - if (UserCenterResourse.Option.PswAuthentication != i_Psw) + if (UserCenterResourse.AccountOption.PswAuthentication != i_Psw) { - UserCenterResourse.Option.PasswordInputCount--; - if (UserCenterResourse.Option.PasswordInputCount <= 0) + UserCenterResourse.AccountOption.PasswordInputCount--; + if (UserCenterResourse.AccountOption.PasswordInputCount <= 0) { //绠$悊鍛樿韩浠介獙璇佸け璐�,璇烽噸鏂扮櫥褰� string msg2 = Language.StringByID(R.MyInternationalizationString.uCheckAdministratorFailAndReload); @@ -158,14 +158,14 @@ return; } //閲嶇疆鍓╀綑瀵嗙爜娆℃暟 - UserCenterResourse.Option.ResetPasswordCount(); + UserCenterResourse.AccountOption.ResetPasswordCount(); formMode = FormMode.A淇敼瀵嗙爜; this.InitMiddleFrame(); } else if (formMode == FormMode.A淇敼瀵嗙爜) { - if (i_Psw == UserCenterResourse.Option.PswAuthentication) + if (i_Psw == UserCenterResourse.AccountOption.PswAuthentication) { //鏂板瘑鐮佸拰鍘熷瘑鐮佷竴鑷达紝璇烽噸鏂拌緭鍏� pswControl.SetErrorMsg(Language.StringByID(R.MyInternationalizationString.uNewPswAndOldPswIsEqual)); @@ -221,7 +221,7 @@ { RequestVersion = Common.CommonPage.RequestVersion, LoginAccessToken = Common.Config.Instance.Token, - GesturePwd = UserCenterResourse.Option.GestureAuthentication, + GesturePwd = UserCenterResourse.AccountOption.GestureAuthentication, StringPwd = psw }; var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdatEexpandPwd", false, pra); @@ -234,8 +234,8 @@ } else { - UserCenterResourse.Option.PswAuthentication = psw; - UserCenterResourse.Option.Save(); + UserCenterResourse.AccountOption.PswAuthentication = psw; + UserCenterResourse.AccountOption.Save(); HdlThreadLogic.Current.RunMain(() => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs index c6e916c..8cb0a34 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/AddNewRoomForm.cs @@ -77,6 +77,8 @@ this.newRoom = new Common.Room(); newRoom.FloorId = this.floorKeys; newRoom.BackgroundImage = btnPic.ImagePath; + newRoom.Humidity = -1000; + newRoom.Temperatrue = -1000; //鍒濆鍖栨甯� var tableContr = new InformationEditorControl(); @@ -178,18 +180,11 @@ } newRoom.FloorId = this.floorKeys; - var result = newRoom.AddRoom(newRoom); - if (result == false) - { - //鎻愮ず鐢ㄦ埛娣诲姞澶辫触 - this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.FAIL)); - } - else - { - this.FinishEditorEvent?.Invoke(); - this.CloseForm(); - } + HdlRoomLogic.Current.AddRoom(newRoom); + this.FinishEditorEvent?.Invoke(); + + this.CloseForm(); }; } @@ -203,7 +198,7 @@ /// <param name="control"></param> private void ShowSelectFloor(FrameCaptionViewControl control) { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); var listKeys = new List<string>(); var listName = new List<string>(); @@ -277,8 +272,16 @@ { return; } - //鑾峰彇涓�... - btnTemper.Text = Language.StringByID(R.MyInternationalizationString.uGetting); + if (newRoom.Temperatrue == -1000) + { + //娌℃湁鑾峰彇寰楀埌杩囨俯搴� + btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting); + } + else + { + btnTemper.Text = this.newRoom.Temperatrue == 0 ? "0.0鈩�" : this.newRoom.Temperatrue.ToString() + "鈩�"; + btnTemper.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting); + } HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, ((report) => @@ -288,8 +291,6 @@ { return; } - //绉婚櫎鎺変簨浠� - HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { @@ -301,6 +302,7 @@ { //0鈩� btnTemper.Text = "0.0鈩�"; + this.newRoom.Temperatrue = 0; } else if (data.AttriButeData > 32767) { @@ -308,14 +310,18 @@ string strValue = (data.AttriButeData - 65536).ToString(); //灏忔暟鐐归渶瑕佷竴浣� strValue = strValue.Substring(0, strValue.Length - 1); - btnTemper.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + //璁板綍娓╁害 + this.newRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnTemper.Text = this.newRoom.Temperatrue.ToString() + "鈩�"; } else { //灏忔暟鐐归渶瑕佷竴浣� string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); - btnTemper.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + //璁板綍娓╁害 + this.newRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnTemper.Text = this.newRoom.Temperatrue.ToString() + "鈩�"; } }); } @@ -373,8 +379,16 @@ { return; } - //鑾峰彇涓�... - btnHumi.Text = Language.StringByID(R.MyInternationalizationString.uGetting); + if (newRoom.Humidity == -1000) + { + //娌℃湁鑾峰彇寰楀埌杩囨箍搴� + btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting); + } + else + { + btnHumi.Text = this.newRoom.Humidity == 0 ? "0.0%" : this.newRoom.Humidity.ToString() + "%"; + btnHumi.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting); + } HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => @@ -384,8 +398,6 @@ { return; } - //绉婚櫎鎺変簨浠� - HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -396,13 +408,16 @@ { //0 btnHumi.Text = "0.0%"; + this.newRoom.Humidity = 0; } else { //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟) string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); - btnHumi.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; + //璁板綍婀垮害 + this.newRoom.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnHumi.Text = this.newRoom.Humidity.ToString() + "%"; } }); } @@ -511,7 +526,8 @@ } if (string.IsNullOrEmpty(this.floorKeys) == true) { - if (Shared.Common.Room.Lists.Find((obj) => obj.Name == this.newRoom.Name && obj.Id != this.newRoom.Id) != null) + var listRoom = HdlRoomLogic.Current.GetAllListRooms(); + if (listRoom.Find((obj) => obj.Name == this.newRoom.Name && obj.Id != this.newRoom.Id) != null) { this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uRoomNameIsExist)); return false; @@ -519,7 +535,7 @@ } else { - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(this.floorKeys); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.floorKeys); if (listRoom.Find((obj) => obj.Name == this.newRoom.Name && obj.Id != this.newRoom.Id) != null) { this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uRoomNameIsExist)); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs index e0b6ace..05ce2f0 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/EditorRoomInforForm.cs @@ -12,7 +12,7 @@ #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> - /// 缁撴潫缂栬緫鍚嶇О鐨勪簨浠� + /// 缁撴潫缂栬緫鐨勪簨浠� /// </summary> public Action<string> FinishEditorEvent = null; /// <summary> @@ -42,8 +42,18 @@ /// <param name="i_editorRoom">缂栬緫鐨勬埧闂村璞�</param> public void ShowForm(Common.Room i_editorRoom = null) { + //寮勪竴鐐瑰垵濮嬪�� this.editorRoom = i_editorRoom; - this.cloneRoom = i_editorRoom.CloneRoomClass(); + this.cloneRoom = HdlRoomLogic.Current.CloneRoomClass(i_editorRoom); + if (i_editorRoom.HumidityDevice == string.Empty) + { + this.cloneRoom.Humidity = -1000; + } + if (i_editorRoom.TemperatrueDevice == string.Empty) + { + this.cloneRoom.Temperatrue = -1000; + } + //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorRoom)); @@ -213,7 +223,9 @@ editorRoom.FloorId = cloneRoom.FloorId; editorRoom.Name = cloneRoom.Name; editorRoom.HumidityDevice = cloneRoom.HumidityDevice; + editorRoom.Humidity = cloneRoom.Humidity; editorRoom.TemperatrueDevice = cloneRoom.TemperatrueDevice; + editorRoom.Temperatrue = cloneRoom.Temperatrue; editorRoom.BackgroundImage = cloneRoom.BackgroundImage; editorRoom.BackgroundImageType = cloneRoom.BackgroundImageType; editorRoom.Save(); @@ -233,7 +245,7 @@ /// <param name="control"></param> private void ShowSelectFloor(FrameCaptionViewControl control) { - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); var listKeys = new List<string>(); var listName = new List<string>(); @@ -307,8 +319,16 @@ { return; } - //鑾峰彇涓�... - btnTemper.Text = Language.StringByID(R.MyInternationalizationString.uGetting); + if (cloneRoom.Temperatrue == -1000) + { + //娌℃湁鑾峰彇寰楀埌杩囨俯搴� + btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting); + } + else + { + btnTemper.Text = this.cloneRoom.Temperatrue == 0 ? "0.0鈩�" : this.cloneRoom.Temperatrue.ToString() + "鈩�"; + btnTemper.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting); + } HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, ((report) => @@ -318,8 +338,6 @@ { return; } - //绉婚櫎鎺変簨浠� - HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { @@ -331,6 +349,7 @@ { //0鈩� btnTemper.Text = "0.0鈩�"; + this.cloneRoom.Temperatrue = 0; } else if (data.AttriButeData > 32767) { @@ -338,14 +357,18 @@ string strValue = (data.AttriButeData - 65536).ToString(); //灏忔暟鐐归渶瑕佷竴浣� strValue = strValue.Substring(0, strValue.Length - 1); - btnTemper.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + //璁板綍娓╁害 + this.cloneRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnTemper.Text = this.cloneRoom.Temperatrue.ToString() + "鈩�"; } else { //灏忔暟鐐归渶瑕佷竴浣� string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); - btnTemper.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + //璁板綍娓╁害 + this.cloneRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnTemper.Text = this.cloneRoom.Temperatrue.ToString() + "鈩�"; } }); } @@ -403,8 +426,16 @@ { return; } - //鑾峰彇涓�... - btnHumi.Text = Language.StringByID(R.MyInternationalizationString.uGetting); + if (cloneRoom.Humidity == -1000) + { + //娌℃湁鑾峰彇寰楀埌杩囨箍搴� + btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting); + } + else + { + btnHumi.Text = this.cloneRoom.Humidity == 0 ? "0.0%" : this.cloneRoom.Humidity.ToString() + "%"; + btnHumi.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting); + } HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => @@ -414,8 +445,6 @@ { return; } - //绉婚櫎鎺変簨浠� - HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -426,13 +455,16 @@ { //0 btnHumi.Text = "0.0%"; + this.cloneRoom.Humidity = 0; } else { //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟) string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); - btnHumi.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; + //璁板綍婀垮害 + this.cloneRoom.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + btnHumi.Text = this.cloneRoom.Humidity.ToString() + "%"; } }); } @@ -544,7 +576,7 @@ } if (string.IsNullOrEmpty(this.cloneRoom.FloorId) == true) { - if (Shared.Common.Room.Lists.Find((obj) => obj.Name == this.cloneRoom.Name && obj.Id != this.cloneRoom.Id) != null) + if (HdlRoomLogic.Current.GetAllListRooms().Find((obj) => obj.Name == this.cloneRoom.Name && obj.Id != this.cloneRoom.Id) != null) { this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.HadSameRoom)); return false; @@ -552,7 +584,7 @@ } else { - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(this.cloneRoom.FloorId); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.cloneRoom.FloorId); if (listRoom.Find((obj) => obj.Name == this.cloneRoom.Name && obj.Id != this.cloneRoom.Id) != null) { this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.HadSameRoom)); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/FloorListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/FloorListRoomForm.cs index 9cb5ad7..69419c8 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/FloorListRoomForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/FloorListRoomForm.cs @@ -80,7 +80,7 @@ private void InitRoomListRow() { //鑾峰彇妤煎眰鐨勬埧闂� - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(this.floorKeys); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.floorKeys); this.listRoomSort.Clear(); for (int i = 0; i < listRoom.Count; i++) { @@ -152,18 +152,18 @@ //纭鍒犻櫎鎴块棿? this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () => { - if (Common.Room.CurrentRoom.Id == room.Id) + if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id) { //濡傛灉鍒犻櫎鐨勬槸褰撳墠鎴块棿鐨勮瘽 - Common.Room.CurrentRoom = Common.Room.Lists[0]; + HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom(); } - Common.Room.CurrentRoom.Remove(room.FileName); + HdlRoomLogic.Current.RemoveRoom(room.Id); //璋冩暣楂樺害 frameRow.RemoveFromParent(); listView.AdjustRealHeight(Application.GetRealHeight(23)); //淇濆瓨椤哄簭 this.listRoomSort.Remove(room.Id); - Common.Room.CurrentRoom.SaveRoomSort(floorKeys, this.listRoomSort); + HdlRoomLogic.Current.SaveRoomSort(floorKeys, this.listRoomSort); }); }; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs index 2f0cac5..f93e217 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs @@ -95,7 +95,7 @@ this.frameTable.RemoveAll(); HdlThreadLogic.Current.RunMainInThread(() => { - if (lookRoom.SceneUIList.Count == 0) + if (lookRoom.ListSceneId.Count == 0) { //杩樻病鏈夋坊鍔犲満鏅摝 this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddScenceMsg)); @@ -105,8 +105,13 @@ listView.Height = frameTable.Height; frameTable.AddChidren(listView); - foreach (var data in lookRoom.SceneUIList) + foreach (var dataId in lookRoom.ListSceneId) { + var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId); + if (data == null) + { + continue; + } //鍦烘櫙鎺т欢 var frameContr = new ScenePictrueControl(); listView.AddChidrenFrame(frameContr); @@ -223,7 +228,7 @@ private Dictionary<int, DeviceRowInfo> GetAllGroupDevice() { //鍏ㄩ儴鐨勮澶� - var listDevice = lookRoom.GetRoomListDevice(); + var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom); var dic = new Dictionary<int, DeviceRowInfo>(); foreach (var device in listDevice) { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs index 48bf303..a20b2b5 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs @@ -229,7 +229,7 @@ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ await UserCenterLogic.InitUserCenterMenmoryAndThread(false); - Room.InitAllRoom(); + HdlRoomLogic.Current.InitAllRoom(); HdlThreadLogic.Current.RunMain(() => { @@ -480,7 +480,7 @@ { //淇濆瓨椤哄簭 listResidenceSort.Remove(keys); - Room.CurrentRoom.SaveFloorSort(listResidenceSort); + HdlRoomLogic.Current.SaveFloorSort(listResidenceSort); this.listView.RemoveAll(); //鏁版嵁宸茬粡鍙樻洿 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs index f0cae0b..93cc3e8 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs @@ -266,7 +266,7 @@ private void InitFloorRow() { //鑾峰彇妤煎眰 - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); this.listFloorSort.Clear(); foreach (string keys in dicFloor.Keys) { @@ -364,33 +364,29 @@ break; } } - - if (Common.Room.CurrentRoom == null) + var listDeleteId = new List<string>(); + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + for (int i = 0; i < listAllRoom.Count; i++) { - Common.Room.CurrentRoom = Common.Room.Lists[0]; - } - var listDeleteFile = new List<string>(); - for (int i = 0; i < Common.Room.Lists.Count; i++) - { - if (Common.Room.Lists[i].FloorId == keys) + if (listAllRoom[i].FloorId == keys) { - listDeleteFile.Add(Common.Room.Lists[i].FileName); + listDeleteId.Add(listAllRoom[i].Id); } } //濡傛灉褰撳墠閫夋嫨鐨勬埧闂存槸鍒犻櫎瀵硅薄鐨勮瘽 - if (Common.Room.CurrentRoom.FloorId == keys) + if (HdlRoomLogic.Current.CurrentRoom.FloorId == keys) { - Common.Room.CurrentRoom = Common.Room.Lists[0]; + HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom(); } //鍒犻櫎鎴块棿 - foreach (string fileName in listDeleteFile) + foreach (string roomId in listDeleteId) { - Common.Room.CurrentRoom.Remove(fileName); + HdlRoomLogic.Current.RemoveRoom(roomId); } Common.Config.Instance.Home.Save(); //淇濆瓨椤哄簭 listFloorSort.Remove(keys); - Common.Room.CurrentRoom.SaveFloorSort(listFloorSort); + HdlRoomLogic.Current.SaveFloorSort(listFloorSort); if (Common.Config.Instance.Home.FloorDics.Count == 0) { @@ -506,7 +502,7 @@ private void InitRoomListRow() { //鑾峰彇妤煎眰鐨勬埧闂� - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(string.Empty); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty); this.listRoomSort.Clear(); for (int i = 0; i < listRoom.Count; i++) { @@ -579,17 +575,18 @@ //纭鍒犻櫎鎴块棿? this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () => { - if (Common.Room.CurrentRoom.Id == room.Id) + if (HdlRoomLogic.Current.CurrentRoom.Id == room.Id) { //濡傛灉鍒犻櫎鐨勬槸褰撳墠鎴块棿鐨勮瘽 - Common.Room.CurrentRoom = Common.Room.Lists[0]; + HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom(); } - Common.Room.CurrentRoom.Remove(room.FileName); + HdlRoomLogic.Current.RemoveRoom(room.Id); //淇濆瓨椤哄簭 this.listRoomSort.Remove(room.Id); - Common.Room.CurrentRoom.SaveRoomSort(string.Empty, this.listRoomSort); + HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort); - if (Common.Room.Lists.Count <= 1) + var listAllRoom = HdlRoomLogic.Current.GetAllListRooms(); + if (listAllRoom.Count <= 1) { //鏍规嵁鎸囧畾妯″紡,鍒濆鍖栨甯冩帶浠� this.InitFrameTableByMode(); @@ -658,7 +655,7 @@ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ await UserCenterLogic.InitUserCenterMenmoryAndThread(false); - Common.Room.InitAllRoom(); + HdlRoomLogic.Current.InitAllRoom(); //鍒犻櫎浣忓畢 Common.House.DeleteHouseByHouseId(deleteId); @@ -746,7 +743,7 @@ //鎷ユ湁妤煎眰 return 1; } - if (Common.Room.Lists.Count > 1) + if (HdlRoomLogic.Current.GetAllListRooms().Count > 1) { //鏃犳ゼ灞傛ā寮� return 2; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddMenuForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddMenuForm.cs index 626e387..f600532 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddMenuForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AlarmTargetAddMenuForm.cs @@ -93,7 +93,7 @@ var listRoom = new List<Common.Room>(); foreach (string roomId in this.dicAllData.Keys) { - listRoom.Add(Common.Room.CurrentRoom.GetRoomById(roomId)); + listRoom.Add(HdlRoomLogic.Current.GetRoomById(roomId)); } //鍒濆鍖栨埧闂磋彍鍗曟帶浠� @@ -129,7 +129,7 @@ private void InitTopRightMenuControl() { //鑾峰彇妤煎眰 - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); if (dicFloor.Count == 0) { return; @@ -242,7 +242,7 @@ var dicData = new Dictionary<string, Dictionary<int, uRowInformation>>(); //鑾峰彇鏈湴瀹夐槻鐨勫満鏅� Dictionary<int, string> dicScene = HdlSafeguardLogic.Current.GetLocalSceneByZoneID(this.zoonID); - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(this.nowSelectFloorId); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.nowSelectFloorId); for (int i = 0; i < listRoom.Count; i++) { @@ -271,9 +271,9 @@ } var dicRoomData = new Dictionary<int, uRowInformation>(); - for (int j = 0; j < i_room.DeviceUIList.Count; j++) + for (int j = 0; j < i_room.ListDevice.Count; j++) { - var device = i_room.DeviceUIList[j].CommonDevice; + var device = Common.LocalDevice.Current.GetDevice(i_room.ListDevice[j]); //濡傛灉閭d釜璁惧宸茬粡娣诲姞浜嗭紝鍒欎笉鍐嶆樉绀� if (device == null || HdlSafeguardLogic.Current.IsAlarmDeviceExist(this.zoonID, device) == true) { @@ -299,10 +299,15 @@ dicRoomData[typeInfo.BeloneTextId].listDevice.Add(device); } } - for (int j = 0; j < i_room.SceneUIList.Count; j++) + for (int j = 0; j < i_room.ListSceneId.Count; j++) { //濡傛灉閭d釜鍦烘櫙宸茬粡娣诲姞浜嗭紝鍒欎笉鍐嶆樉绀� - if (dicScene.ContainsKey(i_room.SceneUIList[j].Id) == true) + if (dicScene.ContainsKey(i_room.ListSceneId[j]) == true) + { + continue; + } + var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(i_room.ListSceneId[j]); + if (sceneUi == null) { continue; } @@ -312,7 +317,7 @@ dicRoomData[R.MyInternationalizationString.uScence].IconPath = "Scene/SceneIcon.png"; dicRoomData[R.MyInternationalizationString.uScence].listScene = new List<Common.SceneUI>(); } - dicRoomData[R.MyInternationalizationString.uScence].listScene.Add(i_room.SceneUIList[j]); + dicRoomData[R.MyInternationalizationString.uScence].listScene.Add(sceneUi); } return dicRoomData; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs index 015a7d6..76d6357 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs @@ -238,7 +238,7 @@ topFrameLayout.AddChidren(btnShortCut); btnShortCut.InitControl(); - if (UserCenterResourse.Option.SafetyShortcut == true) + if (UserCenterResourse.ResidenceOption.SafetyShortcut == true) { //浣跨敤蹇嵎鏂瑰紡 btnShortCut.IsSelected = true; @@ -250,8 +250,8 @@ //纭畾鍙栨秷涓婚〉鐨勩�屽畨闃层�嶆嵎寰勶紵 this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCancelSafetyShortcutMsg), () => { - UserCenterResourse.Option.SafetyShortcut = false; - UserCenterResourse.Option.Save(); + UserCenterResourse.ResidenceOption.SafetyShortcut = false; + UserCenterResourse.ResidenceOption.Save(); btnShortCut.IsSelected = false; }); } @@ -260,8 +260,8 @@ //纭畾鍒涘缓銆屽畨闃层�嶆嵎寰勫埌涓婚〉锛� this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () => { - UserCenterResourse.Option.SafetyShortcut = true; - UserCenterResourse.Option.Save(); + UserCenterResourse.ResidenceOption.SafetyShortcut = true; + UserCenterResourse.ResidenceOption.Save(); btnShortCut.IsSelected = true; }); } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs index c11b162..042db84 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs @@ -163,19 +163,19 @@ //鍦烘櫙鏈夌偣鐗规畩,濡傛灉鍚屼竴涓埧闂村唴,宸茬粡鍒嗕韩浜�,鍒欎笉鍐嶆樉绀� //濡傛灉杩欎釜鍦烘櫙鏄敱宓屽鑰屽垎浜殑,杩欎釜鏃跺��,瀹冨彲浠ユ樉绀哄嚭鏉� - var listScene = new List<Common.SceneUI>(); + var listScene = new List<int>(); if (memberShardInfo.dicShardRoom.ContainsKey(lookRoom.FileName) == false) { - listScene.AddRange(lookRoom.SceneUIList); + listScene.AddRange(lookRoom.ListSceneId); } else { var tempRoom = memberShardInfo.dicShardRoom[lookRoom.FileName]; - foreach (var data in lookRoom.SceneUIList) + foreach (var dataId in lookRoom.ListSceneId) { - if (tempRoom.SceneUIFilePathList.Contains(data.FileName) == false) + if (tempRoom.ListSceneId.Contains(dataId) == false) { - listScene.Add(data); + listScene.Add(dataId); } } } @@ -193,8 +193,13 @@ listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187); frameSceneTable.AddChidren(listView); - foreach (var data in listScene) + foreach (var dataId in listScene) { + var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId); + if (data == null) + { + continue; + } //鍦烘櫙鍥剧墖 var frameContr = new ScenePictrueControl(); listView.AddChidrenFrame(frameContr); @@ -379,7 +384,7 @@ private Dictionary<int, List<CommonDevice>> GetAllGroupDevice() { //鍏ㄩ儴鐨勮澶� - var listDevice = lookRoom.GetRoomListDevice(); + var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom); var dic = new Dictionary<int, List<CommonDevice>>(); foreach (var device in listDevice) { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs index 7cf0cff..9ce5881 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs @@ -117,7 +117,7 @@ private void InitTopRightMenuControl() { //鑾峰彇妤煎眰 - var dicFloor = Common.Room.CurrentRoom.GetFloorSortList(); + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); if (dicFloor.Count == 0) { return; @@ -170,7 +170,7 @@ private void InitAreaListRow(string floorId) { dicSelectRoom.Clear(); - var listRoom = Common.Room.CurrentRoom.GetFloorSortRoom(floorId, false); + var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(floorId, false); HdlThreadLogic.Current.RunMain(() => { var listDataRoom = new List<Common.Room>(); @@ -331,9 +331,9 @@ dicScene[i] = listScene; //鑾峰彇鎴块棿鍏ㄩ儴璁惧 - foreach (var deviceUi in listRoom[i].DeviceUIList) + foreach (var deviceKeys in listRoom[i].ListDevice) { - var device = deviceUi.CommonDevice; + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); if (device == null || memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == true) { //寮傚父 @@ -356,8 +356,9 @@ var listChirdDevice = new List<CommonDevice>(); var listChirdScene = new List<Common.SceneUI>(); //鑾峰彇鎴块棿鍏ㄩ儴鍦烘櫙 - foreach (var sceneUi in listRoom[i].SceneUIList) + foreach (var sceneId in listRoom[i].ListSceneId) { + var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); if (sceneUi == null || memberShardInfo.dicAllShardKeys.ContainsKey(sceneUi.FileName) == true) { //寮傚父锛屾垨鑰呭凡缁忓垎浜簡鐨勶紝涓嶅啀鏄剧ず @@ -424,7 +425,7 @@ /// <returns></returns> private bool CheckCanShowRow(Common.Room room) { - if (room.DeviceUIList.Count == 0 && room.SceneUIList.Count == 0) + if (room.ListDevice.Count == 0 && room.ListSceneId.Count == 0) { return false; } @@ -437,20 +438,22 @@ //娌℃湁杩欎釜鎴块棿 return true; } - foreach (var deviceUi in room.DeviceUIList) + foreach (var deviceKeys in room.ListDevice) { - if (deviceUi.CommonDevice == null) + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { continue; } - if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceUi.CommonDevice.FilePath) == false) + if (memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == false) { //瀛樺湪鏈垎浜殑璁惧鐨勮瘽锛屾鎴块棿鍙互鏄剧ず return true; } } - foreach (var sceneUi in room.SceneUIList) + foreach (var sceneId in room.ListSceneId) { + var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); if (sceneUi == null) { continue; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs index 7735487..9b6e56b 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs @@ -155,12 +155,15 @@ this.frameSceneTable.RemoveAll(); var listScene = new List<Common.SceneUI>(); - for (int i = 0; i < lookRoom.SceneUIList.Count; i++) + for (int i = 0; i < lookRoom.ListSceneId.Count; i++) { - if (HdlShardLogic.Current.IsFileExists(lookRoom.SceneUIList[i].FileName) == true) + var byteData = HdlShardLogic.Current.GetShardFileContent($"Scene_{lookRoom.ListSceneId[i]}.json"); + if (byteData == null) { - listScene.Add(lookRoom.SceneUIList[i]); + continue; } + var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData)); + listScene.Add(sceneUi); } if (listScene.Count == 0) { @@ -430,8 +433,9 @@ { //鑾峰彇杩欎釜鎴块棿閲岄潰鐨勫垎浜澶� var listDevice = new List<CommonDevice>(); - foreach (var deviceFile in this.lookRoom.DeviceUIFilePathList) + foreach (var deviceKeys in this.lookRoom.ListDevice) { + string deviceFile = HdlShardLogic.Current.GetShardDeviceFileName(deviceKeys); if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFile) == true) { var strArry = deviceFile.Split('_'); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs index c4a6ace..6e954e4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs @@ -79,7 +79,6 @@ } //鍒濆鍖栧尯鍩熷垪琛� this.InitAreaListRow(); - }); } @@ -125,7 +124,7 @@ bodyFrameLayout.AddChidren(listView); //鎺掑簭妤煎眰 - var dicSort = Common.Room.CurrentRoom.GetFloorSortList(); + var dicSort = HdlRoomLogic.Current.GetFloorSortList(); foreach (var floorId in dicSort.Keys) { if (dicGroup.ContainsKey(floorId) == true) @@ -181,7 +180,7 @@ } } //鎴块棿鎺掑簭 - var listSortRoom = Common.Room.CurrentRoom.GetFloorSortRoom(floorId, false); + var listSortRoom = HdlRoomLogic.Current.GetFloorSortRoom(floorId, false); var listSort = new HashSet<string>(); foreach (var room in listSortRoom) { @@ -264,8 +263,13 @@ { //鑾峰彇鍏ㄩ儴璁惧 var listDevice = new List<CommonDevice>(); - foreach (var deviceFile in room.DeviceUIFilePathList) + foreach (var deviceKeys in room.ListDevice) { + string deviceFile = HdlShardLogic.Current.GetShardDeviceFileName(deviceKeys); + if (deviceFile == string.Empty) + { + continue; + } var byteData = HdlShardLogic.Current.GetShardFileContent(deviceFile); if (byteData == null) { @@ -276,8 +280,14 @@ } //鑾峰彇鍏ㄩ儴鍦烘櫙 var listScene = new List<Common.SceneUI>(); - foreach (var sceneUi in room.SceneUIList) + foreach (var sceneId in room.ListSceneId) { + var byteData = HdlShardLogic.Current.GetShardFileContent($"Scene_{sceneId}.json"); + if (byteData == null) + { + continue; + } + var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData)); listScene.Add(sceneUi); } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs index 9dfbc4a..7a129f1 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs @@ -19,7 +19,7 @@ /// </summary> private VerticalFrameRefreshControl listView = null; /// <summary> - /// 鍏ㄩ儴鐨勮 + /// 鍏ㄩ儴鐨勮,涓婚敭鏄嚜鍔ㄩ�掑鐨勪笢瑗� /// </summary> private Dictionary<string, RowLayoutControl> dicAllRow = null; @@ -175,8 +175,15 @@ for (int i = 0; i < listData.Count; i++) { - //娣诲姞淇℃伅琛� - this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1); + //涓�鏉′俊鎭噷闈紝瀹冨彲鑳藉寘鍚涓姤璀� + for (int j = 0; j < listData[i].listMsg.Count; j++) + { + //璁剧疆宸茶鐨勫垵濮嬪�� + listData[i].ListReading.Add(listData[i].IsReading); + //娣诲姞淇℃伅琛� + bool addLine = i != listData.Count - 1 || j != listData[i].listMsg.Count - 1; + this.AddMsgRowControl(framBack, listData[i], j, addLine); + } } //璋冩暣楂樺害 listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23)); @@ -252,8 +259,9 @@ /// </summary> /// <param name="frameList"></param> /// <param name="recordInfo"></param> + /// <param name="msgIndex">鎶ヨ娑堟伅鐨勪笅鏍�</param> /// <param name="addLine"></param> - private void AddMsgRowControl(FrameListControl frameList, MessageRecordInfo recordInfo, bool addLine) + private void AddMsgRowControl(FrameListControl frameList, MessageRecordInfo recordInfo, int msgIndex, bool addLine) { var rowControl = new RowLayoutControl(frameList.rowSpace / 2); frameList.AddChidren(rowControl); @@ -268,7 +276,7 @@ var btnMsgObject = rowControl.frameTable.AddLeftCaption(recordInfo.MsgObjectText, 600); //娑堟伅 - var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.MsgText, 600, 60); + var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.listMsg[msgIndex], 600, 60); btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; btnMsg.Y = Application.GetRealHeight(5) + rowControl.frameTable.chidrenYaxis; rowControl.frameTable.AddChidren(btnMsg, ChidrenBindMode.BindEventOnly); @@ -282,10 +290,10 @@ //搴曠嚎 if (addLine == true) { - rowControl.frameTable.AddBottomLine(); + rowControl.frameTable.AddBottomLine(); } //宸茶 - if (recordInfo.IsReading == true) + if (recordInfo.ListReading[msgIndex] == true) { rowControl.frameTable.UseClickStatu = false; //娑堟伅绫诲瀷 @@ -298,7 +306,7 @@ //鏂版秷鎭� PicViewControl btnNewTip = null; - if (recordInfo.IsReading == false) + if (recordInfo.ListReading[msgIndex] == false) { btnNewTip = new PicViewControl(78, 55); btnNewTip.UnSelectedImagePath = "Item/NewVersion.png"; @@ -326,11 +334,11 @@ //鐐瑰嚮 rowControl.frameTable.ButtonClickEvent += async (sender, e) => { - if (recordInfo.IsReading == true) + if (recordInfo.ListReading[msgIndex] == true) { return; } - recordInfo.IsReading = true; + recordInfo.ListReading[msgIndex] = true; rowControl.frameTable.UseClickStatu = false; //娑堟伅绫诲瀷 btnMsgObject.TextColor = UserCenterColor.Current.TextGrayColor1; @@ -777,19 +785,27 @@ if (info == null) { //闈炲湪鍐岀殑娑堟伅璁板綍 - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered)); + return true; } - else if (info.BatteryMsg != null) + + if (string.IsNullOrEmpty(info.AlarmMsg) == false) { - recordInfo.MsgText = info.BatteryMsg; + recordInfo.listMsg.Add(info.AlarmMsg); } - else if (info.DemolishmenMsg != null) + if (info.BatteryMsg != null) { - recordInfo.MsgText = info.DemolishmenMsg; + recordInfo.listMsg.Add(info.BatteryMsg); } - else + if (info.DemolishmenMsg != null) { - recordInfo.MsgText = string.IsNullOrEmpty(info.AlarmMsg) == false ? info.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered); + recordInfo.listMsg.Add(info.DemolishmenMsg); + } + + //瑙﹀彂浼犳劅鍣ㄦ姤璀� + if (recordInfo.listMsg.Count == 0) + { + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered)); } return true; } @@ -823,7 +839,8 @@ } //娑堟伅 var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(receiveData); - recordInfo.MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered); + string MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered); + recordInfo.listMsg.Add(MsgText); } #endregion @@ -848,12 +865,12 @@ //绂诲甯冮槻 recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uRemoveHomeGarrison); //宸叉墽琛� - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); } else { //宸叉墽琛� - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); //娌℃湁鍐呴儴闃插尯 if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == false) { @@ -891,7 +908,7 @@ if (data.Result == 0) { //宸叉墽琛� - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); //鎾ら槻 recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uWithdrawGarrison); } @@ -917,7 +934,7 @@ //绫诲瀷:閫昏緫鍚嶅瓧 recordInfo.MsgObjectText = receiveData["Data"]["LogicName"].ToString(); //宸叉墽琛� - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); } #endregion @@ -935,7 +952,7 @@ //绫诲瀷:鍦烘櫙鍚嶅瓧 recordInfo.MsgObjectText = receiveData["Data"]["ScenesName"].ToString(); //宸叉墽琛� - recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted); + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); } #endregion diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs index b438cb5..06ff44c 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs @@ -23,6 +23,13 @@ //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSecondAuthentication)); + var btntitle = (Button)topFrameLayout.GetTagByKey("txtTitle"); + btntitle.MouseLongEventHandler += (sender, e) => + { + //鏄剧ず鏁板瓧鍛戒护绐楀彛 + this.ShowKeyNumberComandDialog(); + }; + //鍒濆鍖栦腑閮ㄤ俊鎭� this.InitMiddleFrame(); } @@ -55,7 +62,7 @@ rowFinger.AddChidren(btnEffect, ChidrenBindMode.NotBind); //寮�鍏虫寜閽� var btnFingerSwicth = rowFinger.AddMostRightSwitchIcon(); - btnFingerSwicth.IsSelected = UserCenterResourse.Option.FingerprintAuthentication; + btnFingerSwicth.IsSelected = UserCenterResourse.AccountOption.FingerprintAuthentication; //搴曠嚎 rowFinger.AddBottomLine(); @@ -67,7 +74,7 @@ rowPsw.AddRightArrow(); //鍘昏缃� var btnSettion1 = rowPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400); - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) { //鍘讳慨鏀� btnSettion1.TextID = R.MyInternationalizationString.uGotoEditor; @@ -83,7 +90,7 @@ rowGesture.AddRightArrow(); //鍘昏缃� var btnSettion2 = rowGesture.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400); - if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) { //鍘讳慨鏀� btnSettion2.TextID = R.MyInternationalizationString.uGotoEditor; @@ -138,7 +145,7 @@ var btnLockSwicth = rowLock.AddMostRightSwitchIcon(); //搴曠嚎 rowLock.AddBottomLine(); - btnLockSwicth.IsSelected = UserCenterResourse.Option.DoorUnLockByRemote; + btnLockSwicth.IsSelected = UserCenterResourse.AccountOption.DoorUnLockByRemote; var rowSafety = new FrameRowControl(frameButtom.rowSpace / 2); rowSafety.UseClickStatu = false; @@ -189,7 +196,7 @@ rowPsw.ButtonClickEvent += (sender, e) => { //濡傛灉娌℃湁瀵嗙爜楠岃瘉 - if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true) { //濡傛灉璁剧疆鏈夊叾浠栭獙璇佹柟寮�,鍒欓渶瑕侀獙璇�,鍚﹀垯鐩存帴璺宠繃楠岃瘉 HdlCheckLogic.Current.CheckSecondarySecurity( @@ -206,7 +213,7 @@ rowGesture.ButtonClickEvent += (sender, e) => { //濡傛灉娌℃湁鎵嬪娍楠岃瘉 - if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true) + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true) { //濡傛灉璁剧疆鏈夊叾浠栭獙璇佹柟寮�,鍒欓渶瑕侀獙璇�,鍚﹀垯鐩存帴璺宠繃楠岃瘉 HdlCheckLogic.Current.CheckSecondarySecurity( @@ -256,22 +263,22 @@ return; } - UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected; - UserCenterResourse.Option.Save(); + UserCenterResourse.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected; + UserCenterResourse.AccountOption.Save(); //閲嶆柊鍒锋柊鐣岄潰 this.InitMiddleFrame(); } else { - if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true - && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true + if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true + && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true && btnLockSwicth.IsSelected == true) { //鎵�鏈夐獙璇侀兘鍙栨秷浜�,鍒欏彇娑堣繙绋嬪紑閿佸姛鑳� - UserCenterResourse.Option.DoorUnLockByRemote = false; + UserCenterResourse.AccountOption.DoorUnLockByRemote = false; } - UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected; - UserCenterResourse.Option.Save(); + UserCenterResourse.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected; + UserCenterResourse.AccountOption.Save(); //閲嶆柊鍒锋柊鐣岄潰 this.InitMiddleFrame(); } @@ -288,11 +295,11 @@ private void DoRemoteUnLocks(MostRightIconControl btnLockSwicth) { if (btnLockSwicth.IsSelected == false - && string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true - && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true) + && string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true + && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true) { TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); - if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.Option.FingerprintAuthentication == false) + if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.AccountOption.FingerprintAuthentication == false) { //杩滅▼寮�閿佸紑鍚け璐ワ紝璇峰厛璁剧疆{0}浜屾瀹夊叏楠岃瘉鏂瑰紡 string msg = Language.StringByID(R.MyInternationalizationString.uUseUnLockByRemoteFailMsg); @@ -304,8 +311,8 @@ return; } } - UserCenterResourse.Option.DoorUnLockByRemote = !btnLockSwicth.IsSelected; - UserCenterResourse.Option.Save(); + UserCenterResourse.AccountOption.DoorUnLockByRemote = !btnLockSwicth.IsSelected; + UserCenterResourse.AccountOption.Save(); //閲嶆柊鍒锋柊鐣岄潰 this.InitMiddleFrame(); } @@ -372,6 +379,34 @@ } } + /// <summary> + /// 鏄剧ず鏁板瓧鍛戒护绐楀彛 + /// </summary> + private void ShowKeyNumberComandDialog() + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + dialogForm.SetTitleText("?????"); + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += ((textValue) => + { + dialogForm.CloseDialog(); + if (textValue == "2887") + { + //寮�鍚殣钘忚彍鍗� + UserCenterResourse.HideOption.CenterHideMenu = 1; + this.ShowMassage(ShowMsgType.Tip, "Ok!"); + } + if (textValue == "0001") + { + var form = new Guide.GuideHouseForm(); + form.ShowFrom(); + this.ShowMassage(ShowMsgType.Tip, "Ok!"); + } + }); + } + #endregion } } diff --git a/ZigbeeApp/Shared/Phone/UserView/HomePage.cs b/ZigbeeApp/Shared/Phone/UserView/HomePage.cs index 4386e5e..81b188b 100755 --- a/ZigbeeApp/Shared/Phone/UserView/HomePage.cs +++ b/ZigbeeApp/Shared/Phone/UserView/HomePage.cs @@ -68,7 +68,7 @@ //鍚姩ZigBee ZigBee.Common.Application.Init(); - Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { @@ -99,7 +99,7 @@ //鍚姩ZigBee ZigBee.Common.Application.Init(); - Room.InitAllRoom(); + UserCenter.HdlRoomLogic.Current.InitAllRoom(); Application.RunOnMainThread(() => { diff --git a/ZigbeeApp/Shared/Phone/UserView/SafetyShortcutControl.cs b/ZigbeeApp/Shared/Phone/UserView/SafetyShortcutControl.cs index fac3c75..5d447bb 100755 --- a/ZigbeeApp/Shared/Phone/UserView/SafetyShortcutControl.cs +++ b/ZigbeeApp/Shared/Phone/UserView/SafetyShortcutControl.cs @@ -5,7 +5,7 @@ namespace Shared.Phone.UserView { - public class SafetyShortcutControl:Button + public class SafetyShortcutControl : Button { /// <summary> /// dialog diff --git a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs index 2440cd3..bf0c4c4 100755 --- a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs +++ b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs @@ -11,21 +11,13 @@ namespace Shared.Phone.UserView { - /// <summary> /// 涓婚〉 /// </summary> - public class UserHomeView : FrameLayout, ZigBee.Common.IStatus - { - #region 鈼� 鍙橀噺____________________________ - /// <summary> - /// 璁惧鏄惁鍦ㄧ嚎鏍囪瘑--Online - /// </summary> - private readonly string deviceStatus_Online = "Online"; - /// <summary> - /// 璁惧鐘舵�佸紑鍏虫爣璇�--Switch - /// </summary> - private readonly string deviceStatus_OnOffStatus = "Switch"; + public class UserHomeView : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + /// <summary> /// 鍔熻兘ScrolViewLayout /// </summary> @@ -34,19 +26,10 @@ /// 鍔熻兘鍜屽満鏅痓odyView /// </summary> private FrameLayout functionSceneBodyView; - - /// <summary> - /// The height of the room page view. -- 550 - /// </summary> - private static readonly int roomPageView_Height = 550; - /// <summary> - /// 鍔熻兘鍗$墖楂樺害 --250 - /// </summary> - private static readonly int deviceFL_Height = 250; /// <summary> /// 鍔熻兘鎸夐敭 /// </summary> - private Button functionBtn; + private NormalViewControl btnFunction; /// <summary> /// 璇诲彇璁惧鐘舵�佺殑绾跨▼鍒楄〃 @@ -70,517 +53,109 @@ /// </summary> private bool sendedControlCommand = false; - /// <summary> - /// 寤舵椂 300姣 - /// </summary> - private readonly int sleepSpan = 300; - - private FrameLayout itemView = new FrameLayout(); /// <summary> - /// floorBtn + /// btnFloor /// </summary> - private Button floorBtn; - /// <summary> - /// timeDic - /// </summary> - private Dictionary<string, Timer> timerDic = new Dictionary<string, Timer> { }; + private NormalViewControl btnFloor; /// <summary> /// sceneScrolView /// </summary> - private VerticalScrolViewLayout sceneScrolView ; - + private VerticalScrolViewLayout sceneScrolView; #endregion - - #region 鈼� 鎺ュ彛____________________________ - - /// <summary> - /// 璇ユ帴鍙e皢寮冪敤 !!!!!! - /// 鏀圭敤DeviceInfoChange() - /// </summary> - /// <returns>The changed.</returns> - /// <param name="common">Common.</param> - public void Changed(CommonDevice common) - { - - } - - /// <summary> - /// 璁惧鐘舵�佹洿鏂版帴鍙� - /// <para>type锛氬鏋滀负 DeviceInComingRespon:璁惧鏂颁笂鎶�</para> - /// <para>type锛氬鏋滀负 IASInfoReport:RemoveDeviceRespon</para> - /// <para>type锛氬鏋滀负 DeviceStatusReport:璁惧涓婃姤</para> - /// <para>type锛氬鏋滀负 IASInfoReport:IAS瀹夐槻淇℃伅涓婃姤</para> - /// <para>type锛氬鏋滀负 OnlineStatusChange: 璁惧鍦ㄧ嚎鐘舵�佹洿鏂�</para> - /// </summary> - /// <param name="common">Common.</param> - /// <param name="typeTag">Type tag.</param> - public void DeviceInfoChange(CommonDevice common, string typeTag) - { - //璁惧涓婃姤鐘舵�佷腑 褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁� - if (typeTag == "DeviceStatusReport") - { - Application.RunOnMainThread(() => - { - try - { - if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0) - { - return; - } - for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) - { - var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; - if (rowFL.ChildrenCount == 0) - { - //璁惧涓虹┖鎴栬�呮帶浠朵负绌� - continue; - } - for (int j = 0; j < rowFL.ChildrenCount; j++) - { - var deviceUI = (rowFL.GetChildren(j) as FunctionMainView).Tag as DeviceUI; - if (deviceUI == null || deviceUI.CommonDevice == null) - { - //璁惧涓虹┖鎴栬�呮帶浠朵负绌� - continue; - } - if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint) - { - //鍒ゆ柇鏄惁涓哄綋鍓嶈澶� - continue; - } + #region 鈻� 鍒濆鍖朹____________________________ - switch (deviceUI.CommonDevice.Type) - { - case DeviceType.OnOffOutput: - //寮�鍏冲姛鑳� - if (common.DeviceStatusReport.CluterID == 6) - { - var onOffOutputLight = deviceUI.CommonDevice as ZigBee.Device.ToggleLight; - onOffOutputLight.DeviceStatusReport = common.DeviceStatusReport; - onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = onOffOutputLight.OnOffStatus == 1; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - onOffOutputLight.LastDateTime = DateTime.Now; - } - break; - - case DeviceType.AirSwitch: - //寮�鍏冲姛鑳� - if (common.DeviceStatusReport.CluterID == 6) - { - var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch; - airSwitch.DeviceStatusReport = common.DeviceStatusReport; - airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = airSwitch.OnOffStatus == 1; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - airSwitch.LastDateTime = DateTime.Now; - } - //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁� - if (common.DeviceStatusReport.CluterID == 3) - { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; - } - break; - - case DeviceType.WindowCoveringDevice: - if (common.DeviceStatusReport.CluterID == 258) - { - if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0) - { - //绐楀笜绫诲瀷 - var rollerShade = deviceUI.CommonDevice as Rollershade; - rollerShade.DeviceStatusReport = common.DeviceStatusReport; - rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData; - rollerShade.LastDateTime = DateTime.Now; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - if (common.DeviceStatusReport.AttriBute[0].AttributeId == 8) - { - //绐楀笜鐧惧垎姣� - var rollerShade = deviceUI.CommonDevice as Rollershade; - rollerShade.DeviceStatusReport = common.DeviceStatusReport; - rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData; - rollerShade.LastDateTime = DateTime.Now; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - } - if (common.DeviceStatusReport.CluterID == 3) - { - deviceUI.CommonDevice.IsOnline = 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; - } - break; - - case DeviceType.Thermostat: - //AC鍔熻兘 - if (common.DeviceStatusReport.CluterID == 513) - { - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; - ac.DeviceStatusReport = common.DeviceStatusReport; - var attriButeList = ac.DeviceStatusReport.AttriBute; - foreach (var attList in attriButeList) - { - var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default; - switch (attList.AttributeId) - { - case 0: - //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝 - ac.currentLocalTemperature = curTemp; - ac.LastDateTime = DateTime.Now; - break; - case 17: - //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鍐锋俯搴︼紝瀹為檯娓╁害涓衡�淐oolingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� - ac.currentCoolingSetpoint = curTemp; - ac.LastDateTime = DateTime.Now; - break; - case 18: - //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鐑俯搴︼紝瀹為檯娓╁害涓衡�淗eatingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� - ac.currentHeatingSetpoint = curTemp; - ac.LastDateTime = DateTime.Now; - break; - case 4096: - //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勮嚜鍔ㄦ俯搴︼紝瀹為檯娓╁害涓衡�淎utoSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� - ac.currentAutoSetpoint = curTemp; - ac.LastDateTime = DateTime.Now; - break; - - case 28: - //姝ゅ睘鎬ф弿杩版亽娓╄澶囨澶勪簬鍝妯″紡 - ac.currentSystemMode = attList.AttriButeData; - ac.LastDateTime = DateTime.Now; - break; - } - } - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = ac.currentSystemMode != 0; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - if (common.DeviceStatusReport.CluterID == 514) - { - var ac = deviceUI.CommonDevice as ZigBee.Device.AC; - var attriButeList = common.DeviceStatusReport.AttriBute; - ac.DeviceStatusReport = common.DeviceStatusReport; - foreach (var attList in attriButeList) - { - switch (attList.AttributeId) - { - case 0: - ac.currentFanMode = attList.AttriButeData; - ac.LastDateTime = DateTime.Now; - break; - case 4096: - ac.currentFanSwingMode = attList.AttriButeData; - ac.LastDateTime = DateTime.Now; - break; - } - } - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = ac.currentSystemMode != 0; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁� - if (common.DeviceStatusReport.CluterID == 3) - { - var ac = deviceUI.CommonDevice as AC; - ac.IsOnline = 1; - ac.LastDateTime = DateTime.Now; - } - break; - - case DeviceType.DimmableLight: - //璋冨厜鐏姛鑳� - if (common.DeviceStatusReport.CluterID == 6) - { - var dimmableLight = deviceUI.CommonDevice as DimmableLight; - dimmableLight.DeviceStatusReport = common.DeviceStatusReport; - dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = dimmableLight.OnOffStatus == 1; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - dimmableLight.LastDateTime = DateTime.Now; - } - - //浜害 - if (common.DeviceStatusReport.CluterID == 8) - { - var dimmableLight = deviceUI.CommonDevice as DimmableLight; - dimmableLight.DeviceStatusReport = common.DeviceStatusReport; - var attriButeList = dimmableLight.DeviceStatusReport.AttriBute; - switch (attriButeList[0].AttributeId) - { - case 0: - //姝ゅ睘鎬ц〃鏄庡綋鍓嶄寒搴︾▼搴� - dimmableLight.Level = attriButeList[0].AttriButeData; - dimmableLight.LastDateTime = DateTime.Now; - //(rowFL.GetChildren(j) as FunctionMainView).IsSelected = true; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - break; - } - } - break; - case DeviceType.TemperatureSensor: - //娓╁害 - if (common.DeviceStatusReport.CluterID == 1026) - { - var tempera = deviceUI.CommonDevice as TemperatureSensor; - foreach (var data in common.DeviceStatusReport.AttriBute) - { - if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) - { - if (data.AttriButeData == 0) - { - tempera.Temperatrue = 0; - } - else if (data.AttriButeData > 32767) - { - //璐熸暟(鐗规畩澶勭悊) - string strValue = (data.AttriButeData - 65536).ToString(); - //灏忔暟鐐归渶瑕佷竴浣� - strValue = strValue.Substring(0, strValue.Length - 1); - tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); - } - else - { - //灏忔暟鐐归渶瑕佷竴浣� - string strValue = data.AttriButeData.ToString(); - strValue = strValue.Substring(0, strValue.Length - 1); - tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); - } - - tempera.LastDateTime = DateTime.Now; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - } - } - //婀垮害 - if (common.DeviceStatusReport.CluterID == 1029) - { - var tempera = deviceUI.CommonDevice as TemperatureSensor; - foreach (var data in common.DeviceStatusReport.AttriBute) - { - if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) - { - if (data.AttriButeData == 0) - { - tempera.Humidity = 0; - } - else - { - //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟) - string strValue = data.AttriButeData.ToString(); - strValue = strValue.Substring(0, strValue.Length - 1); - tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); - } - tempera.LastDateTime = DateTime.Now; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - } - } - } - break; - } - } - } - } - catch (Exception ex) - { - System.Console.WriteLine($"Error:{ex.Message}"); - } - }); - } - else if (typeTag == "IASInfoReport") - { - Application.RunOnMainThread(() => - { - try - { - for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) - { - var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; - if (rowFL.ChildrenCount == 0) - { - //璁惧涓虹┖鎴栬�呮帶浠朵负绌� - continue; - } - - for (int j = 0; j < rowFL.ChildrenCount; j++) - { - var deviceUI = (rowFL.GetChildren(j) as FunctionMainView).Tag as DeviceUI; - if (deviceUI == null || deviceUI.CommonDevice == null) - { - //璁惧涓虹┖鎴栬�呮帶浠朵负绌� - continue; - } - if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint) - { - //鍒ゆ柇鏄惁涓哄綋鍓嶈澶� - continue; - } - - switch (deviceUI.CommonDevice.Type) - { - case DeviceType.IASZone: - //ias - var ias = common as IASZone; - var iAS = deviceUI.CommonDevice as ZigBee.Device.IASZone; - iAS.iASInfo = ias.iASInfo; - (rowFL.GetChildren(j) as FunctionMainView).IsSelected = iAS.iASInfo?.Alarm1 == 1; - (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu(); - iAS.LastDateTime = DateTime.Now; - break; - } - } - } - } - catch (Exception ex) - { - System.Console.WriteLine($"Error:{ex.Message}"); - } - }); - } - } /// <summary> - /// Changeds the IL ogic status. + /// 鐣岄潰鏄剧ず /// </summary> - /// <param name="logic">Logic.</param> - public void ChangedILogicStatus(ZigBee.Device.Logic logic) + public void ShowForm() { - //throw new NotImplementedException(); - } - /// <summary> - /// Changeds the IS cene status. - /// </summary> - /// <param name="scene">Scene.</param> - public void ChangedISceneStatus(Scene scene) - { - //throw new NotImplementedException(); - } - #endregion - - #region 鈼� 鍒濆鍖朹_________________________ - - /// <summary> - /// Removes from parent. - /// </summary> - public override void RemoveFromParent() - { - RemoveStatuList(); - base.RemoveFromParent(); - } - - private void RemoveStatuList() - { - ZbGateway.StatusList.Remove(this); - RemoveAllUpdateControlDeviceStatuAction(); - } - - /// <summary> - /// 涓婚〉 --鎴戠殑瀹� - /// </summary> - public UserHomeView() - { - ZbGateway.StatusList.Add(this); - BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; - } - - /// <summary> - /// 鏄剧ず鐣岄潰 - /// </summary> - public void Show() - { + this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; + //娓呴櫎鍏ㄩ儴 this.RemoveAll(); + //鍒濆鍖栧ご閮ㄦ帶浠� + this.InitTopFrameLayoutControl(); + //鍒濆鍖栦腑闂存帶浠� + this.InitMidFrameLayoutControl(); + //娣诲姞璁惧鐘舵�佷笂鎶ヤ簨浠� + this.AddDeviceReportEvent(); + } - #region topview - var topFrameLayout = new FrameLayout() - { - Y = Application.GetRealHeight(60), - Height = Application.GetRealHeight(127), - BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, - }; - AddChidren(topFrameLayout); - - var floor = new Button - { - X = Application.GetRealWidth(CommonFormResouce.X_Left), - Width = Application.GetMinRealAverage(69), - Height = Application.GetMinRealAverage(69), - Gravity = Gravity.CenterVertical, - UnSelectedImagePath = "Item/Floor.png" - }; + /// <summary> + /// 鍒濆鍖栧ご閮ㄦ帶浠� + /// </summary> + private void InitTopFrameLayoutControl() + { + //澶撮儴瀹瑰櫒 + base.topFrameLayout = new FrameLayout(); + topFrameLayout.Y = Application.GetRealHeight(60); + topFrameLayout.Height = Application.GetRealHeight(127); + topFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; + this.AddChidren(topFrameLayout); + + //鎷ユ湁妤煎眰 if (Config.Instance.Home.FloorDics.Count > 0) - { - topFrameLayout.AddChidren(floor); + { + //妤煎眰鍥炬爣 + var btnFloorIcon = new IconViewControl(69); + btnFloorIcon.X = ControlCommonResourse.XXLeft; + btnFloorIcon.Gravity = Gravity.CenterVertical; + btnFloorIcon.UnSelectedImagePath = "Item/Floor.png"; + topFrameLayout.AddChidren(btnFloorIcon); + btnFloorIcon.ButtonClickEvent += (sender, e) => + { + //鏄剧ず閫夋嫨妤煎眰鐨勭晫闈� + this.ShowSelectFloorForm(); + }; + //妤煎眰鍚� + this.btnFloor = new NormalViewControl(500, 100, true); + btnFloor.X = btnFloorIcon.Right; + btnFloor.Gravity = Gravity.CenterVertical; + btnFloor.TextColor = ZigbeeColor.Current.GXCTextColor; + btnFloor.Text = Config.Instance.Home.GetCurrentFloorName; + btnFloor.IsBold = true; + topFrameLayout.AddChidren(btnFloor); + btnFloor.ButtonClickEvent += (sender, e) => + { + //鏄剧ず閫夋嫨妤煎眰鐨勭晫闈� + this.ShowSelectFloorForm(); + }; } - - floorBtn = new Button + //瀹夐槻蹇嵎鏂瑰紡 + if (UserCenterResourse.ResidenceOption.SafetyShortcut) { - X = floor.Right, - Width = Application.GetRealWidth(500), - Height = Application.GetRealHeight(100), - Gravity = Gravity.CenterVertical, - TextAlignment = TextAlignment.CenterLeft, - TextColor = ZigbeeColor.Current.GXCTextColor, - Text = Config.Instance.Home.GetCurrentFloorName, - IsBold = true, - TextSize = 14 - }; - if (Config.Instance.Home.FloorDics.Count > 0) - { - topFrameLayout.AddChidren(floorBtn); + var btnSafety = new SafetyShortcutControl(); + btnSafety.X = Application.GetRealWidth(860); + btnSafety.Gravity = Gravity.CenterVertical; + topFrameLayout.AddChidren(btnSafety); } + //娑堟伅鍥炬爣 + var btnMessage = new MessageManagementControl(); + btnMessage.X = Application.GetRealWidth(953); + btnMessage.Gravity = Gravity.CenterVertical; + btnMessage.UnSelectedImagePath = "Item/Message.png"; + btnMessage.SelectedImagePath = "Item/MessageSelected.png"; + topFrameLayout.AddChidren(btnMessage); - if(UserCenterResourse.Option.SafetyShortcut) - { - var safetyBtn = new SafetyShortcutControl(); - safetyBtn.X = Application.GetRealWidth(860); - safetyBtn.Gravity = Gravity.CenterVertical; - topFrameLayout.AddChidren(safetyBtn); - } + //浣忓畢鍚嶅瓧 + var btnHouseName = new NormalViewControl(700, 95, true); + btnHouseName.X = ControlCommonResourse.XXLeft; + btnHouseName.Y = Application.GetRealHeight(161); + btnHouseName.TextSize = 24; + btnHouseName.TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor; + btnHouseName.IsBold = true; + btnHouseName.Text = Config.Instance.Home.Name; + this.AddChidren(btnHouseName); - var messageBtn = new MessageManagementControl(); - messageBtn.X = Application.GetRealWidth(953); - messageBtn.Gravity = Gravity.CenterVertical; - messageBtn.UnSelectedImagePath = "Item/Message.png"; - messageBtn.SelectedImagePath = "Item/MessageSelected.png"; - topFrameLayout.AddChidren(messageBtn); - - var residecneName = new Button() - { - X = Application.GetRealWidth(CommonFormResouce.X_Left), - Y = Application.GetRealHeight(161), - Width = Application.GetRealWidth(700), - Height = Application.GetRealHeight(95), - TextAlignment = TextAlignment.CenterLeft, - Text = Config.Instance.Home.Name ?? Language.StringByID(R.MyInternationalizationString.TheResidenceNameNull), - TextSize = 24, - TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, - IsBold=true - }; - if (Config.Instance.Home.IsOthreShare) - { - residecneName.Text = $"{Config.Instance.Home.Name}"; - } - AddChidren(residecneName); - - floor.MouseUpEventHandler += SelectFloor; - floorBtn.MouseUpEventHandler += SelectFloor; //鍒囨崲浣忓畢 - residecneName.MouseLongEventHandler += (send, e) => + btnHouseName.MouseLongEventHandler += (sender, e) => { - var tempHomeBtn = send as Button; if (Config.Instance.HomeFilePathList.Count == 0) { - var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst), Language.StringByID(R.MyInternationalizationString.Close), Language.StringByID(R.MyInternationalizationString.Confrim)); - alert.Show(); - alert.ResultEventHandler += (senderHouse, eHouse) => - { - if (eHouse) - { - return; - } - }; + //褰撳墠浣忓畢涓虹┖锛岃鍏堝缓绔嬩綇瀹� + this.ShowMassage(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst)); } else { @@ -591,28 +166,34 @@ ChangeResidence(House.GetHouseByHouseId(houseId)); }; } - }; - - #endregion - - if (CanBindGateway() == false) + }; + } + + /// <summary> + /// 鍒濆鍖栦腑闂存帶浠� + /// </summary> + private void InitMidFrameLayoutControl() + { + //妫�娴嬫槸鍚︾粦瀹氭湁缃戝叧 + if (this.CheckHadBindGateway() == false) + { + //鏄剧ず娌℃湁缁戝畾杩囩綉鍏崇殑鐣岄潰 + this.ShowNoGatewayTip(); + } + else { - - var roomPageView = new HorizontalPages() - { - Y = Application.GetRealHeight(302), - Width = Application.GetRealWidth(CommonPage.AppRealWidth), - Height = Application.GetRealHeight(478), - }; - AddChidren(roomPageView); + var roomPageView = new HorizontalPages(); + roomPageView.Y = Application.GetRealHeight(302); + roomPageView.Width = Application.GetRealWidth(CommonPage.AppRealWidth); + roomPageView.Height = Application.GetRealHeight(478); + this.AddChidren(roomPageView); //绐佸嚭杈硅窛 roomPageView.TCBJ = Application.GetRealWidth(181); //涓や釜page涔嬮棿鐨勯棿璺� roomPageView.JMBJ = Application.GetRealWidth(0); //褰撳墠鎴块棿 - var rList = Room.CurrentRoom.GetRoomsByCurrentFloorIdAppendLoveRoom(); - Room.CurrentRoom = Room.CurrentRoom ?? rList[0]; + var rList = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom(); foreach (var room in rList) { var roomView = new Device.CommonForm.RoomView(0, 0); @@ -621,96 +202,19 @@ roomView.HideName(true); roomView.action += () => { - Show(); + this.ShowForm(); }; } - var curIndex = rList.FindIndex((obj) => obj.Id == Room.CurrentRoom.Id); + //璁剧疆鎴块棿鐨勫垵濮嬮�夋嫨 + var curIndex = rList.FindIndex((obj) => obj.Id == HdlRoomLogic.Current.CurrentRoom.Id); roomPageView.PageIndex = curIndex; if (roomPageView.GetChildren(roomPageView.PageIndex) != null) { (roomPageView.GetChildren(roomPageView.PageIndex) as RoomView).HideName(false); - - } - - var functionSceneView = new FrameLayout() - { - Y = Application.GetRealHeight(861), - Width = Application.GetRealWidth(832), - Height = Application.GetRealHeight(167), - Gravity = Gravity.CenterHorizontal, - BackgroundImagePath = "Item/SceneFunctionBG.png" - }; - AddChidren(functionSceneView); - - //鍦烘櫙 - var sceneBtn = new Button() - { - X = Application.GetRealWidth(30), - Y = Application.GetRealHeight(12), - Width = Application.GetRealWidth(350), - Height = Application.GetRealHeight(100), - TextColor = ZigbeeColor.Current.GXCTextGrayColor3, - SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, - TextID = R.MyInternationalizationString.Scence, - IsSelected = true, - TextSize=16, - IsBold=true - }; - functionSceneView.AddChidren(sceneBtn); - - //鍦烘櫙 - functionBtn = new Button() - { - X = Application.GetRealWidth(430), - Y = Application.GetRealHeight(12), - Width = Application.GetRealWidth(360), - Height = Application.GetRealHeight(100), - TextColor = ZigbeeColor.Current.GXCTextGrayColor3, - SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, - TextID = R.MyInternationalizationString.Function, - IsSelected = false, - TextSize=14 - }; - functionSceneView.AddChidren(functionBtn); - - //鍔熻兘鍜屽満鏅痓odyView - functionSceneBodyView = new FrameLayout() - { - Y = functionSceneView.Bottom, - Height = Application.GetRealHeight(750), - Gravity = Gravity.CenterHorizontal, - BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor - }; - AddChidren(functionSceneBodyView); - - //閫夋嫨鍔熻兘鍒嗘爮 - functionBtn.MouseUpEventHandler += (sender, e) => - { - sceneBtn.IsSelected = false; - functionBtn.IsSelected = true; - sceneBtn.TextSize = 14; - sceneBtn.IsBold = false; - functionBtn.TextSize = 16; - functionBtn.IsBold = true; - RefreshBodyView(); - }; - //閫夋嫨鍦烘櫙鍒嗘爮 - sceneBtn.MouseUpEventHandler += (sender, e) => - { - functionBtn.IsSelected = false; - sceneBtn.IsSelected = true; - sceneBtn.TextSize = 16; - sceneBtn.IsBold = true; - functionBtn.TextSize = 14; - functionBtn.IsBold = false; - RefreshBodyView(); - }; - - RefreshBodyView(); - + } roomPageView.PageChange += (sender, e) => { - if(roomPageView.GetChildren(roomPageView.PageIndex - 1) !=null) + if (roomPageView.GetChildren(roomPageView.PageIndex - 1) != null) { (roomPageView.GetChildren(roomPageView.PageIndex - 1) as RoomView).HideName(true); } @@ -723,162 +227,137 @@ (roomPageView.GetChildren(roomPageView.PageIndex) as RoomView).HideName(false); } //鍒囨崲褰撳墠鎴块棿 - Room.CurrentRoom = rList[roomPageView.PageIndex]; - RefreshBodyView(); - + HdlRoomLogic.Current.CurrentRoom = rList[roomPageView.PageIndex]; + //鍒锋柊璁惧妗屽竷鎺т欢 + this.RefreshBodyView(); }; - } - else - { - ShowNoGatewayTip(); - } + + //鍔熻兘鍜屽満鏅殑鑳屾櫙鍥� + var functionSceneView = new FrameLayout(); + functionSceneView.Y = Application.GetRealHeight(861); + functionSceneView.Width = Application.GetRealWidth(832); + functionSceneView.Height = Application.GetRealHeight(167); + functionSceneView.Gravity = Gravity.CenterHorizontal; + functionSceneView.BackgroundImagePath = "Item/SceneFunctionBG.png"; + this.AddChidren(functionSceneView); + + //鍦烘櫙 + var btnScene = new NormalViewControl(350, 100, true); + btnScene.X = Application.GetRealWidth(30); + btnScene.Y = Application.GetRealHeight(12); + btnScene.TextColor = ZigbeeColor.Current.GXCTextGrayColor3; + btnScene.SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor; + btnScene.TextID = R.MyInternationalizationString.Scence; + btnScene.IsSelected = true; + btnScene.TextSize = 16; + btnScene.IsBold = true; + btnScene.TextAlignment = TextAlignment.Center; + functionSceneView.AddChidren(btnScene); - } + //鍔熻兘 + btnFunction = new NormalViewControl(360, 100, true); + btnFunction.X = Application.GetRealWidth(430); + btnFunction.Y = Application.GetRealHeight(12); + btnFunction.TextColor = ZigbeeColor.Current.GXCTextGrayColor3; + btnFunction.SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor; + btnFunction.TextID = R.MyInternationalizationString.Function; + btnFunction.IsSelected = false; + btnFunction.TextAlignment = TextAlignment.Center; + functionSceneView.AddChidren(btnFunction); - #endregion + //鍔熻兘鍜屽満鏅痓odyView + functionSceneBodyView = new FrameLayout() + { + Y = functionSceneView.Bottom, + Height = Application.GetRealHeight(750), + Gravity = Gravity.CenterHorizontal, + BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor + }; + this.AddChidren(functionSceneBodyView); - #region 鈼� 鍒锋柊____________________________ - /// <summary> - /// RefreshBodyView - /// </summary> - public void RefreshBodyView() - { - functionSceneBodyView.RemoveAll(); - if (functionBtn.IsSelected) - { - ShowFunction(); - } - else - { - ShowScene(); - } - } - - /// <summary> - /// SelectFloor - /// </summary> - /// <param name="sender"></param> - /// <param name="mouseEventArgs"></param> - public void SelectFloor(object sender, MouseEventArgs mouseEventArgs) - { - var floorFL = new Phone.Device.Category.SelectFloor(); - AddChidren(floorFL); - floorFL.Init(35, 153); - floorFL.changeFloor = true; - floorFL.FloorAction = (floorId) => - { - floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId); - Common.Room.CurrentRoom = Common.Room.CurrentRoom?.GetLoveRoom(); - Show(); - }; - } - - #endregion - - #region 鈼� 妫�娴嬫槸鍚︾粦瀹氫簡缃戝叧________________ - - /// <summary> - /// 褰撴病鏈夌粦瀹氱綉鍏虫椂锛屾槸鍚︽湁鏉冮檺娣诲姞缃戝叧 - /// </summary> - /// <returns><c>true</c>, if bing gateway was caned, <c>false</c> otherwise.</returns> - private bool CanBindGateway() - { - if (HadBindGateway() == false && (UserCenter.UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenter.UserCenterResourse.UserInfo.AuthorityNo == 2)) - { - return true; - } - return false; - } - - /// <summary> - /// 鏄惁缁戝畾浜嗙綉鍏� - /// </summary> - /// <returns><c>true</c>, if bind gateway was haded, <c>false</c> otherwise.</returns> - private bool HadBindGateway() - { - var gatewayList = UserCenter.HdlGatewayLogic.Current.GetAllLocalGateway(); - if (gatewayList.Count == 0) - { - return false; - } - return true; - } - + //閫夋嫨鍔熻兘鍒嗘爮 + btnFunction.ButtonClickEvent += (sender, e) => + { + btnScene.IsSelected = false; + btnFunction.IsSelected = true; + btnScene.TextSize = 14; + btnScene.IsBold = false; + btnFunction.TextSize = 16; + btnFunction.IsBold = true; + //鍒锋柊璁惧妗屽竷鎺т欢 + this.RefreshBodyView(); + }; + //閫夋嫨鍦烘櫙鍒嗘爮 + btnScene.ButtonClickEvent += (sender, e) => + { + btnFunction.IsSelected = false; + btnScene.IsSelected = true; + btnScene.TextSize = 16; + btnScene.IsBold = true; + btnFunction.TextSize = 14; + btnFunction.IsBold = false; + this.RefreshBodyView(); + }; + //鍒锋柊璁惧妗屽竷鎺т欢 + this.RefreshBodyView(); + } + } + /// <summary> /// 鎻愮ず鐢ㄦ埛娌℃湁缃戝叧锛屽苟蹇�熻烦杞埌娣诲姞缃戝叧鐣岄潰 /// </summary> private void ShowNoGatewayTip() { - var bg = new Button - { - Y = Application.GetRealHeight(302), - Width = Application.GetMinRealAverage(717), - Height = Application.GetMinRealAverage(478), - Gravity = Gravity.CenterHorizontal, - UnSelectedImagePath = "Item/NoBindGW.png" + var bg = new PicViewControl(717, 478); + bg.Y = Application.GetRealHeight(302); + bg.Gravity = Gravity.CenterHorizontal; + bg.UnSelectedImagePath = "Item/NoBindGW.png"; + this.AddChidren(bg); + + var tip = new NormalViewControl(Application.GetMinRealAverage(717), Application.GetMinRealAverage(58), false); + tip.Y = Application.GetRealHeight(815); + tip.Gravity = Gravity.CenterHorizontal; + tip.TextID = R.MyInternationalizationString.NewAccountNeedBingGW; + tip.TextColor = ZigbeeColor.Current.GXCTextGrayColor; + tip.TextAlignment = TextAlignment.Center; + this.AddChidren(tip); + + var addBG = new PicViewControl(971, 366); + addBG.Y = Application.GetRealHeight(1048); + addBG.UnSelectedImagePath = "Item/VirtualFrame.png"; + addBG.Gravity = Gravity.CenterHorizontal; + this.AddChidren(addBG); + + var addGatewayBtn = new IconViewControl(89); + addGatewayBtn.Y = Application.GetRealHeight(1143); + addGatewayBtn.UnSelectedImagePath = "Item/Add_GW.png"; + addGatewayBtn.Gravity = Gravity.CenterHorizontal; + this.AddChidren(addGatewayBtn); + addGatewayBtn.ButtonClickEvent += (sender, e) => + { + var form = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm(); + form.AddForm(); }; - AddChidren(bg); - var tip = new Button - { - Y = Application.GetRealHeight(815), - Width = Application.GetMinRealAverage(717), - Height = Application.GetMinRealAverage(58), - Gravity = Gravity.CenterHorizontal, - TextID = R.MyInternationalizationString.NewAccountNeedBingGW, - TextColor = ZigbeeColor.Current.GXCTextGrayColor + var addTip = new PicViewControl(717, 58); + addTip.Y = Application.GetRealHeight(1256); + addTip.Gravity = Gravity.CenterHorizontal; + addTip.TextID = R.MyInternationalizationString.AddSmartGW; + addTip.TextColor = ZigbeeColor.Current.GXCTextBlackColor; + addTip.TextAlignment = TextAlignment.Center; + AddChidren(addTip); + + addTip.ButtonClickEvent += (sender, e) => + { + var form = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm(); + form.AddForm(); }; - AddChidren(tip); - - var addBG = new Button - { - Y = Application.GetRealHeight(1048), - Height = Application.GetMinRealAverage(366), - Width = Application.GetMinRealAverage(971), - UnSelectedImagePath = "Item/VirtualFrame.png", - Gravity = Gravity.CenterHorizontal - }; - AddChidren(addBG); - - var addGatewayBtn = new Button() - { - Y = Application.GetRealHeight(1143), - Height = Application.GetMinRealAverage(89), - Width = Application.GetMinRealAverage(89), - UnSelectedImagePath = "Item/Add_GW.png", - Gravity = Gravity.CenterHorizontal - }; - AddChidren(addGatewayBtn); - addGatewayBtn.MouseUpEventHandler += GoToAddGateWay; - - var addTip = new Button - { - Y = Application.GetRealHeight(1256), - Width = Application.GetMinRealAverage(717), - Height = Application.GetMinRealAverage(58), - Gravity = Gravity.CenterHorizontal, - TextID = R.MyInternationalizationString.AddSmartGW, - TextColor = ZigbeeColor.Current.GXCTextBlackColor - }; - AddChidren(addTip); - addTip.MouseUpEventHandler += GoToAddGateWay; - } - - /// <summary> - /// 鍓嶅線娣诲姞缃戝叧鐣岄潰 - /// </summary> - /// <param name="sender">Sender.</param> - /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> - private void GoToAddGateWay(object sender, MouseEventArgs mouseEventArgs) - { - var selectNewGateWayForm = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm { }; - selectNewGateWayForm.AddForm(); - } - + } + #endregion - - #region 鈼� 鍔熻兘_____________________________ - + + #region 鈻� 鍔熻兘鍒嗘敮___________________________ + /// <summary> /// 鏄剧ず娌℃湁鍔熻兘 /// </summary> @@ -900,7 +379,7 @@ Height = Application.GetRealHeight(200), Text = Language.StringByID(R.MyInternationalizationString.NoFunction_Tip).Replace("{\\r\\n}", "\r\n"), TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, - TextAlignment=TextAlignment.Center, + TextAlignment = TextAlignment.Center, IsMoreLines = true }; functionSceneBodyView.AddChidren(noFunctionTip); @@ -912,24 +391,20 @@ private void ShowFunction() { functionSceneBodyView.RemoveAll(); - //閫夋嫨鍔熻兘--鐩存帴浠庢埧闂寸殑devicelist涓幏鍙� - var deviceList = Room.CurrentRoom.DeviceUIList; - if (deviceList == null) - { - return; - } - - if (deviceList.Count == 0) + //褰撳墠鎴块棿鐨勮澶囨暟 + if (HdlRoomLogic.Current.CurrentRoom.ListDevice.Count == 0) { ShowNoFunctionTip(); } else { - var dList = new List<DeviceUI> { }; - foreach(var device in deviceList) + var dList = new List<CommonDevice>(); + foreach (var mainkeys in HdlRoomLogic.Current.CurrentRoom.ListDevice) { - var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device.CommonDevice); - if (info.BeloneType == DeviceBeloneType.A骞叉帴鐐� || info.BeloneType == DeviceBeloneType.A涓户鍣�) + var device = LocalDevice.Current.GetDevice(mainkeys); + if (device == null + || device.Type == DeviceType.OnOffSwitch//骞叉帴鐐� + || device.Type == DeviceType.Repeater)//涓户鍣� { continue; } @@ -941,759 +416,764 @@ for (int i = 0; i < dList.Count; i++) { var device = dList[i]; - //new System.Threading.Thread(() => - //{ - Application.RunOnMainThread(() => - { - try - { - int t = i % 2; - int tt = i / 2; - int xx = 43 + i % 2 * (20 + 487); - int yy = 14; - if (i % 2 == 0) - { - itemView = new FrameLayout() - { - Height = Application.GetRealHeight(14 + 348), - }; - deviceVerticalScrolViewLayout.AddChidren(itemView); - } - //鏀惰棌 - EventHandler<MouseEventArgs> collectionEvent = (sender, e) => - { - if ((sender as Button).IsSelected) - { - Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); - (sender as Button).IsSelected = false; - } - else - { - Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); - (sender as Button).IsSelected = true; - } - if (Room.CurrentRoom.IsLove) - { - RefreshBodyView(); - } - }; - - if (device.CommonDevice.Type == DeviceType.WindowCoveringDevice) - { - //绐楀笜 鍗峰笜 - var rollerShade = (ZigBee.Device.Rollershade)device.CommonDevice; - if (rollerShade.Gateway != null) - { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (rollerShade.Gateway.IsVirtual) - { - ReadStatus(rollerShade, () => - { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); - }); - } - else - { - if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - rollerShade.LastDateTime).TotalSeconds) - { - ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); - } - } - }) - { IsBackground = true }.Start(); - - var functionView = new FunctionMainView(xx, yy); - functionView.Tag = device; - itemView.AddChidren(functionView); - functionView.Init(); - functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetStatuText(device.GetDeviceStatu()); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(rollerShade)); - functionView.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; - functionView.SetCollect(true); - - functionView.SwitchButton.MouseUpEventHandler += (sender, e) => - { - (sender as Button).IsSelected = !(sender as Button).IsSelected; - if ((sender as Button).IsSelected) - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - (device.CommonDevice as Rollershade).CurtainUpDownStopControl(0); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(Language.StringByID(R.MyInternationalizationString.Open)); - ((sender as Button).Parent as FunctionMainView).IsSelected = true; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - else - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - (device.CommonDevice as Rollershade).CurtainUpDownStopControl(1); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); - ((sender as Button).Parent as FunctionMainView).IsSelected = false; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - }; - - functionView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - var rollerShadeControl = new Phone.Device.Curtain.RollerShadeControl(); - UserView.HomePage.Instance.AddChidren(rollerShadeControl); - UserView.HomePage.Instance.PageIndex += 1; - UserView.HomePage.Instance.ScrollEnabled = false; - rollerShadeControl.Show(device, Room.CurrentRoom); - rollerShadeControl.action += (curDev, curRoom) => - { - ReFreshEditDeviceAction(device, curRoom, functionView); - }; - }; - - functionView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.OnOffOutput) - { - //寮�鍏崇伅 - var light = device.CommonDevice as ToggleLight; - if (light.Gateway != null) + Application.RunOnMainThread(() => + { + try + { + int t = i % 2; + int tt = i / 2; + int xx = 43 + i % 2 * (20 + 487); + int yy = 14; + if (i % 2 == 0) + { + itemView = new FrameLayout() + { + Height = Application.GetRealHeight(14 + 348), + }; + deviceVerticalScrolViewLayout.AddChidren(itemView); + } + //鏀惰棌 + EventHandler<MouseEventArgs> collectionEvent = (sender, e) => + { + if ((sender as Button).IsSelected) + { + //鍒犻櫎鎴戠殑鍠滅埍 + HdlRoomLogic.Current.DeleteLoveDevice(device); + (sender as Button).IsSelected = false; + } + else + { + //娣诲姞鎴戠殑鍠滅埍 + HdlRoomLogic.Current.AddLoveDevice(device); + (sender as Button).IsSelected = true; + } + if (HdlRoomLogic.Current.CurrentRoom.IsLove) + { + //鍒锋柊璁惧妗屽竷鎺т欢 + this.RefreshBodyView(); + } + }; + + if (device.Type == DeviceType.WindowCoveringDevice) + { + //绐楀笜 鍗峰笜 + var rollerShade = (ZigBee.Device.Rollershade)device; + if (rollerShade.Gateway != null) + { + new System.Threading.Thread(() => { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (light.Gateway.IsVirtual) - { - ReadStatus(light, () => - { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); - }); - } - else - { - if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) - { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); - } - } - }) - { IsBackground = true }.Start(); - - var functionView = new FunctionMainView(xx, yy); - itemView.AddChidren(functionView); - functionView.Init(); - functionView.Tag = device; - functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetStatuText(device.GetDeviceStatu()); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - functionView.IsSelected = light.OnOffStatus == 1; - functionView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - functionView.CollectButton.IsSelected = false; - } - else - { - functionView.CollectButton.IsSelected = true; - } - - functionView.SwitchButton.MouseUpEventHandler += (sender, e) => - { - (sender as Button).IsSelected = !(sender as Button).IsSelected; - if ((sender as Button).IsSelected) - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - light.SwitchControl(1); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = true; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - else - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - light.SwitchControl(0); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = false; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - }; - - functionView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - - var lightControl = new Phone.Device.Light.OnOffControl(); - UserView.HomePage.Instance.AddChidren(lightControl); - UserView.HomePage.Instance.PageIndex += 1; - lightControl.Show(device, Room.CurrentRoom); - lightControl.action += (curDev, curRoom) => - { - ReFreshEditDeviceAction(device, curRoom, functionView); - }; - }; - - functionView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.AirSwitch) - { - //绌烘皵寮�鍏� - var airSwitch = device.CommonDevice as AirSwitch; - if (airSwitch.Gateway != null) - { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (airSwitch.Gateway.IsVirtual) - { - ReadStatus(airSwitch, () => - { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); - }); - } - else - { - if ((DateTime.Now - airSwitch.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) - { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); - } - } - }) - { IsBackground = true }.Start(); - - var functionView = new FunctionMainView(xx, yy); - itemView.AddChidren(functionView); - functionView.Init(); - functionView.Tag = device; - functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetStatuText(device.GetDeviceStatu()); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(airSwitch)); - functionView.IsSelected = airSwitch.OnOffStatus == 1; - functionView.SetCollect(Room.CurrentRoom.IsCollectInRoom( device.FileName)); - - functionView.SwitchButton.MouseUpEventHandler += (sender, e) => - { - (sender as Button).IsSelected = !(sender as Button).IsSelected; - if ((sender as Button).IsSelected) - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - airSwitch.SwitchControl(1); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = true; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - else - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - airSwitch.SwitchControl(0); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = false; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - }; - - functionView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - var lightControl = new Phone.Device.Light.AirSwitchControl(); - UserView.HomePage.Instance.AddChidren(lightControl); - UserView.HomePage.Instance.PageIndex += 1; - lightControl.Show(device, Room.CurrentRoom); - lightControl.action += (curDev, curRoom) => - { - ReFreshEditDeviceAction(device, curRoom, functionView); - }; - - }; - - functionView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.Thermostat) - { - //鎭掓俯鍣�-AC-绌鸿皟 - var ac = device.CommonDevice as AC; - if (ac.Gateway != null) - { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (ac.Gateway.IsVirtual) - { - ReadStatus(ac, () => - { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); - }); - } - else - { - if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) - { - ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); - } - } - }) - { IsBackground = true }.Start(); - - var functionView = new FunctionMainView(xx, yy); - itemView.AddChidren(functionView); - functionView.Init(); - functionView.Tag = device; - functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetStatuText(device.GetDeviceStatu()); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - functionView.IsSelected = ac.currentSystemMode != 0; - functionView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - - functionView.SwitchButton.MouseUpEventHandler += (sender, e) => - { - (sender as Button).IsSelected = !(sender as Button).IsSelected; - if ((sender as Button).IsSelected) - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - ac.Open(); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = true; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - else - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - ac.Close(); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = false; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - }; - - functionView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - var lightControl = new Phone.Device.AC.ACControl(); - UserView.HomePage.Instance.AddChidren(lightControl); - UserView.HomePage.Instance.PageIndex += 1; - lightControl.Show(device, Room.CurrentRoom); - lightControl.action += (curDev, curRoom) => - { - ReFreshEditDeviceAction(device, curRoom, functionView); - }; - }; - - functionView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.DimmableLight) - { - //璋冨厜鐏� - var dimmableLight = device.CommonDevice as DimmableLight; - if (dimmableLight.Gateway != null) - { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (dimmableLight.Gateway.IsVirtual) - { - //鍙戦�佽鍙栫姸鎬佸懡浠� - ReadStatus(dimmableLight, () => - { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); - }); - } - else - { - //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� - if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) - { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); - } - } - }) - { IsBackground = true }.Start(); - - var functionView = new FunctionMainView(xx, yy); - itemView.AddChidren(functionView); - functionView.Init(); - functionView.Tag = device; - functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetStatuText(device.GetDeviceStatu()); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - functionView.IsSelected = dimmableLight.OnOffStatus == 1; - functionView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - functionView.CollectButton.IsSelected = false; - } - else - { - functionView.CollectButton.IsSelected = true; - } - - functionView.SwitchButton.MouseUpEventHandler += (sender, e) => - { - (sender as Button).IsSelected = !(sender as Button).IsSelected; - if ((sender as Button).IsSelected) - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - dimmableLight.SwitchControl(1); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = true; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - else - { - zbGateway = device.CommonDevice.Gateway; - sendedControlCommand = false; - zbGateway.ReportAction += UpdateDeviceControllStatu; - AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); - - dimmableLight.SwitchControl(0); - - ((sender as Button).Parent as FunctionMainView).SetStatuText(device.GetDeviceStatu()); - ((sender as Button).Parent as FunctionMainView).IsSelected = false; - - //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => - { - if (Parent == null) - { - return; - } - RemoveUpdateControlDeviceStatuAction(zbGateway); - if (sendedControlCommand == false) - { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); - } - }); - } - }; - - functionView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - var dimmableLightControl = new Phone.Device.Light.DimmableLightControl(); - UserView.HomePage.Instance.AddChidren(dimmableLightControl); - UserView.HomePage.Instance.PageIndex += 1; - dimmableLightControl.Show(device, Room.CurrentRoom); - dimmableLightControl.action += (curDev, curRoom) => - { - ReFreshEditDeviceAction(device, curRoom, functionView); - }; - }; - functionView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.IASZone) - { - //鍚勭被浼犳劅鍣� - var ias = device.CommonDevice as IASZone; - - var lightView = new FunctionMainView(xx, yy); - itemView.AddChidren(lightView); - lightView.Init(); - lightView.Tag = device; - lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - lightView.SetStatuText(device.GetDeviceStatu()); - lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - lightView.IsSelected = ias.iASInfo?.Alarm1 == 1; - lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - lightView.CanControl(false); - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - lightView.CollectButton.IsSelected = false; - } - else - { - lightView.CollectButton.IsSelected = true; - } - lightView.CollectButton.MouseUpEventHandler += collectionEvent; - } - else if (device.CommonDevice.Type == DeviceType.TemperatureSensor) - { - var tempera = device.CommonDevice as TemperatureSensor; - - if (tempera.Gateway != null) - { - new System.Threading.Thread(() => - { - System.Threading.Thread.Sleep(100 * i); - if (tempera.Gateway.IsVirtual) - { - ReadStatus(tempera, () => - { - if (tempera.SensorDiv == 1) - { - ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(device.CommonDevice); - } - else if (tempera.SensorDiv == 2) - { - ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(device.CommonDevice); - } - }); - } - else - { - if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - tempera.LastDateTime).TotalSeconds) - { - if (tempera.SensorDiv == 1) - { - ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(device.CommonDevice); - } - else if (tempera.SensorDiv == 2) - { - ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(device.CommonDevice); - } - } - } - }) - { IsBackground = true }.Start(); - - var lightView = new FunctionMainView(xx, yy); - itemView.AddChidren(lightView); - lightView.Init(); - lightView.Tag = device; - lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - lightView.SetStatuText(device.GetDeviceStatu()); - lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - lightView.IsSelected = false; - lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - lightView.CanControl(false); - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - lightView.CollectButton.IsSelected = false; - } - else - { - lightView.CollectButton.IsSelected = true; - } - lightView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - else if (device.CommonDevice.Type == DeviceType.DoorLock) - { - //闂ㄩ攣 - var dimmableLight = device.CommonDevice as DoorLock; - - var lightView = new FunctionMainView(xx, yy); - itemView.AddChidren(lightView); - lightView.Init(); - lightView.Tag = device; - lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - lightView.SetStatuText(device.GetDeviceStatu()); - lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - lightView.IsSelected = false; - lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - lightView.CanControl(false); - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - lightView.CollectButton.IsSelected = false; - } - else - { - lightView.CollectButton.IsSelected = true; - } - - lightView.CardBG.MouseUpEventHandler += (sender, e) => - { - CommonPage.Instance.IsDrawerLockMode = true; - var userDoorLockPage = new UserDoorLockPage(Room.CurrentRoom, device); - HomePage.Instance.AddChidren(userDoorLockPage); - HomePage.Instance.PageIndex += 1; - userDoorLockPage.Show(); - }; - lightView.CollectButton.MouseUpEventHandler += collectionEvent; - } - else - { - var lightView = new FunctionMainView(xx, yy); - itemView.AddChidren(lightView); - lightView.Init(); - lightView.Tag = device; - lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - lightView.SetStatuText(device.GetDeviceStatu()); - lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - lightView.CanControl(false); - //lightView.IsSelected = device.CommonDevice.IsOnline == 1; - lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); - - if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) - { - lightView.CollectButton.IsSelected = false; - } - else - { - lightView.CollectButton.IsSelected = true; - } - lightView.CollectButton.MouseUpEventHandler += collectionEvent; - } - } - catch(Exception ex) - { - - } - }); + System.Threading.Thread.Sleep(100 * i); + if (rollerShade.Gateway.IsVirtual) + { + ReadStatus(rollerShade, () => + { + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device); + }); + } + else + { + if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - rollerShade.LastDateTime).TotalSeconds) + { + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device); + } + } + }) + { IsBackground = true }.Start(); + + var functionView = new FunctionMainView(xx, yy); + functionView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + itemView.AddChidren(functionView); + functionView.Init(); + functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + functionView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(rollerShade)); + functionView.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; + functionView.SetCollect(true); + + functionView.SwitchButton.MouseUpEventHandler += (sender, e) => + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + if ((sender as Button).IsSelected) + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + (device as Rollershade).CurtainUpDownStopControl(0); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(Language.StringByID(R.MyInternationalizationString.Open)); + ((sender as Button).Parent as FunctionMainView).IsSelected = true; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + else + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + (device as Rollershade).CurtainUpDownStopControl(1); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + ((sender as Button).Parent as FunctionMainView).IsSelected = false; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + }; + + functionView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + var rollerShadeControl = new Phone.Device.Curtain.RollerShadeControl(); + UserView.HomePage.Instance.AddChidren(rollerShadeControl); + UserView.HomePage.Instance.PageIndex += 1; + UserView.HomePage.Instance.ScrollEnabled = false; + rollerShadeControl.IsDrawerLockMode = true; + rollerShadeControl.Show(device, HdlRoomLogic.Current.CurrentRoom); + rollerShadeControl.action += (curDev, curRoom) => + { + ReFreshEditDeviceAction(device, curRoom, functionView); + }; + }; + + functionView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.OnOffOutput) + { + //寮�鍏崇伅 + var light = device as ToggleLight; + if (light.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (light.Gateway.IsVirtual) + { + ReadStatus(light, () => + { + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); + }); + } + else + { + if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) + { + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); + } + } + }) + { IsBackground = true }.Start(); + + var functionView = new FunctionMainView(xx, yy); + itemView.AddChidren(functionView); + functionView.Init(); + functionView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + functionView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + functionView.IsSelected = light.OnOffStatus == 1; + functionView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + functionView.CollectButton.IsSelected = false; + } + else + { + functionView.CollectButton.IsSelected = true; + } + + functionView.SwitchButton.MouseUpEventHandler += (sender, e) => + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + if ((sender as Button).IsSelected) + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + light.SwitchControl(1); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = true; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + else + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + light.SwitchControl(0); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = false; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + }; + + functionView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + + var lightControl = new Phone.Device.Light.OnOffControl(); + UserView.HomePage.Instance.AddChidren(lightControl); + UserView.HomePage.Instance.PageIndex += 1; + lightControl.IsDrawerLockMode = true; + lightControl.Show(device, HdlRoomLogic.Current.CurrentRoom); + lightControl.action += (curDev, curRoom) => + { + ReFreshEditDeviceAction(device, curRoom, functionView); + }; + }; + + functionView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.AirSwitch) + { + //绌烘皵寮�鍏� + var airSwitch = device as AirSwitch; + if (airSwitch.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (airSwitch.Gateway.IsVirtual) + { + ReadStatus(airSwitch, () => + { + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); + }); + } + else + { + if ((DateTime.Now - airSwitch.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) + { + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); + } + } + }) + { IsBackground = true }.Start(); + + var functionView = new FunctionMainView(xx, yy); + itemView.AddChidren(functionView); + functionView.Init(); + functionView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + functionView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(airSwitch)); + functionView.IsSelected = airSwitch.OnOffStatus == 1; + functionView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + + functionView.SwitchButton.MouseUpEventHandler += (sender, e) => + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + if ((sender as Button).IsSelected) + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + airSwitch.SwitchControl(1); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = true; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + else + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + airSwitch.SwitchControl(0); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = false; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + }; + + functionView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + var lightControl = new Phone.Device.Light.AirSwitchControl(); + UserView.HomePage.Instance.AddChidren(lightControl); + UserView.HomePage.Instance.PageIndex += 1; + lightControl.IsDrawerLockMode = true; + lightControl.Show(device, HdlRoomLogic.Current.CurrentRoom); + lightControl.action += (curDev, curRoom) => + { + ReFreshEditDeviceAction(device, curRoom, functionView); + }; + + }; + + functionView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.Thermostat) + { + //鎭掓俯鍣�-AC-绌鸿皟 + var ac = device as AC; + if (ac.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (ac.Gateway.IsVirtual) + { + ReadStatus(ac, () => + { + ReadDeviceAttributeLogic.Instance.SendACStatuComand(device); + }); + } + else + { + if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) + { + ReadDeviceAttributeLogic.Instance.SendACStatuComand(device); + } + } + }) + { IsBackground = true }.Start(); + + var functionView = new FunctionMainView(xx, yy); + itemView.AddChidren(functionView); + functionView.Init(); + functionView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + functionView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + functionView.IsSelected = ac.currentSystemMode != 0; + functionView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + + functionView.SwitchButton.MouseUpEventHandler += (sender, e) => + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + if ((sender as Button).IsSelected) + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + ac.Open(); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = true; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + else + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + ac.Close(); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = false; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + }; + + functionView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + var lightControl = new Phone.Device.AC.ACControl(); + UserView.HomePage.Instance.AddChidren(lightControl); + UserView.HomePage.Instance.PageIndex += 1; + lightControl.IsDrawerLockMode = true; + lightControl.Show(device, HdlRoomLogic.Current.CurrentRoom); + lightControl.action += (curDev, curRoom) => + { + ReFreshEditDeviceAction(device, curRoom, functionView); + }; + }; + + functionView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.DimmableLight) + { + //璋冨厜鐏� + var dimmableLight = device as DimmableLight; + if (dimmableLight.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (dimmableLight.Gateway.IsVirtual) + { + //鍙戦�佽鍙栫姸鎬佸懡浠� + ReadStatus(dimmableLight, () => + { + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); + }); + } + else + { + //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� + if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) + { + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); + } + } + }) + { IsBackground = true }.Start(); + + var functionView = new FunctionMainView(xx, yy); + itemView.AddChidren(functionView); + functionView.Init(); + functionView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + functionView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + functionView.IsSelected = dimmableLight.OnOffStatus == 1; + functionView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + functionView.CollectButton.IsSelected = false; + } + else + { + functionView.CollectButton.IsSelected = true; + } + + functionView.SwitchButton.MouseUpEventHandler += (sender, e) => + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + if ((sender as Button).IsSelected) + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + dimmableLight.SwitchControl(1); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = true; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + else + { + zbGateway = device.Gateway; + sendedControlCommand = false; + zbGateway.ReportAction += UpdateDeviceControllStatu; + AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device); + + dimmableLight.SwitchControl(0); + + ((sender as Button).Parent as FunctionMainView).SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + ((sender as Button).Parent as FunctionMainView).IsSelected = false; + + //鎺у埗寤舵椂鍥炶皟 + HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => + { + if (Parent == null) + { + return; + } + RemoveUpdateControlDeviceStatuAction(zbGateway); + if (sendedControlCommand == false) + { + HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); + } + }); + } + }; + + functionView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + var dimmableLightControl = new Phone.Device.Light.DimmableLightControl(); + UserView.HomePage.Instance.AddChidren(dimmableLightControl); + UserView.HomePage.Instance.PageIndex += 1; + dimmableLightControl.IsDrawerLockMode = true; + dimmableLightControl.Show(device, HdlRoomLogic.Current.CurrentRoom); + dimmableLightControl.action += (curDev, curRoom) => + { + ReFreshEditDeviceAction(device, curRoom, functionView); + }; + }; + functionView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.IASZone) + { + //鍚勭被浼犳劅鍣� + var ias = device as IASZone; + + var lightView = new FunctionMainView(xx, yy); + itemView.AddChidren(lightView); + lightView.Init(); + lightView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + lightView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + lightView.IsSelected = ias.iASInfo?.Alarm1 == 1; + lightView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + lightView.CanControl(false); + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + lightView.CollectButton.IsSelected = false; + } + else + { + lightView.CollectButton.IsSelected = true; + } + lightView.CollectButton.MouseUpEventHandler += collectionEvent; + } + else if (device.Type == DeviceType.TemperatureSensor) + { + var tempera = device as TemperatureSensor; + + if (tempera.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (tempera.Gateway.IsVirtual) + { + ReadStatus(tempera, () => + { + if (tempera.SensorDiv == 1) + { + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(device); + } + else if (tempera.SensorDiv == 2) + { + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(device); + } + }); + } + else + { + if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - tempera.LastDateTime).TotalSeconds) + { + if (tempera.SensorDiv == 1) + { + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(device); + } + else if (tempera.SensorDiv == 2) + { + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(device); + } + } + } + }) + { IsBackground = true }.Start(); + + var lightView = new FunctionMainView(xx, yy); + itemView.AddChidren(lightView); + lightView.Init(); + lightView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + lightView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + lightView.IsSelected = false; + lightView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + lightView.CanControl(false); + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + lightView.CollectButton.IsSelected = false; + } + else + { + lightView.CollectButton.IsSelected = true; + } + lightView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + else if (device.Type == DeviceType.DoorLock) + { + //闂ㄩ攣 + var dimmableLight = device as DoorLock; + + var lightView = new FunctionMainView(xx, yy); + itemView.AddChidren(lightView); + lightView.Init(); + lightView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + lightView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + lightView.IsSelected = false; + lightView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + lightView.CanControl(false); + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + lightView.CollectButton.IsSelected = false; + } + else + { + lightView.CollectButton.IsSelected = true; + } + + lightView.CardBG.MouseUpEventHandler += (sender, e) => + { + CommonPage.Instance.IsDrawerLockMode = true; + var userDoorLockPage = new UserDoorLockPage(HdlRoomLogic.Current.CurrentRoom, device); + HomePage.Instance.AddChidren(userDoorLockPage); + HomePage.Instance.PageIndex += 1; + userDoorLockPage.Show(); + }; + lightView.CollectButton.MouseUpEventHandler += collectionEvent; + } + else + { + var lightView = new FunctionMainView(xx, yy); + itemView.AddChidren(lightView); + lightView.Init(); + lightView.Tag = LocalDevice.Current.GetDeviceMainKeys(device); + lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); + lightView.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(device)); + lightView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + lightView.CanControl(false); + lightView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); + + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) + { + lightView.CollectButton.IsSelected = false; + } + else + { + lightView.CollectButton.IsSelected = true; + } + lightView.CollectButton.MouseUpEventHandler += collectionEvent; + } + } + catch (Exception ex) + { + + } + }); //}) //{ IsBackground = true }.Start(); } @@ -1706,37 +1186,35 @@ /// <param name="device"></param> /// <param name="curRoom"></param> /// <param name="functionView"></param> - private void ReFreshEditDeviceAction(DeviceUI device, Common.Room curRoom, FunctionMainView functionView) + private void ReFreshEditDeviceAction(CommonDevice device, Common.Room curRoom, FunctionMainView functionView) { - if (Common.Room.CurrentRoom.IsLove) + if (HdlRoomLogic.Current.CurrentRoom.IsLove) { functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - if (Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + if (HdlRoomLogic.Current.IsCollectInRoom(device) == false) { ShowFunction(); } } else { - if (curRoom.Id != Common.Room.CurrentRoom.Id) + if (curRoom.Id != HdlRoomLogic.Current.CurrentRoom.Id) { - - Common.Room.CurrentRoom.DeleteDevice(device.FileName); ShowFunction(); } else { functionView.SetDeviceImage(device.IconPath, device.OnlineIconPath); - functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice)); - functionView.SetCollect(Room.CurrentRoom.IsCollectInRoom(device.FileName)); + functionView.SetDeviceName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + functionView.SetCollect(HdlRoomLogic.Current.IsCollectInRoom(device)); } } } #endregion - #region 鈼� 鍦烘櫙_____________________________ + #region 鈻� 鍦烘櫙鍒嗘敮___________________________ /// <summary> /// 鏄剧ず娌″満鏅� @@ -1758,7 +1236,7 @@ Height = Application.GetRealHeight(200), Text = Language.StringByID(R.MyInternationalizationString.NoScene_Tip).Replace("{\\r\\n}", "\r\n"), TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, - TextAlignment=TextAlignment.Center, + TextAlignment = TextAlignment.Center, IsMoreLines = true }; functionSceneBodyView.AddChidren(noScenceTip); @@ -1771,7 +1249,7 @@ { functionSceneBodyView.RemoveAll(); //閫夋嫨鍦烘櫙 - var sceneList = Room.CurrentRoom.SceneUIList; + var sceneList = HdlSceneLogic.Current.GetRoomSceneList(HdlRoomLogic.Current.CurrentRoom); if (sceneList == null) { return; @@ -1799,7 +1277,7 @@ itemView = new FrameLayout() { Height = Application.GetRealHeight(14 + 348), - Tag = scene + Tag = scene.Id }; sceneScrolView.AddChidren(itemView); } @@ -1872,9 +1350,29 @@ } } - #endregion + #endregion + + #region 鈻� 鍒锋柊_______________________________ - #region 鈼� 鍒囨崲浣忓畢_________________________ + /// <summary> + /// 鍒锋柊璁惧妗屽竷鎺т欢 + /// </summary> + public void RefreshBodyView() + { + functionSceneBodyView.RemoveAll(); + if (btnFunction.IsSelected) + { + ShowFunction(); + } + else + { + ShowScene(); + } + } + + #endregion + + #region 鈻� 鍒囨崲浣忓畢___________________________ /// <summary> /// 鍒囨崲浣忓畢 /// </summary> @@ -1885,22 +1383,22 @@ { CommonPage.Loading.Start(); new System.Threading.Thread(async () => - { - Config.Instance.HomeId = home.Id; - Config.Instance.Home = House.GetHouseByFilePath(home.FileName); - Global.CreateHomeDirectory(home.Id); - Config.Instance.Save(); - //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ - await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); - - Room.InitAllRoom(); - - Application.RunOnMainThread(() => - { - Show(); - CommonPage.Loading.Hide(); - }); - }) + { + Config.Instance.HomeId = home.Id; + Config.Instance.Home = House.GetHouseByFilePath(home.FileName); + Global.CreateHomeDirectory(home.Id); + Config.Instance.Save(); + //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼ + await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); + //鍒濆鍖栧叏閮ㄦ埧闂� + HdlRoomLogic.Current.InitAllRoom(); + + Application.RunOnMainThread(() => + { + ShowForm(); + CommonPage.Loading.Hide(); + }); + }) { IsBackground = true }.Start(); } catch (Exception ex) @@ -1916,7 +1414,7 @@ #endregion - #region 鈼� 杩涜璁惧鐘舵�佽鍙朹_________________ + #region 鈻� 杩涜璁惧鐘舵�佽鍙朹__________________ /// <summary> /// 鍒ゆ柇鏄惁鍙互杩涜璁惧鐘舵�佽鍙栥�傚湪鍥炶皟涓鍙� @@ -1965,7 +1463,7 @@ #endregion - #region 鈼� 鎺у埗鐘舵�乢________________________ + #region 鈻� 鎺у埗鐘舵�乢__________________________ /// <summary> /// 鏄剧ず璁惧鎺у埗鐘舵�� @@ -1985,7 +1483,7 @@ } //鏍囪宸茬粡鍙戦�佹帶鍒跺懡浠ゅ埌缃戝叧 sendedControlCommand = true; - //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success); + //HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.Success); } /// <summary> @@ -2033,6 +1531,386 @@ { commonDeviceList.Add(common); } + } + + #endregion + + #region 鈻� 璁惧鐘舵�佷笂鎶______________________ + + /// <summary> + /// 娣诲姞璁惧鐘舵�佷笂鎶ヤ簨浠� + /// </summary> + private void AddDeviceReportEvent() + { + //璁惧灞炴�т笂鎶� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceStatus", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => + { + HdlThreadLogic.Current.RunMain(() => + { + if (report.DeviceStatusReport.AttriBute == null || report.DeviceStatusReport.AttriBute.Count == 0) + { + return; + } + for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) + { + var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; + if (rowFL.ChildrenCount == 0) + { + //璁惧涓虹┖鎴栬�呮帶浠朵负绌� + continue; + } + + for (int j = 0; j < rowFL.ChildrenCount; j++) + { + var deviceUI = LocalDevice.Current.GetDevice((rowFL.GetChildren(j) as FunctionMainView).Tag.ToString()); + if (deviceUI == null) + { + //璁惧涓虹┖鎴栬�呮帶浠朵负绌� + continue; + } + if (report.DeviceAddr != deviceUI.DeviceAddr || report.DeviceEpoint != deviceUI.DeviceEpoint) + { + //鍒ゆ柇鏄惁涓哄綋鍓嶈澶� + continue; + } + + switch (deviceUI.Type) + { + case DeviceType.OnOffOutput: + //寮�鍏冲姛鑳� + if (report.DeviceStatusReport.CluterID == 6) + { + var onOffOutputLight = deviceUI as ZigBee.Device.ToggleLight; + onOffOutputLight.DeviceStatusReport = report.DeviceStatusReport; + onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = onOffOutputLight.OnOffStatus == 1; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + onOffOutputLight.LastDateTime = DateTime.Now; + } + break; + + case DeviceType.AirSwitch: + //寮�鍏冲姛鑳� + if (report.DeviceStatusReport.CluterID == 6) + { + var airSwitch = deviceUI as ZigBee.Device.AirSwitch; + airSwitch.DeviceStatusReport = report.DeviceStatusReport; + airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = airSwitch.OnOffStatus == 1; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + airSwitch.LastDateTime = DateTime.Now; + } + //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁� + if (report.DeviceStatusReport.CluterID == 3) + { + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; + } + break; + + case DeviceType.WindowCoveringDevice: + if (report.DeviceStatusReport.CluterID == 258) + { + if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0) + { + //绐楀笜绫诲瀷 + var rollerShade = deviceUI as Rollershade; + rollerShade.DeviceStatusReport = report.DeviceStatusReport; + rollerShade.WcdType = report.DeviceStatusReport.AttriBute[0].AttriButeData; + rollerShade.LastDateTime = DateTime.Now; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + if (report.DeviceStatusReport.AttriBute[0].AttributeId == 8) + { + //绐楀笜鐧惧垎姣� + var rollerShade = deviceUI as Rollershade; + rollerShade.DeviceStatusReport = report.DeviceStatusReport; + rollerShade.WcdCurrentPositionLiftPercentage = report.DeviceStatusReport.AttriBute[0].AttriButeData; + rollerShade.LastDateTime = DateTime.Now; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + } + if (report.DeviceStatusReport.CluterID == 3) + { + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; + } + break; + + case DeviceType.Thermostat: + //AC鍔熻兘 + if (report.DeviceStatusReport.CluterID == 513) + { + var ac = deviceUI as ZigBee.Device.AC; + ac.DeviceStatusReport = report.DeviceStatusReport; + var attriButeList = ac.DeviceStatusReport.AttriBute; + foreach (var attList in attriButeList) + { + var curTemp = attList.AttriButeData / 100; + switch (attList.AttributeId) + { + case 0: + //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝 + ac.currentLocalTemperature = curTemp; + ac.LastDateTime = DateTime.Now; + break; + case 17: + //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鍐锋俯搴︼紝瀹為檯娓╁害涓衡�淐oolingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� + ac.currentCoolingSetpoint = curTemp; + ac.LastDateTime = DateTime.Now; + break; + case 18: + //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鐑俯搴︼紝瀹為檯娓╁害涓衡�淗eatingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� + ac.currentHeatingSetpoint = curTemp; + ac.LastDateTime = DateTime.Now; + break; + case 4096: + //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勮嚜鍔ㄦ俯搴︼紝瀹為檯娓╁害涓衡�淎utoSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆� + ac.currentAutoSetpoint = curTemp; + ac.LastDateTime = DateTime.Now; + break; + + case 28: + //姝ゅ睘鎬ф弿杩版亽娓╄澶囨澶勪簬鍝妯″紡 + ac.currentSystemMode = attList.AttriButeData; + ac.LastDateTime = DateTime.Now; + break; + } + } + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = ac.currentSystemMode != 0; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + if (report.DeviceStatusReport.CluterID == 514) + { + var ac = deviceUI as ZigBee.Device.AC; + var attriButeList = report.DeviceStatusReport.AttriBute; + ac.DeviceStatusReport = report.DeviceStatusReport; + foreach (var attList in attriButeList) + { + switch (attList.AttributeId) + { + case 0: + ac.currentFanMode = attList.AttriButeData; + ac.LastDateTime = DateTime.Now; + break; + case 4096: + ac.currentFanSwingMode = attList.AttriButeData; + ac.LastDateTime = DateTime.Now; + break; + } + } + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = ac.currentSystemMode != 0; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁� + if (report.DeviceStatusReport.CluterID == 3) + { + deviceUI.IsOnline = 1; + deviceUI.LastDateTime = DateTime.Now; + } + break; + + case DeviceType.DimmableLight: + //璋冨厜鐏姛鑳� + if (report.DeviceStatusReport.CluterID == 6) + { + var dimmableLight = deviceUI as DimmableLight; + dimmableLight.DeviceStatusReport = report.DeviceStatusReport; + dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = dimmableLight.OnOffStatus == 1; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + dimmableLight.LastDateTime = DateTime.Now; + } + + //浜害 + if (report.DeviceStatusReport.CluterID == 8) + { + var dimmableLight = deviceUI as DimmableLight; + dimmableLight.DeviceStatusReport = report.DeviceStatusReport; + var attriButeList = dimmableLight.DeviceStatusReport.AttriBute; + switch (attriButeList[0].AttributeId) + { + case 0: + //姝ゅ睘鎬ц〃鏄庡綋鍓嶄寒搴︾▼搴� + dimmableLight.Level = attriButeList[0].AttriButeData; + dimmableLight.LastDateTime = DateTime.Now; + //(rowFL.GetChildren(j) as FunctionMainView).IsSelected = true; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + break; + } + } + break; + case DeviceType.TemperatureSensor: + //娓╁害 + if (report.DeviceStatusReport.CluterID == 1026) + { + var tempera = deviceUI as TemperatureSensor; + foreach (var data in report.DeviceStatusReport.AttriBute) + { + if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) + { + if (data.AttriButeData == 0) + { + tempera.Temperatrue = 0; + } + else if (data.AttriButeData > 32767) + { + //璐熸暟(鐗规畩澶勭悊) + string strValue = (data.AttriButeData - 65536).ToString(); + //灏忔暟鐐归渶瑕佷竴浣� + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + } + else + { + //灏忔暟鐐归渶瑕佷竴浣� + string strValue = data.AttriButeData.ToString(); + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + } + + tempera.LastDateTime = DateTime.Now; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + } + } + //婀垮害 + if (report.DeviceStatusReport.CluterID == 1029) + { + var tempera = deviceUI as TemperatureSensor; + foreach (var data in report.DeviceStatusReport.AttriBute) + { + if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) + { + if (data.AttriButeData == 0) + { + tempera.Humidity = 0; + } + else + { + //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟) + string strValue = data.AttriButeData.ToString(); + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + } + tempera.LastDateTime = DateTime.Now; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + } + } + } + break; + } + } + } + + }, ShowErrorMode.NO); + }); + + //浼犳劅鍣ㄤ笂鎶� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (report) => + { + HdlThreadLogic.Current.RunMain(() => + { + for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) + { + var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; + if (rowFL.ChildrenCount == 0) + { + //璁惧涓虹┖鎴栬�呮帶浠朵负绌� + continue; + } + + for (int j = 0; j < rowFL.ChildrenCount; j++) + { + var deviceUI = LocalDevice.Current.GetDevice((rowFL.GetChildren(j) as FunctionMainView).Tag.ToString()); + if (deviceUI == null) + { + //璁惧涓虹┖鎴栬�呮帶浠朵负绌� + continue; + } + if (report.DeviceAddr != deviceUI.DeviceAddr || report.DeviceEpoint != deviceUI.DeviceEpoint) + { + //鍒ゆ柇鏄惁涓哄綋鍓嶈澶� + continue; + } + + switch (deviceUI.Type) + { + case DeviceType.IASZone: + //ias + var ias = report as IASZone; + var iAS = deviceUI as ZigBee.Device.IASZone; + iAS.iASInfo = ias.iASInfo; + (rowFL.GetChildren(j) as FunctionMainView).IsSelected = iAS.iASInfo?.Alarm1 == 1; + (rowFL.GetChildren(j) as FunctionMainView).StatuButton.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI); + iAS.LastDateTime = DateTime.Now; + break; + } + } + } + }, ShowErrorMode.NO); + }); + } + + #endregion + + #region 鈻� 鍒囨崲妤煎眰___________________________ + + /// <summary> + /// 鏄剧ず閫夋嫨妤煎眰鐨勭晫闈� + /// </summary> + private void ShowSelectFloorForm() + { + var floorFL = new Device.Category.SelectFloor(); + this.AddChidren(floorFL); + floorFL.Init(35, 153); + floorFL.changeFloor = true; + floorFL.FloorAction = (floorId) => + { + this.btnFloor.Text = Config.Instance.Home.GetFloorNameById(floorId); + HdlRoomLogic.Current.CurrentRoom = HdlRoomLogic.Current.GetLoveRoom(); + this.ShowForm(); + }; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewDeviceStatus"); + HdlGatewayReceiveLogic.Current.RemoveEvent("UserHomeViewSensor"); + + base.CloseFormBefore(); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 妫�娴嬫槸鍚︾粦瀹氭湁缃戝叧 + /// </summary> + private bool CheckHadBindGateway() + { + //鑾峰彇鏈湴宸茬粡缁戝畾鐨勭綉鍏� + var gatewayList = HdlGatewayLogic.Current.GetAllLocalGateway(); + if (gatewayList.Count == 0) + { + return false; + } + //涓讳汉鎴栬�呯鐞嗗憳鎵嶈 + if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) + { + return true; + } + return false; } #endregion diff --git a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs index f31d6c9..c9688eb 100755 --- a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs +++ b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs @@ -537,7 +537,7 @@ Instance.homePageIMG.IsSelected = true; var home = new UserHomeView { }; Instance.BodyView.AddChidren(home); - home.Show(); + home.ShowForm(); } else if (sender == Instance.categoryIMG || sender==Instance.categoryName) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs index e53f180..30ae20b 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs @@ -258,6 +258,22 @@ //鏍囪褰撳墠缃戝叧鏄富缃戝叧 gateWay.getGatewayBaseInfo.IsMainGateWay = true; } + } + + //娴嬭瘯鑳藉惁骞挎挱寰楀埌缃戝叧,閫氬父鎯呭喌涓嬩笉妫�娴� + if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.CheckCanReceiveGateway == 1) + { + if (Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest.ContainsKey(id) == false) + { + if (gateWay == null) + { + Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest[id] = zbGateWay; + } + else + { + Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest[id] = gateWay; + } + } } } } diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs index 36c1d58..b85b2c0 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs @@ -3362,7 +3362,21 @@ { if (!RemoteMqttClient.IsConnected || !IsRemote) { - return; + if (e.ApplicationMessage.Topic != "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze") + { + return; + } + } + //濡傛灉褰撳墠浣跨敤鐨勬槸鍐呯綉妯″紡 + if (IsRemote == false) + { + if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//韪汉涓嬬嚎 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//鍒嗕韩鍒犻櫎 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData") + { + mqttRemoteClient_MqttMsgPublishReceived(e); + } + return; } mqttRemoteClient_MqttMsgPublishReceived(e); }); diff --git a/ZigbeeApp/Shared/R.cs b/ZigbeeApp/Shared/R.cs index 58c0e31..c859024 100755 --- a/ZigbeeApp/Shared/R.cs +++ b/ZigbeeApp/Shared/R.cs @@ -1185,7 +1185,7 @@ /// </summary> public const int TheRoomIsSharedNotAllowedToOperate = 13120; /// <summary> - /// 杩樻病閫夋嫨鎴块棿锛岃鍏堥�夋嫨 + /// 杩樻病閫夋嫨鍖哄煙锛岃鍏堥�夋嫨 /// </summary> public const int NotSelectZone = 13121; /// <summary> @@ -5327,6 +5327,10 @@ /// 鑳屽厜鐏寒搴� /// </summary> public const int uBacklightBrightness = 16072; + /// <summary> + /// 鎵撳紑 + /// </summary> + public const int uOpen1 = 16073; @@ -5694,6 +5698,15 @@ /// 闀滃儚ID涓�253鐨勮澶囩殑榛樿鍚嶅瓧锛氭柟鎮︾幆澧冮潰鏉� /// </summary> public const int uDeviceModelId253 = 30033; + /// <summary> + /// 闀滃儚ID涓�224鐨勮澶囩殑榛樿鍚嶅瓧锛氱畝绾�4鎸夐敭鍦烘櫙闈㈡澘 + /// </summary> + public const int uDeviceModelId224 = 30034; + /// <summary> + /// 闀滃儚ID涓�226鐨勮澶囩殑榛樿鍚嶅瓧锛氱畝绾�2璺獥甯橀潰鏉� + /// </summary> + public const int uDeviceModelId226 = 30035; + //鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄澶囨墍灞炵绫荤殑缈昏瘧鍚嶅瓧,浠�40000寮�濮嬧槄鈽呪槄鈽� /// <summary> diff --git a/ZigbeeApp/Shared/Shared.projitems b/ZigbeeApp/Shared/Shared.projitems index b77d82d..6294487 100755 --- a/ZigbeeApp/Shared/Shared.projitems +++ b/ZigbeeApp/Shared/Shared.projitems @@ -122,6 +122,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Abount\AbountForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Abount\SLAForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Common\AccountOption.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Common\ResidenceOption.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\ClickButtonControls\BottomLeftClickButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\ClickButtonControls\BottomRightClickButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\BelongAreaControl.cs" /> @@ -146,9 +147,13 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlCheckLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceAirConditionerLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceCurtainLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceOtherLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlGatewayBackupLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlGatewayUpdateLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlLogLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlResidenceLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlRoomLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlSceneLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlThreadLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlWifiLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\AirConditioner\AirConditionerModeForm.cs" /> @@ -228,6 +233,9 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Guide\GuideRoomForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HdlBackup\HdlAutoBackupForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HdlBackup\HdlBackupListForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HideOption\HideOptionDirectoryListForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HideOption\HideOptionFileContentForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HideOption\HideOptionFileListForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HideOption\HideOptionGatewayListForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\HideOption\HideOptionMainForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Member\MemberNotEsixtForm.cs" /> @@ -275,11 +283,9 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\BaseCommonControl\Common\ClickButtonCommon.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\BaseCommonControl\Common\IconControlCommon.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\NormalControls\InformationTipView.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\NormalControls\TopLayoutTitleControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\FrameLayoutControls\FrameCaptionInputControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\FrameLayoutControls\FrameCaptionViewControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\DeviceControls\DeviceObjectControl.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\RowLayoutControls\RowMostRightTextView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\SafeguardLogControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\SceneControls\SceneRoomControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\SceneControls\SceneSimpleSelectControl.cs" /> @@ -420,7 +426,6 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Direction\AddDeviceTypeListForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\DeviceMacInfoEditorForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\DeviceAddSuccessForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Common\DeviceUI.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Safety\SafetyManagementMainForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\FrameLayoutControls\FrameRowControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Category\Category.cs" /> -- Gitblit v1.8.0