From f9181a9c8125136f597add7c30cb2ff508d54ba7 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:34:32 +0800
Subject: [PATCH] 2024年07月25日17:33:40

---
 HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs |  195 ++++++++++++++++++++++++++++++------------------
 1 files changed, 122 insertions(+), 73 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
index b5f70fd..3ae8804 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
@@ -92,11 +92,15 @@
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
             if (isAdd)
             {
-                new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl)).LoadTopView();
+                var topView = new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl));
+                topView.maginY = 10;
+                topView.LoadTopView();
             }
             else
             {
-                new TopViewDiv(bodyView, "").LoadTopView_SettingText(()=> {
+                var topView = new TopViewDiv(bodyView, "");
+                topView.maginY = 10;
+                topView.LoadTopView_SettingText(()=> {
 
                     Action action = () => {
                         var waitPage = new Loading();
@@ -158,8 +162,8 @@
             }
             var contentView = new FrameLayout()
             {
-                Y = Application.GetRealHeight(64),
-                Height = Application.GetRealHeight(667-64),
+                Y = Application.GetRealHeight(64+10),
+                Height = Application.GetRealHeight(667-64-10),
             };
             bodyView.AddChidren(contentView);
 
@@ -371,7 +375,7 @@
             functionListView = new VerticalScrolViewLayout()
             {
                 Y = Application.GetRealHeight(220),
-                Height = Application.GetRealHeight(640 - 12 - 52 - 100 -100),
+                Height = Application.GetRealHeight(640 - 12 - 52 - 100 -100-10),
             };
             bodyView.AddChidren(functionListView);
 
@@ -418,6 +422,7 @@
                         new PublicAssmebly().TipMsg(StringId.Tip, StringId.PlsEntryGroupName);
                         return;
                     }
+                    groupControl.name = name;
                     if (groupControlLightList.Count < 2)
                     {
                         new PublicAssmebly().TipMsg(StringId.Tip, StringId.PlsSelectMoreData);
@@ -425,7 +430,6 @@
                     }
                     if (isAdd)
                     {
-                        groupControl.name = name;
                         groupControl.sids.Clear();
                         foreach (var light in groupControlLightList)
                         {
@@ -441,92 +445,137 @@
                                 MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
                             }
                         }
-                        try
+                        var waitPage = new Loading();
+                        bodyView.AddChidren(waitPage);
+                        waitPage.Start("");
+                        new Thread(() =>
                         {
-                            groupControl.type = groupControlType.type;
-                            groupControl.sid = groupControl.NewGroupControlSid();
-                            var pack = Common.ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl });
-                            if (pack != null)
+                            try
                             {
-                                if (pack.Code == StateCode.SUCCESS)
+                                groupControl.type = groupControlType.type;
+                                groupControl.sid = groupControl.NewGroupControlSid();
+                                var pack = ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl });
+                                if (pack != null)
                                 {
+                                    if (pack.Code == StateCode.SUCCESS)
+                                    {
+                                        try
+                                        {
+                                            var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
+                                            if (addTemp != null && addTemp.Count > 0)
+                                                groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId;
+                                            FunctionList.List.groupControls.Add(groupControl);
+                                        }
+                                        catch (Exception ex)
+                                        {
+                                            MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}");
+                                        }
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            addActon?.Invoke(groupControl);
+                                            this.RemoveFromParent();
+                                        });
+                                    }
+                                    else
+                                    {
+                                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    }
+                                }
+
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
+                            }
+                            finally
+                            {
+                                Application.RunOnMainThread(() => {
                                     try
                                     {
-                                        var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
-                                        if (addTemp != null && addTemp.Count > 0)
-                                            groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId;
-                                        FunctionList.List.groupControls.Add(groupControl);
+                                        waitPage.Hide();
+                                        waitPage = null;
                                     }
-                                    catch (Exception ex)
-                                    {
-                                        MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}");
-                                    }
-                                    addActon?.Invoke(groupControl);
-                                    this.RemoveFromParent();
-                                }
-                                else
-                                {
-                                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
-                                }
+                                    catch { }
+                                });
                             }
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
-                        }
+                        })
+                        { IsBackground = true }.Start();
                     }
                     else
                     {
-                        try
+                        var waitPage = new Loading();
+                        bodyView.AddChidren(waitPage);
+                        waitPage.Start("");
+                        new Thread(() =>
                         {
-                            //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
-                            //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList);
-                            //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids);
-                            ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑�
-                            //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2)
-                            //{
-                            //    this.RemoveFromParent();
-                            //    return;
-                            //}
-                            groupControl.sids.Clear();
-                            foreach (var light in groupControlLightList)
+                            try
                             {
-                                try
+                                //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
+                                //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList);
+                                //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids);
+                                ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑�
+                                //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2)
+                                //{
+                                //    this.RemoveFromParent();
+                                //    return;
+                                //}
+                                groupControl.sids.Clear();
+                                foreach (var light in groupControlLightList)
                                 {
-                                    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)
+                                    try
                                     {
-                                        temp = groupControl;
+                                        var gc = new GroupControlFunction();
+                                        gc.sid = light.sid;
+                                        gc.spk = light.spk;
+                                        groupControl.sids.Add(gc);
                                     }
-                                    addActon?.Invoke(temp);
-                                    this.RemoveFromParent();
+                                    catch (Exception ex)
+                                    {
+                                        MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
+                                    }
                                 }
-                                else
+
+                                var pack = ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl });
+                                if (pack != null)
                                 {
-                                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    if (pack.Code == StateCode.SUCCESS)
+                                    {
+                                        var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId);
+                                        if (temp != null)
+                                        {
+                                            temp = groupControl;
+                                        }
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            addActon?.Invoke(temp);
+                                            this.RemoveFromParent();
+                                        });
+                                    }
+                                    else
+                                    {
+                                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    }
                                 }
                             }
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}");
-                        }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}");
+                            }
+                            finally
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    try
+                                    {
+                                        waitPage.Hide();
+                                        waitPage = null;
+                                    }
+                                    catch { }
+                                });
+
+                            }
+                        })
+                        { IsBackground = true }.Start();
 
                     }
                 }

--
Gitblit v1.8.0