From 9acd3887f1f8db40d59f991b1726a61aa7c7637c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 12 五月 2021 15:13:56 +0800 Subject: [PATCH] Merge branch 'CJL' into wxr4 --- HDL_ON/UI/UI2/4-PersonalCenter/SmartSpeaker/SmartSpeakerRoomListPage.cs | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 311 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/SmartSpeaker/SmartSpeakerRoomListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/SmartSpeaker/SmartSpeakerRoomListPage.cs new file mode 100644 index 0000000..fd1aac3 --- /dev/null +++ b/HDL_ON/UI/UI2/4-PersonalCenter/SmartSpeaker/SmartSpeakerRoomListPage.cs @@ -0,0 +1,311 @@ +锘縰sing System; +using Shared; +using HDL_ON.UI.CSS; +using System.Collections.Generic; +using System.Threading; +using HDL_ON.DAL.Server; +using HDL_ON.Entity; + +namespace HDL_ON.UI +{ + + /// <summary> + /// 鎴块棿鍒楄〃 + /// </summary> + public class SmartSpeakerRoomListPage : FrameLayout + { + /// <summary> + /// bodyView + /// </summary> + FrameLayout bodyView; + + /// <summary> + /// 褰撳墠涓绘粦鍔╒iew + /// </summary> + VerticalScrolViewLayout bodyScrolView; + /// <summary> + /// 闊崇鍙傛暟 + /// </summary> + SpeakerInfo speakerInfo; + + /// <summary> + /// 鎴块棿鍒楄〃鍜屾棤鍖哄煙鍔熻兘椤甸潰 + /// </summary> + /// <param name="speakerInfo">闊崇鍙傛暟</param> + public SmartSpeakerRoomListPage(SpeakerInfo speakerInfo) + { + bodyView = this; + bodyView.BackgroundColor = CSS_Color.BackgroundColor; + this.speakerInfo = speakerInfo; + } + + /// <summary> + /// 鍔犺浇瑙嗗浘 + /// </summary> + public void LoadPage() + { + new TopViewDiv(bodyView, Language.StringByID(StringId.DataManagement)).LoadTopView(); + + int bodyY = Application.GetRealHeight(64); + bodyScrolView = new VerticalScrolViewLayout() + { + Y = bodyY, + Height = bodyView.Height - bodyY, + BackgroundColor = CSS_Color.BackgroundColor, + + }; + bodyView.AddChidren(bodyScrolView); + + //鍔犺浇鎴块棿鍒楄〃 + ShowRoomListView(); + } + + /// <summary> + /// 鍔犺浇鎴块棿鍒楄〃 + /// </summary> + void ShowRoomListView() + { + bodyScrolView.RemoveAll(); + + var titleView = new FrameLayout() + { + BackgroundColor = CSS_Color.MainBackgroundColor, + Height = Application.GetRealWidth(53), + }; + bodyScrolView.AddChidren(titleView); + //绠ご鍥炬爣 + var btnResidenceDownIcon = new Button() + { + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + X = Application.GetRealWidth(12), + Gravity = Gravity.CenterVertical, + UnSelectedImagePath = "Public/DownIcon.png", + }; + titleView.AddChidren(btnResidenceDownIcon); + //浣忓畢鏍囬 + var btnHomeTitle = new Button() + { + X = btnResidenceDownIcon.Right + Application.GetRealWidth(1), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + Text = DB_ResidenceData.Instance.CurrentRegion.Name, + }; + titleView.AddChidren(btnHomeTitle); + + //var btnLine = new Button() + //{ + // X = Application.GetRealWidth(16), + // Y = titleView.Height - Application.GetRealHeight(2), + // Width = Application.GetRealWidth(360), + // Height = Application.GetRealHeight(1), + // BackgroundColor = CSS_Color.DividingLineColor, + //}; + //titleView.AddChidren(btnLine); + + //--------------------------------------------- + //鏈垎閰嶅尯鍩熺殑鍔熻兘 + List<Function> allFunctionList = FunctionList.List.GetDeviceFunctionList(); + //鏈垎閰嶅尯鍩熺殑鍔熻兘 + List<Function> unallocatedList = new List<Function>(); + // + foreach (var function in allFunctionList) + { + function.roomIds.Remove(null); + if (function.roomIds.Count == 0) + { + unallocatedList.Add(function); + } + } + + //鎵�鏈夊満鏅� + List<Scene> allSceneList = FunctionList.List.scenes; + //鍏ㄥ眬鍦烘櫙鍦烘櫙 + List<Scene> globalSceneList = new List<Scene>(); + //鎵惧嚭鎵�鏈夌殑鍏ㄥ眬鍦烘櫙 + foreach (var mScene in allSceneList) + { + + //roomIds澶т簬0 浠h〃鍒嗛厤鍒版埧闂� + mScene.roomIds.Remove(null); + if (mScene.roomIds.Count == 0) + { + globalSceneList.Add(mScene); + } + } + + + try + { + //鎴块棿鍒楄〃 + foreach (var room in SpatialInfo.CurrentSpatial.RoomList) + { + AddRoomFunctionRowLayout(room); + } + //2020-12-16 鍔犺浇鏈垎閰嶅尯鍩熷姛鑳絉owLayout + AddNoAreaFunctionRowLayout(unallocatedList, globalSceneList); + } + catch + { + Utlis.WriteLine("AddRoomFunctionRowLayout error"); + } + } + + + /// <summary> + /// 娣诲姞鎴块棿鍒楄〃 + /// </summary> + /// <param name="mRoom"></param> + void AddRoomFunctionRowLayout(Room mRoom) + { + ShowBaseRoomFunOrNoAreaFunRowLayout(mRoom, null, null); + } + + /// <summary> + /// 娣诲姞鏃犲尯鍩熺殑鍔熻兘 + /// </summary> + /// <param name="unallocatedList">鏈垎閰嶇殑鎵�鏈夊姛鑳藉垪琛�</param> + /// <param name="globalSceneList">鍏ㄥ尯鍩熺殑鍦烘櫙</param> + void AddNoAreaFunctionRowLayout(List<Function> unallocatedList, List<Scene> globalSceneList) + { + ShowBaseRoomFunOrNoAreaFunRowLayout(null, unallocatedList, globalSceneList); + } + + /// <summary> + /// 2020-12-17 閲嶆柊璋冩暣 + /// 娣诲姞鎴块棿鍒嗕韩鎴栬�呮棤鍖哄煙鍒嗛厤 涓暟缁熻鐘舵�佺殑RowLayout + /// </summary> + /// <param name="room">濡傛灉鎴块棿涓虹┖锛屼唬琛ㄧ鐞嗘棤鍒嗛厤鍖哄煙</param> + /// <param name="unallocatedList">绠$悊鏃犲垎閰嶅尯鍩熸墠鏈夋晥</param> + /// <param name="globalSceneList">鍏ㄥ眬鍦烘櫙</param> + void ShowBaseRoomFunOrNoAreaFunRowLayout(Room mRoom, List<Function> unallocatedList, List<Scene> globalSceneList) + { + /// 鎴块棿鎵�鏈夊姛鑳藉拰鑰呭満鏅垪琛� + List<SpeakerTargetInfo> roomFunctionOrSceneList = new List<SpeakerTargetInfo>(); + + var roomView = new RowLayout() + { + Height = Application.GetRealWidth(50), + BackgroundColor = CSS_Color.MainBackgroundColor, + LineColor = CSS_Color.MainBackgroundColor, + }; + bodyScrolView.AddChidren(roomView); + + var btnRoomName = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(10), + Width = Application.GetRealWidth(330), + Height = Application.GetRealWidth(30), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + //Text = room.roomName, + }; + roomView.AddChidren(btnRoomName); + + var btnRight = new Button() + { + X = Application.GetRealWidth(351), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + UnSelectedImagePath = "Public/Right.png", + }; + roomView.AddChidren(btnRight); + + //濡傛灉鎴块棿涓虹┖锛屼唬琛ㄧ鐞嗘棤鍒嗛厤鍖哄煙 + if (mRoom != null) + { + //鏄剧ず鎴块棿鍚� + btnRoomName.Text = mRoom.roomName; + var mRoomFunctionList = mRoom.GetRoomFunctions(false); + var mRoomSceneList = mRoom.GetRoomScenes(true); + //閬嶅巻鎵�鏈夊姛鑳藉垪琛� + if (mRoomFunctionList != null) + { + foreach (var fun in mRoomFunctionList) + { + roomFunctionOrSceneList.Add(new SpeakerTargetInfo() + { + targetId = fun.deviceId, + targetName = fun.name, + isDevice = true + }); + } + } + + //閬嶅巻鎵�鏈夊満鏅垪琛� + if (mRoomSceneList != null) + { + foreach (var roomScene in mRoomSceneList) + { + roomFunctionOrSceneList.Add(new SpeakerTargetInfo() + { + targetId = roomScene.userSceneId, + targetName = roomScene.name, + isDevice = false + }); + } + } + + //roomId = mRoom.roomId; + //娣诲姞鍒嗗壊绾� + var lineView = new LineView(roomView.Height - Application.GetRealHeight(1)); + roomView.AddChidren(lineView); + } + else + { + //鏄剧ず鏃犲尯鍩熷姛鑳� + btnRoomName.TextID = StringId.NoAreaFunction; + + //閬嶅巻鎵�鏈夊姛鑳藉垪琛� + if (unallocatedList != null) + { + foreach (var fun in unallocatedList) + { + roomFunctionOrSceneList.Add(new SpeakerTargetInfo() + { + targetId = fun.deviceId, + targetName = fun.name, + isDevice = true + }); + } + } + + //閬嶅巻鎵�鏈夊満鏅垪琛� + if (globalSceneList != null) + { + foreach (var roomScene in globalSceneList) + { + roomFunctionOrSceneList.Add(new SpeakerTargetInfo() + { + targetId = roomScene.userSceneId, + targetName = roomScene.name, + isDevice = false + }); + } + } + } + + + //鐐瑰嚮璋冩暣浜嬩欢 + EventHandler<MouseEventArgs> eHandler = (sender, e) => + { + var page = new SmartSpeakerSelectDevicesPage(speakerInfo, roomFunctionOrSceneList); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + roomView.MouseUpEventHandler = eHandler; + btnRoomName.MouseUpEventHandler = eHandler; + btnRight.MouseUpEventHandler = eHandler; + + } + + } + + + +} -- Gitblit v1.8.0