From 203c3a3ffde6259413d9743f6a723b95b1e7989c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 06 七月 2023 22:43:05 +0800 Subject: [PATCH] 门锁功能 --- HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 154 insertions(+), 24 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs index 770551c..c4b2d1b 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs @@ -1,5 +1,6 @@ 锘縰sing System; using System.Collections.Generic; +using HDL_ON.Common; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; @@ -24,10 +25,10 @@ (s,c)=>{ try { - var page = new AddGroupControlPage(new System.Collections.Generic.List<Function>(),new GroupControl(), - ()=> { - - }); + var page = new AddGroupControlPage(null, + (newGC)=> { + ReadGroupControlList(); + },()=> { }); MainPage.BasePageView.AddChidren(page); page.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; @@ -38,23 +39,40 @@ contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), - Height = Application.GetRealHeight(550), + Height = Application.GetRealHeight(667 - 64), BackgroundColor = CSS_Color.MainBackgroundColor, }; bodyView.AddChidren(contentView); + ReadGroupControlList(); + + #region + contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); + + + + #endregion + + } + /// <summary> + /// 璇诲彇缁勬帶鏁版嵁 + /// </summary> + private void ReadGroupControlList() + { new System.Threading.Thread(() => { - var http = new HttpServerRequest(); - var pack = http.GetGroupControlList(); - if(pack != null) + var pack = ApiUtlis.Ins.HttpRequest.GetGroupControlList(); + if (pack != null) { - if(pack.Code == StateCode.SUCCESS ) + if (pack.Code == StateCode.SUCCESS) { try { var groupControlList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString()); - LoadGroupControlView(groupControlList); + Application.RunOnMainThread(() => + { + LoadGroupControlView(groupControlList); + }); } catch (Exception ex) { @@ -66,22 +84,37 @@ IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); } } - - }) { IsBackground = true }.Start(); - - #region - contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); - - - - #endregion + }) + { IsBackground = true }.Start(); } private void LoadGroupControlView(List<GroupControl> list) { - if(list.Count == 0) +#if DEBUG + if (list.Count == 0) + { + list.Add(new GroupControl() + { + name = "缁勫悎璋冨厜1", + roomIds = new List<string> {}, + sid = "00000000000000001", + type = "light", + }); + + list.Add(new GroupControl() + { + name = "缁勫悎璋冨厜2", + roomIds = new List<string> { },//Room.CurrentSpatial.RoomList[0].roomId + sid = "00000000000000002", + type = "light", + }); + } + +#endif + + if (list.Count == 0) { } @@ -89,14 +122,25 @@ { contentView.RemoveAll(); - foreach (var function in list) + foreach (var groupControl in list) { - var functionRow = new FrameLayout() + var functionRow = new RowLayout() { Height = Application.GetRealHeight(65), BackgroundColor = CSS_Color.MainBackgroundColor, + LineColor = 0x00000000 }; contentView.AddChidren(functionRow); + + var btnRight = new Button() + { + X = Application.GetRealWidth(339), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + UnSelectedImagePath = "Public/Right.png", + }; + functionRow.AddChidren(btnRight); var btnFunctionName = new Button() { @@ -107,7 +151,7 @@ TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.FirstLevelTitleColor, - Text = function.name, + Text = groupControl.name, }; functionRow.AddChidren(btnFunctionName); @@ -120,7 +164,7 @@ TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = CSS_Color.PromptingColor1, - Text = function.GetRoomListName(), + Text = groupControl.GetRoomListName(), }; functionRow.AddChidren(btnFunctionLocationInfo); @@ -136,6 +180,92 @@ BackgroundColor = CSS_Color.DividingLineColor, }); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + var page = new AddGroupControlPage(groupControl, + (newGC) => { + try + { + if (newGC != null) + { + Application.RunOnMainThread(() => + { + groupControl.roomIds = newGC.uids; + btnFunctionLocationInfo.Text = newGC.GetUidListName(); + }); + } + }catch(Exception ex) + { + MainPage.Log($"鍒锋柊缇ゆ帶鎴块棿淇℃伅寮傚父:{ex.Message}"); + } + },()=> { + LoadGroupControlView(FunctionList.List.groupControls); + }); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + functionRow.MouseUpEventHandler = eventHandler; + btnRight.MouseUpEventHandler = eventHandler; + btnFunctionName.MouseUpEventHandler = eventHandler; + btnFunctionLocationInfo.MouseUpEventHandler = eventHandler; + + var btnDelGroupControl = new Button() + { + TextColor = CSS_Color.MainBackgroundColor, + BackgroundColor = CSS_Color.WarningColor, + TextID = StringId.Del, + TextAlignment = TextAlignment.Center, + }; + functionRow.AddRightView(btnDelGroupControl); + btnDelGroupControl.MouseUpEventHandler = (sender1, e1) => { + var waitPage = new Loading(); + this.AddChidren(waitPage); + waitPage.Start(""); + new System.Threading.Thread(() => + { + try + { + var pack = ApiUtlis.Ins.HttpRequest.DelGroupControl(groupControl.userDeviceGroupControlId); + if (pack != null) + { + Application.RunOnMainThread(() => + { + try + { + if (pack.Code == StateCode.SUCCESS) + { + list.Remove(groupControl); + LoadGroupControlView(list); + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } + }catch(Exception ex) + { + MainPage.Log($"鍒锋柊缁勬帶鏁版嵁寮傚父:{ex.Message}"); + } + }); + } + }catch(Exception ex) + { + MainPage.Log($"鍒犻櫎缁勬帶寮傚父:{ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => { + if (waitPage != null) + { + waitPage.Hide(); + waitPage.RemoveFromParent(); + waitPage = null; + } + }); + } + }) + { IsBackground = true }.Start(); + }; + } } -- Gitblit v1.8.0