using System; using System.Collections.Generic; namespace Shared.SimpleControl.Phone { public class GenerateTempPasswordResult : Dialog { public static GenerateTempPasswordResult curView; FrameLayout middleLayout; DoorLock doorLock; public GenerateTempPasswordResult (DoorLock door_lock) { this.doorLock = door_lock; curView = this; BackgroundColor = 0xFF3b3d3c; showUserTempPassword (); readStatus (door_lock); } static void readStatus (DoorLock door_lock) { System.Threading.Tasks.Task.Run (() => { var randomNum = Control.ControlBytesSendHasReturn (Command.CreatConnection, door_lock.SubnetID, door_lock.DeviceID, new byte [] { 1 }); if (randomNum != null) { byte [] randomBytes = new byte [8]; System.Array.Copy (randomNum, 1, randomBytes, 0, 8); byte [] inpuptBytes = { 0x1F, 0x52, door_lock.PhysicsLoopID }; var encryptionBytes = Security.Encryption (randomBytes, inpuptBytes); var resultBytes = Control.ControlBytesSendHasReturn (Command.SendEncryptionAfterConnected, door_lock.SubnetID, door_lock.DeviceID, encryptionBytes); if (resultBytes == null) { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), "设备不在线", Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } else { var ddBytes = Security.Encryption (randomBytes, resultBytes); door_lock.Enable = ddBytes [3].ToString (); door_lock.Times = ddBytes [4].ToString (); door_lock.VailidTimeH = ddBytes [5].ToString (); door_lock.VailidTimeL = ddBytes [6].ToString (); } } }); } void showUserTempPassword () { #region 标题 var topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), BackgroundColor =0xff1e1f20, }; AddChidren (topView); var title = new Button () { TextAlignment = TextAlignment.Center, TextID = R.MyInternationalizationString.UserTempPassword , TextSize = 19, }; topView.AddChidren (title); var logo = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), UnSelectedImagePath = MainPage.LogoString, Gravity = Gravity.CenterVertical, }; topView.AddChidren (logo); var back = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical, }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { Close (); curView = null; }; var btnl = new Button () { Height = 1, BackgroundColor = 0xFF000000, Y = topView.Height - 1 }; topView.AddChidren (btnl); #endregion #region middleVerticalScrolViewLayout middleLayout = new FrameLayout () { Height = Application.GetRealHeight (Application.DesignHeight - 126), Y = topView.Bottom, }; AddChidren (middleLayout); //foreach (var fingerBytes in doorLock.tempPasswordList) { // string remarkString = CommonPage.MyEncodingGB2312.GetString (fingerBytes, 3, 20).Trim ('\0'); var btnTempPassword = new Button () { X = Application.GetRealWidth (25), Gravity = Gravity.CenterVertical, Y = Application.GetRealHeight (780), Height = Application.GetRealHeight (100), Text = "aaaaaaaaaaa", }; middleLayout.AddChidren (btnTempPassword); var btnEdit = new Button () { X = Application.GetRealWidth (85), Y = Application.GetRealHeight (780), Width = Application.GetRealWidth (80), Height = Application.GetRealHeight (80), UnSelectedImagePath = "Item/Editor.png", SelectedImagePath = "Item/EditorSelected.png", }; middleLayout.AddChidren (btnEdit); var btnRemind = new Button () { Width = Application.GetRealWidth (542), Height = LayoutParams.MatchParent, TextAlignment = TextAlignment.CenterLeft, X = btnEdit.Right + Application.GetRealWidth (15), Y = Application.GetRealHeight (780), Text = "您有2次机会", }; middleLayout.AddChidren (btnRemind); // } #endregion } } }