using System; using HDL_ON.DriverLayer; using HDL_ON.Entity; using HDL_ON.Stan; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class DoorLockUnlockPage : FrameLayout { /// /// 当前界面 /// FrameLayout bodyView; Function device; public DoorLockUnlockPage(Function function) { bodyView = this; device = function; } /// /// 加载视图 /// public void LoadView() { new TopViewDiv(bodyView, Language.StringByID(StringId.PlsEntryPassword)).LoadTopView(); bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; var btnMsg = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(100), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(100), TextAlignment = TextAlignment.TopCenter, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.DoorLockEntryPasswordTip, IsMoreLines = true, }; bodyView.AddChidren(btnMsg); #region 密码填写 var passwordView = new FrameLayout() { X = Application.GetRealWidth(28), Y = Application.GetRealHeight(200), Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(passwordView); var etPassword = new EditText() { TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, PlaceholderTextColor = CSS_Color.PromptingColor1, PlaceholderText = Language.StringByID(StringId.PlsEntryPassword), SecureTextEntry = true, TextAlignment = TextAlignment.Center, BackgroundColor = CSS_Color.BackgroundColor, IsNumberKeyboardType = true }; passwordView.AddChidren(etPassword); //var btnVisiblePassword = new Button() //{ // X = Application.GetRealWidth(273), // Gravity = Gravity.CenterVertical, // Width = Application.GetMinRealAverage(20), // Height = Application.GetMinRealAverage(20), // UnSelectedImagePath = "LoginIcon/HidePasswordIcon.png", // SelectedImagePath = "LoginIcon/ShowPasswordIcon.png", //}; //passwordView.AddChidren(btnVisiblePassword); #endregion var frameRow = new FrameLayout() { Height = Application.GetRealHeight(28), Y = Application.GetRealHeight(258),//375 // 667 }; bodyView.AddChidren(frameRow); //同意按钮背景 var agreeView = new FrameLayout() { Height = Application.GetRealHeight(28), Width = Application.GetRealWidth(28), X = Application.GetRealWidth(22), }; frameRow.AddChidren(agreeView); //同意图标按钮 var agreeBtn = new Button() { Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "Public/ChooseIcon.png", SelectedImagePath = "Public/ChooseOnIcon.png", IsSelected = false, Gravity = Gravity.Center, }; agreeView.AddChidren(agreeBtn); var agreeTextBtn = new TextButton() { X = agreeView.Right, Width = Application.GetRealWidth(28), Height = Application.GetRealHeight(28), TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextID = StringId.DoorLock5minTip }; frameRow.AddChidren(agreeTextBtn); agreeTextBtn.Width = Utlis.GetRealWidthByTextButton(agreeTextBtn); EventHandler eventHandler = (sender, e) => { agreeBtn.IsSelected = !agreeBtn.IsSelected; }; agreeBtn.MouseUpEventHandler = eventHandler; agreeView.MouseUpEventHandler = eventHandler; agreeTextBtn.MouseUpEventHandler = eventHandler; Button btnLine = new Button() { Y = Application.GetRealHeight(607), Height = Application.GetRealHeight(1), BackgroundColor = CSS.CSS_Color.DividingLineColor, }; bodyView.AddChidren(btnLine); Button btnCancel = new Button() { Y = btnLine.Bottom, Width = Application.GetRealWidth(374/2), Height = Application.GetRealHeight(60), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.Cancel, }; bodyView.AddChidren(btnCancel); btnCancel.MouseUpEventHandler = (sender, e) => { this.RemoveFromParent(); }; Button btnConfirm = new Button() { X = btnCancel.Right, Y = btnLine.Y, Width = Application.GetRealWidth(376 / 2), Height = Application.GetRealHeight(60), TextAlignment = TextAlignment.Center, //TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.MainBackgroundColor, BackgroundColor = CSS_Color.MainColor, TextID = StringId.Confirm, }; bodyView.AddChidren(btnConfirm); btnConfirm.MouseUpEventHandler = (sender, e) => { var password = etPassword.Text.Trim(); if (password.Length == 0) { //设备不在线 HdlMessageLogic.Current.ShowMassage(ShowMsgType.TipRemind, Language.StringByID(StringId.PlsEntryPassword), null, null, null, 2); return; } if (agreeBtn.IsSelected) { UserInfo.Current.doorPasswordString = password; UserInfo.Current.LastTimeOpenDoor = DateTime.Now; } Control.Ins.OneKeyUnlocking(this.device, etPassword.Text.Trim()); this.RemoveFromParent(); }; } } }