JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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
        }
 
 
    }
}