using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class CombinedDimmingListPage : FrameLayout { FrameLayout bodyView; VerticalScrolViewLayout contentView; public CombinedDimmingListPage() { bodyView = this; } public void LoadPage() { new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView_AddIcon("CombinedDimming", (s,c)=>{ try { var page = new AddGroupControlPage(null, ()=> { }); MainPage.BasePageView.AddChidren(page); page.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; } catch { } }); contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(550), BackgroundColor = CSS_Color.MainBackgroundColor, }; bodyView.AddChidren(contentView); new System.Threading.Thread(() => { var http = new HttpServerRequest(); var pack = http.GetGroupControlList(); if(pack != null) { if(pack.Code == StateCode.SUCCESS ) { try { var groupControlList = Newtonsoft.Json.JsonConvert.DeserializeObject>(pack.Data.ToString()); Application.RunOnMainThread(() => { LoadGroupControlView(groupControlList); }); } catch (Exception ex) { MainPage.Log($"读取组控列表失败:{ex.Message}"); } } else { IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); } } }) { IsBackground = true }.Start(); #region contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); #endregion } private void LoadGroupControlView(List list) { #if DEBUG if (list.Count == 0) { list.Add(new GroupControl() { name = "组合调光1", roomIds = new List { Room.CurrentSpatial.RoomList[0].roomId }, sid = "00000000000000001", type = "light", uids = new List() { Room.CurrentSpatial.RoomList[0].uid }, }); list.Add(new GroupControl() { name = "组合调光2", roomIds = new List { Room.CurrentSpatial.RoomList[0].roomId }, sid = "00000000000000002", type = "light", uids = new List() { Room.CurrentSpatial.RoomList[0].uid }, }); } #endif if (list.Count == 0) { } else { contentView.RemoveAll(); foreach (var groupControl in list) { var functionRow = new FrameLayout() { Height = Application.GetRealHeight(65), BackgroundColor = CSS_Color.MainBackgroundColor, }; 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() { X = Application.GetRealWidth(16), Y = Application.GetRealHeight(10), Width = Application.GetRealWidth(308), Height = Application.GetRealHeight(24), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = groupControl.name, }; functionRow.AddChidren(btnFunctionName); var btnFunctionLocationInfo = new Button() { X = Application.GetRealWidth(16), Y = btnFunctionName.Bottom, Width = Application.GetRealWidth(308), Height = Application.GetRealHeight(21), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = CSS_Color.PromptingColor1, Text = groupControl.GetRoomListName(), }; functionRow.AddChidren(btnFunctionLocationInfo); functionRow.AddChidren( new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor, }); EventHandler eventHandler = (sender, e) => { var page = new AddGroupControlPage(groupControl, () => { }); 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; } } } } }