wxr
2023-04-21 666b28d77fc3c1b1dae61c9dfd878c8e683cef8c
HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
@@ -90,7 +90,7 @@
            var contentView = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(550),
                Height = Application.GetRealHeight(667-64),
            };
            bodyView.AddChidren(contentView);
@@ -105,7 +105,7 @@
            Button btnGroupNameTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(78),
                Width = Application.GetRealWidth(178),
                TextID = StringId.GroupNmae,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.SubheadingFontSize,
@@ -253,13 +253,13 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.SelectedAll,
            };
            if (groupControlLightList.Count > 0)
            if (groupControlLightList.Count == lightList.Count)
            {
                btnChooseAll.TextID = StringId.Cancel;
            }
            roomFloorChangeView.AddChidren(btnChooseAll);
            btnChooseAll.MouseUpEventHandler = (sender, e) => {
                if (groupControlLightList.Count > 0)
                if (groupControlLightList.Count == lightList.Count)
                {
                    groupControlLightList.Clear();
                    btnChooseAll.TextID = StringId.SelectAll;
@@ -267,11 +267,33 @@
                }
                else
                {
                    groupControlLightList.Clear();
                    groupControlLightList.AddRange(lightList);
                    btnChooseAll.TextID = StringId.Cancel;
                    btnConfrim.IsSelected = true;
                }
                LoadLightRow(lightList);
                for (int i = 0; i < functionListView.ChildrenCount; i++)
                {
                    var view = functionListView.GetChildren(i);
                    if (view.GetType() == typeof(LightRow))
                    {
                        if (view.Tag != null && view.Tag.ToString() == "row")
                        {
                            for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++)
                            {
                                var btn = (view as FrameLayout).GetChildren(j);
                                if (btn.GetType() == typeof(Button))
                                {
                                    if (btn.Tag != null && btn.Tag.ToString() == "ChooseIcon")
                                    {
                                        (btn as Button).IsSelected = groupControlLightList.Count == lightList.Count;
                                    }
                                }
                            }
                        }
                    }
                }
            };
            #endregion
@@ -358,6 +380,15 @@
                            {
                                if (pack.Code == StateCode.SUCCESS)
                                {
                                    try
                                    {
                                        var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
                                        FunctionList.List.groupControls.AddRange(addTemp);
                                    }
                                    catch (Exception ex)
                                    {
                                        MainPage.Log($"添加群控成功,转译返回数据失败:{ex.Message}");
                                    }
                                    backActon?.Invoke();
                                    this.RemoveFromParent();
                                }
@@ -383,11 +414,32 @@
                                this.RemoveFromParent();
                                return;
                            }
                            groupControl.sids.Clear();
                            foreach (var light in groupControlLightList)
                            {
                                try
                                {
                                    var gc = new GroupControlFunction();
                                    gc.sid = light.sid;
                                    gc.spk = light.spk;
                                    groupControl.sids.Add(gc);
                                }
                                catch (Exception ex)
                                {
                                    MainPage.Log($"新增群控转换数据异常:{ex.Message}");
                                }
                            }
                            var pack = Common.ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl });
                            if (pack != null)
                            {
                                if (pack.Code == StateCode.SUCCESS)
                                {
                                    var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId);
                                    if(temp!= null)
                                    {
                                        temp = groupControl;
                                    }
                                    backActon?.Invoke();
                                    this.RemoveFromParent();
                                }
@@ -459,6 +511,10 @@
                                    groupControl = groupControlTemps[0];
                                    Application.RunOnMainThread(() =>
                                    {
                                        if (groupControl.sids.Count == lightList.Count)
                                        {
                                            btnChooseAll.TextID = StringId.Cancel;
                                        }
                                        LoadLightRow(lightList);
                                    });
                                }
@@ -509,15 +565,16 @@
                            showCount = 0;
                            functionListView.RemoveAll();
                        }
                        int i = 0;
                        foreach (var function in functions)
                        for(var i =0;i<100;i++)
                        //foreach (var function in functions)
                        {
                            i++;
                            if (i > 100)
                            showCount++;
                            if (showCount >= functions.Count)
                            {
                                break;
                            }
                            showCount++;
                            var function = functions[showCount];
                            var functionDiv = new LightRow(function)
                            {
                                Gravity = Gravity.CenterHorizontal,
@@ -525,7 +582,7 @@
                                BorderColor = 0x00FFFFFF,
                                BorderWidth = 1,
                                BackgroundColor = CSS_Color.MainBackgroundColor,
                                Tag = function.spk + function.sid
                                Tag = "row"
                            };
                            functionDiv.AddChidren(new Button()
                            {
@@ -538,13 +595,27 @@
                            Action setAction = () =>
                            {
                                if (groupControlLightList.Count > 0)
                                if (groupControlLightList.Count > 1)
                                {
                                    btnConfrim.IsSelected = true;
                                }
                                else
                                {
                                    btnConfrim.IsSelected = false;
                                }
                                if (groupControlLightList.Count == functions.Count)
                                {
                                    if (!btnChooseAll.IsSelected)
                                    {
                                        btnChooseAll.IsSelected = true;
                                    }
                                }
                                else
                                {
                                    if (btnChooseAll.IsSelected)
                                    {
                                        btnChooseAll.IsSelected = false;
                                    }
                                }
                            };
                            if (groupControl.sids.Find((obj) => obj.sid == function.sid) != null)
@@ -564,12 +635,8 @@
                                TextAlignment = TextAlignment.Center,
                                TextSize = CSS_FontSize.SubheadingFontSize,
                                TextColor = CSS_Color.FirstLevelTitleColor,
                                Text = "加载更多",
                                TextID = StringId.LoadMore,
                            };
                            if (Language.CurrentLanguage != "Chinese")
                            {
                                btnAppend.Text = "Load more";
                            }
                            functionListView.AddChidren(btnAppend);
                            btnAppend.MouseUpEventHandler = (sender, e) =>
                            {