From 1b56157e8edc3f502810820d99b607e3629c7171 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 19 七月 2023 09:42:00 +0800
Subject: [PATCH] Merge branch 'Dev-Branch' into wjc

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs |  328 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 328 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
new file mode 100644
index 0000000..f1ee2e9
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/UnlockSettingFacePage.cs
@@ -0,0 +1,328 @@
+锘縰sing System;
+using HDL_ON.Common;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
+using Shared;
+namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
+{
+    /// <summary>
+    /// 钀ょ煶瑙嗛闂ㄩ攣-浜鸿劯寮�閿佽缃〉闈�
+    /// </summary>
+    public class UnlockSettingFacePage : FrameLayout
+    {
+        FrameLayout bodyView;
+        bool faceUnlockSwitch;
+
+        Function device;
+
+        public UnlockSettingFacePage(Function function)
+        {
+            bodyView = this;
+            device = function;
+        }
+
+        public void LoadPage()
+        {
+            var faceUnlockSetup = new FaceUnlockSetupObj();
+
+            new TopViewDiv(bodyView, Language.StringByID(StringId.FaceUnlockSetting)).LoadTopView();
+
+            var contentView = new VerticalScrolViewLayout()
+            {
+                Y = Application.GetRealHeight(64),
+                Height = Application.GetRealHeight(600),
+                ScrollEnabled = false,
+                BackgroundColor = CSS_Color.BackgroundColor,
+            };
+            bodyView.AddChidren(contentView);
+
+         
+            #region 浜鸿劯寮�閿�
+            var faceUnlockView = new FrameLayout()
+            {
+                Height = Application.GetRealHeight(74),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+            };
+            contentView.AddChidren(faceUnlockView);
+
+            var btnFaceUnlockText = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                Y = Application.GetRealHeight(7),
+                Height = Application.GetRealHeight(37),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.FaceUnlock,
+            };
+            faceUnlockView.AddChidren(btnFaceUnlockText);
+
+            var btnFaceUnlockTipText = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                Y = btnFaceUnlockText.Bottom,
+                Width = Application.GetRealWidth(339),
+                Height = Application.GetRealHeight(37),
+                TextAlignment = TextAlignment.TopLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                IsMoreLines = true,
+                TextID = StringId.FaceUnlockOpenTip
+            };
+            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 waitPage = new Loading();
+            bodyView.AddChidren(waitPage);
+            waitPage.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(() =>
+                            {
+                                //鏇存柊鐣岄潰
+                                btnFaceUnlockSwitchIcon.IsSelected = changeState;
+                            });
+                        }
+                        else
+                        {
+                            //澶辫触鎻愮ず
+                            Application.RunOnMainThread(() =>
+                            {
+                                if (!string.IsNullOrEmpty(pack.message))
+                                {
+                                    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();
+            };
+            #endregion
+
+            contentView.AddChidren(new Button()
+            {
+                Height = Application.GetRealHeight(8),
+                BackgroundColor = CSS_Color.BackgroundColor,
+            });
+
+            var view = new VerticalScrolViewLayout()
+            {
+                Height = Application.GetRealHeight(300),
+            };
+            contentView.AddChidren(view);
+
+            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))
+                            {
+                                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();
+
+        }
+
+        void loadSubView(VerticalScrolViewLayout view, FaceUnlockSetupObj faceUnlockSetup)
+        {
+            if (faceUnlockSetup.enabled)
+            {
+                #region 瑙﹀彂鏂瑰紡 TriggerMode
+                var triggerModeView = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(50),
+                    BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                };
+                view.AddChidren(triggerModeView);
+
+                var btnTriggerModeRight = new Button()
+                {
+                    X = Application.GetRealWidth(339),
+                    Gravity = Gravity.CenterVertical,
+                    Width = Application.GetMinRealAverage(16),
+                    Height = Application.GetMinRealAverage(16),
+                    UnSelectedImagePath = "Public/Right.png",
+                };
+                triggerModeView.AddChidren(btnTriggerModeRight);
+
+                var btnTriggerModeStateText = new Button()
+                {
+                    X = Application.GetRealWidth(100),
+                    Width = Application.GetRealWidth(223),
+                    TextAlignment = TextAlignment.CenterRight,
+                    TextSize = CSS_FontSize.TextFontSize,
+                    TextColor = CSS_Color.PromptingColor1,
+                };
+                triggerModeView.AddChidren(btnTriggerModeStateText);
+                btnTriggerModeStateText.TextID = faceUnlockSetup.mode == 0 ? StringId.AutomaticTriggering : StringId.ManualTriggering;
+
+                var btnTriggerModeText = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    TextSize = CSS_FontSize.SubheadingFontSize,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextID = StringId.TriggerMode,
+                };
+                triggerModeView.AddChidren(btnTriggerModeText);
+
+                btnTriggerModeText.MouseUpEventHandler = (sender, e) =>
+                {
+                    var page = new VideoDoorlockFaceUnlockTriggerSettingPage(device, faceUnlockSetup);
+                    MainPage.BasePageView.AddChidren(page);
+                    page.LoadPage();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+                };
+                #endregion
+
+                view.AddChidren(new Button { Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
+            }
+            #region 浜鸿劯褰曞叆甯姪 
+            var faceEntryHelpView = new FrameLayout()
+            {
+                Height = Application.GetRealHeight(50),
+                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+            };
+            view.AddChidren(faceEntryHelpView);
+
+            var btnFaceEntryHelpRight = new Button()
+            {
+                X = Application.GetRealWidth(339),
+                Gravity = Gravity.CenterVertical,
+                Width = Application.GetMinRealAverage(16),
+                Height = Application.GetMinRealAverage(16),
+                UnSelectedImagePath = "Public/Right.png",
+            };
+            faceEntryHelpView.AddChidren(btnFaceEntryHelpRight);
+
+
+            var btnFaceEntryHelpText = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextID = StringId.FaceEntryHelp,
+            };
+            faceEntryHelpView.AddChidren(btnFaceEntryHelpText);
+
+            btnFaceEntryHelpText.MouseUpEventHandler = (sender, e) =>
+            {
+                var page = new VideoDoorlockFaceUnlockHelpPage();
+                MainPage.BasePageView.AddChidren(page);
+                page.LoadPage();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            #endregion
+
+        }
+
+    }
+
+    /// <summary>
+    /// 浜鸿劯寮�閿侀厤缃�
+    /// </summary>
+    public class FaceUnlockSetupObj
+    {
+        /// <summary>
+        /// 寮�鍏�
+        /// </summary>
+        public bool enabled = false;
+        /// <summary>
+        /// 瑙i攣鏂瑰紡 0-鑷姩 1-鎵嬪姩
+        /// </summary>
+        public int mode;
+        /// <summary>
+        /// 鐏垫晱搴� 0-楂� 1-浣�
+        /// </summary>
+        public int sensitivity;
+
+    }
+}

--
Gitblit v1.8.0