wxr
2024-06-17 4c889418cbdc722c2e7fda91abe71bf76b6ac335
HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
@@ -72,17 +72,17 @@
            };
            faceUnlockView.AddChidren(btnFaceUnlockTipText);
            //var btnFaceUnlockSwitchIcon = new Button()
            //{
            //    X = Application.GetRealWidth(322),
            //    Y = Application.GetRealHeight(8),
            //    Width = Application.GetMinRealAverage(36),
            //    Height = Application.GetMinRealAverage(36),
            //    UnSelectedImagePath = "Public/Switch_2.png",
            //    SelectedImagePath = "Public/SwitchOn_2.png",
            //    IsSelected = faceUnlockSwitch,
            //};
            //faceUnlockView.AddChidren(btnFaceUnlockSwitchIcon);
            var btnFaceUnlockSwitchIcon = new Button()
            {
                X = Application.GetRealWidth(322),
                Y = Application.GetRealHeight(8),
                Width = Application.GetMinRealAverage(36),
                Height = Application.GetMinRealAverage(36),
                UnSelectedImagePath = "Public/Switch_2.png",
                SelectedImagePath = "Public/SwitchOn_2.png",
                IsSelected = faceUnlockSwitch,
            };
            faceUnlockView.AddChidren(btnFaceUnlockSwitchIcon);
@@ -105,119 +105,120 @@
            contentView.AddChidren(view);
            //btnFaceUnlockSwitchIcon.MouseUpEventHandler = (sender, e) =>
            //{
            //    waitPage.Start("");
            //    bool changeState = false;
            //    if (!btnFaceUnlockSwitchIcon.IsSelected)
            //    {
            //        btnFaceUnlockSwitchIcon.IsSelected = true;
            //        changeState = true;
            //    }
            //    new System.Threading.Thread(() =>
            //    {
            //        try
            //        {
            //            var pack = ApiUtlis.Ins.HttpRequest.SetFaceUnlockCfg(device.deviceId, changeState, faceUnlockSetup.mode);
            //            if (pack != null && pack.Code == StateCode.SUCCESS)
            //            {
            //                Application.RunOnMainThread(() =>
            //                {
            //                    //更新界面
            //                    faceUnlockSetup.enabled = btnFaceUnlockSwitchIcon.IsSelected = changeState;
            //                    loadSubView(view, faceUnlockSetup);
            //                });
            //            }
            //            else
            //            {
            //                //失败提示
            //                Application.RunOnMainThread(() =>
            //                {
            //                    if (!string.IsNullOrEmpty(pack.message))
            //                    {
            //                        if (string.IsNullOrEmpty(pack.message))
            //                        {
            //                            pack.message = Language.StringByID(StringId.OperationFailed);
            //                        }
            //                        var tip = new Tip()
            //                        {
            //                            MaxWidth = Application.GetRealWidth(300),
            //                            Text = $"{pack.message}({pack.Code})",
            //                            CloseTime = 3,
            //                            Direction = AMPopTipDirection.None
            //                        };
            //                        tip.Show(MainPage.BaseView);
            //                    }
            //                });
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            MainPage.Log($"btnFaceUnlockSwitchIcon error : {ex.Message}");
            //        }
            //        finally
            //        {
            //            Application.RunOnMainThread(() =>
            //            {
            //                waitPage.Hide();
            //            });
            //        }
            //    })
            //    { IsBackground = true }.Start();
            //};
            btnFaceUnlockSwitchIcon.MouseUpEventHandler = (sender, e) =>
            {
                waitPage.Start("");
                bool changeState = false;
                if (!btnFaceUnlockSwitchIcon.IsSelected)
                {
                    btnFaceUnlockSwitchIcon.IsSelected = true;
                    changeState = true;
                }
                new System.Threading.Thread(() =>
                {
                    try
                    {
                        var pack = ApiUtlis.Ins.HttpRequest.SetFaceUnlockCfg(device.deviceId, changeState, faceUnlockSetup.mode);
                        if (pack != null && pack.Code == StateCode.SUCCESS)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                //更新界面
                                faceUnlockSetup.enabled = btnFaceUnlockSwitchIcon.IsSelected = changeState;
                                loadSubView(view, faceUnlockSetup);
                            });
                        }
                        else
                        {
                            //失败提示
                            Application.RunOnMainThread(() =>
                            {
                                if (!string.IsNullOrEmpty(pack.message))
                                {
                                    if (string.IsNullOrEmpty(pack.message))
                                    {
                                        pack.message = Language.StringByID(StringId.OperationFailed);
                                    }
                                    var tip = new Tip()
                                    {
                                        MaxWidth = Application.GetRealWidth(300),
                                        Text = $"{pack.message}({pack.Code})",
                                        CloseTime = 3,
                                        Direction = AMPopTipDirection.None
                                    };
                                    tip.Show(MainPage.BaseView);
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log($"btnFaceUnlockSwitchIcon error : {ex.Message}");
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            waitPage.Hide();
                        });
                    }
                })
                { IsBackground = true }.Start();
            };
            //new System.Threading.Thread(() => {
            //    try
            //    {
            //        var pack = ApiUtlis.Ins.HttpRequest.GetFaceUnlockCfg(device.deviceId);
            //        if (pack != null && pack.Code == StateCode.SUCCESS)
            //        {
            //            Application.RunOnMainThread(() =>
            //            {
            //                //更新界面
            //                faceUnlockSetup = Newtonsoft.Json.JsonConvert.DeserializeObject<FaceUnlockSetupObj>(pack.Data.ToString());
            //                btnFaceUnlockSwitchIcon.IsSelected = faceUnlockSetup.enabled;
            //                loadSubView(view, faceUnlockSetup);
            //            });
            //        }
            //        else
            //        {
            //            //失败提示
            //            Application.RunOnMainThread(() =>
            //            {
            //                if (!string.IsNullOrEmpty(pack.message))
            //                {
            //                    if (string.IsNullOrEmpty(pack.message))
            //                    {
            //                        pack.message = Language.StringByID(StringId.OperationFailed);
            //                    }
            //                    var tip = new Tip()
            //                    {
            //                        MaxWidth = Application.GetRealWidth(300),
            //                        Text = $"{pack.message}({pack.Code})",
            //                        CloseTime = 3,
            //                        Direction = AMPopTipDirection.None
            //                    };
            //                    tip.Show(MainPage.BaseView);
            //                }
            //            });
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        MainPage.Log($"UnlockSettingPage error : {ex.Message}");
            //    }
            //    finally
            //    {
            //        Application.RunOnMainThread(() =>
            //        {
            //            waitPage.Hide();
            //        });
            //    }
            new System.Threading.Thread(() =>
            {
                try
                {
                    var pack = ApiUtlis.Ins.HttpRequest.GetFaceUnlockCfg(device.deviceId);
                    if (pack != null && pack.Code == StateCode.SUCCESS)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            //更新界面
                            faceUnlockSetup = Newtonsoft.Json.JsonConvert.DeserializeObject<FaceUnlockSetupObj>(pack.Data.ToString());
                            btnFaceUnlockSwitchIcon.IsSelected = faceUnlockSetup.enabled;
                            loadSubView(view, faceUnlockSetup);
                        });
                    }
                    else
                    {
                        //失败提示
                        Application.RunOnMainThread(() =>
                        {
                            if (!string.IsNullOrEmpty(pack.message))
                            {
                                if (string.IsNullOrEmpty(pack.message))
                                {
                                    pack.message = Language.StringByID(StringId.OperationFailed);
                                }
                                var tip = new Tip()
                                {
                                    MaxWidth = Application.GetRealWidth(300),
                                    Text = $"{pack.message}({pack.Code})",
                                    CloseTime = 3,
                                    Direction = AMPopTipDirection.None
                                };
                                tip.Show(MainPage.BaseView);
                            }
                        });
                    }
                }
                catch (Exception ex)
                {
                    MainPage.Log($"UnlockSettingPage error : {ex.Message}");
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                    });
                }
            //})
            //{ IsBackground = true }.Start();
            })
            { IsBackground = true }.Start();
        }