| | |
| | | using 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() |
| | | public UnlockSettingFacePage(Function function) |
| | | { |
| | | bodyView = this; |
| | | device = function; |
| | | } |
| | | |
| | | public void LoadPage() |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.FaceUnlockSetting)).LoadTopView(); |
| | | var faceUnlockSetup = new FaceUnlockSetupObj(); |
| | | |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.FaceUnlockSetting)).LoadTopView(); |
| | | |
| | | var contentView = new VerticalScrolViewLayout() |
| | | { |
| | |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | IsMoreLines = true, |
| | | TextID = StringId.FaceUnlockTip |
| | | TextID = StringId.FaceUnlockOpenTip |
| | | }; |
| | | faceUnlockView.AddChidren(btnFaceUnlockTipText); |
| | | |
| | |
| | | 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() |
| | |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextID = StringId.ManualTriggering, |
| | | }; |
| | | triggerModeView.AddChidren(btnTriggerModeStateText); |
| | | |
| | |
| | | |
| | | btnTriggerModeText.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | var page = new VideoDoorlockFaceUnlockTriggerSettingPage(device, faceUnlockSetup); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.LoadPage(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | }; |
| | | #endregion |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | 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; |
| | | |
| | | btnTriggerModeStateText.TextID = faceUnlockSetup.mode == 0 ? StringId.AutomaticTriggering : StringId.ManualTriggering; |
| | | }); |
| | | } |
| | | 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(); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 人脸开锁配置 |
| | | /// </summary> |
| | | public class FaceUnlockSetupObj |
| | | { |
| | | /// <summary> |
| | | /// 开关 |
| | | /// </summary> |
| | | public bool enabled; |
| | | /// <summary> |
| | | /// 解锁方式 0-自动 1-手动 |
| | | /// </summary> |
| | | public int mode; |
| | | /// <summary> |
| | | /// 灵敏度 0-高 1-低 |
| | | /// </summary> |
| | | public int sensitivity; |
| | | |
| | | } |
| | | } |