Davin
2023-07-26 489d3bd60ad7dc2fecb398b09cf4c52df16f0fc2
HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/CombinedDimmingListPage.cs
@@ -21,12 +21,14 @@
        public void LoadPage()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView_AddIcon("CombinedDimming",
                (s,c)=>{
            new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl)).LoadTopView_AddIcon("CombinedDimming",
                (s, c) =>
                {
                    try
                    {
                        var page = new AddGroupControlPage(null,
                            (newGC)=> {
                            (newGC) =>
                            {
                                ReadGroupControlList();
                            },()=> { });
                        MainPage.BasePageView.AddChidren(page);
@@ -60,7 +62,8 @@
        private void ReadGroupControlList()
        {
            new System.Threading.Thread(() => {
            new System.Threading.Thread(() =>
            {
                var pack = ApiUtlis.Ins.HttpRequest.GetGroupControlList();
                if (pack != null)
                {
@@ -68,10 +71,12 @@
                    {
                        try
                        {
                            var groupControlList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
                            FunctionList.List.groupControls.Clear();
                            FunctionList.List.groupControls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
                            Application.RunOnMainThread(() =>
                            {
                                LoadGroupControlView(groupControlList);
                                LoadGroupControlView();
                            });
                        }
                        catch (Exception ex)
@@ -90,39 +95,11 @@
        }
        private void LoadGroupControlView(List<GroupControl> list)
        {
#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)
            {
            }
            else
        private void LoadGroupControlView()
            {
                contentView.RemoveAll();
                foreach (var groupControl in list)
            foreach (var groupControl in FunctionList.List.groupControls)
                {
                    var functionRow = new RowLayout()
                    {
@@ -180,25 +157,35 @@
                            BackgroundColor = CSS_Color.DividingLineColor,
                        });
                    EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
                {
                        var page = new AddGroupControlPage(groupControl,
                           (newGC) => {
                       (newGC) =>
                       {
                               try
                               {
                                   if (newGC != null)
                                   {
                                       Application.RunOnMainThread(() =>
                                       {
                                           groupControl.roomIds = newGC.uids;
                                           //groupControl.roomIds = newGC.roomIds;
                                           //groupControl.uids = newGC.uids;
                                           var localTemp = FunctionList.List.groupControls.Find((obj) => obj.deviceId == newGC.deviceId);
                                       localTemp.roomIds = newGC.roomIds;
                                       localTemp.uids = newGC.uids;
                                       localTemp.sids = newGC.sids;
                                           btnFunctionLocationInfo.Text = newGC.GetUidListName();
                                       });
                                   }
                               }catch(Exception ex)
                           }
                           catch (Exception ex)
                               {
                                   MainPage.Log($"刷新群控房间信息异常:{ex.Message}");
                               }
                           },()=> {
                               LoadGroupControlView(FunctionList.List.groupControls);
                       }, () =>
                       {
                           LoadGroupControlView();
                           });
                        MainPage.BasePageView.AddChidren(page);
                        page.LoadPage();
@@ -217,7 +204,8 @@
                        TextAlignment = TextAlignment.Center,
                    };
                    functionRow.AddRightView(btnDelGroupControl);
                    btnDelGroupControl.MouseUpEventHandler = (sender1, e1) => {
                btnDelGroupControl.MouseUpEventHandler = (sender1, e1) =>
                {
                        var waitPage = new Loading();
                        this.AddChidren(waitPage);
                        waitPage.Start("");
@@ -234,26 +222,30 @@
                                        {
                                            if (pack.Code == StateCode.SUCCESS)
                                            {
                                                list.Remove(groupControl);
                                                LoadGroupControlView(list);
                                            var delTemp = FunctionList.List.groupControls.Find((obj) => groupControl.sid == obj.sid);
                                            FunctionList.List.groupControls.Remove(delTemp);
                                            LoadGroupControlView();
                                            }
                                            else
                                            {
                                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                                            }
                                        }catch(Exception ex)
                                    }
                                    catch (Exception ex)
                                        {
                                            MainPage.Log($"刷新组控数据异常:{ex.Message}");
                                        }
                                    });
                                }
                            }catch(Exception ex)
                        }
                        catch (Exception ex)
                            {
                                MainPage.Log($"删除组控异常:{ex.Message}");
                            }
                            finally
                            {
                                Application.RunOnMainThread(() => {
                            Application.RunOnMainThread(() =>
                            {
                                    if (waitPage != null)
                                    {
                                        waitPage.Hide();
@@ -268,7 +260,6 @@
                }
            }
        }