1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System;
namespace Shared.SimpleControl.Phone
{
    public class DoorLockSystemSetting : FrameLayout
    {
 
        DoorLock doorLock;
        public DoorLockSystemSetting (DoorLock doorLock)
        {
            this.doorLock = doorLock;
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        /// <summary>
        /// 读门锁时钟
        /// </summary>
        /// <param name="door_lock">Door lock.</param>
        void readStatus (DoorLock door_lock)
        {
            System.Threading.Tasks.Task.Run (() => {
                byte [] resultBytes = Control.ControlBytesSendHasReturn (Command.ReadDoorLockClock, door_lock.SubnetID, door_lock.DeviceID, new byte [] { door_lock.LoopID });
                IO.FileUtils.SaveEquipmentMessage (door_lock, door_lock.LoopID.ToString ());
             });
        }
 
        public void ShowUserRemoteUnLock ()
        {
            #region 标题
            var topView = new FrameLayout () {
                Y = Application.GetRealHeight (36),
                Height = Application.GetRealHeight (90),
                BackgroundColor = SkinStyle.Current.MainColor,
            };
            AddChidren (topView);
 
            var title = new Button () {
                TextAlignment = TextAlignment.Center,
                TextID = R.MyInternationalizationString.SystemSetting,
                TextColor = SkinStyle.Current.TextColor1,
                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) => {
                this.RemoveFromParent ();
            };
            #endregion
 
            #region  bodyScrolView
            VerticalScrolViewLayout bodyFrameLayout = new VerticalScrolViewLayout () {
                Height = Application.GetRealHeight (1136 - 126),
                BackgroundColor = SkinStyle.Current.ViewColor,
                Y = topView.Bottom,
            };
            AddChidren (bodyFrameLayout);
 
            for (int i = 0; i < 2; i++) {
                //if (i == 2 || i == 4)
                //continue;
                FrameLayout RowView = new FrameLayout () {
                    Height = Application.GetRealHeight (110),
                    BackgroundColor = SkinStyle.Current.ViewColor,
                };
                bodyFrameLayout.AddChidren (RowView);
 
                Button btnIcon = new Button () {
                    Width = Application.GetRealHeight (13),
                    Height = Application.GetRealHeight (13),
                    X = Application.GetRealWidth (40),
                    UnSelectedImagePath = "Item/Point.png",
                    SelectedImagePath = "Item/PointSelected.png",
                    Gravity = Gravity.CenterVertical,
                };
                RowView.AddChidren (btnIcon);
 
                Button UserManagement = new Button () {
                    X = btnIcon.Right + Application.GetRealWidth (20),
                    Width = Application.GetRealWidth (300),
                    Height = Application.GetRealHeight (110),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = SkinStyle.Current.TextColor1,
                };
                RowView.AddChidren (UserManagement);
                if (i == 0) {
                    UserManagement.TextID = R.MyInternationalizationString.ImprovementTime;
                } else if (i == 1) {
                    UserManagement.TextID = R.MyInternationalizationString.RemoteUnLockPasswordSetOrModify;
                }   
 
                var btnRight = new Button () {
                    Width = Application.GetRealWidth (28),
                    Height = Application.GetRealHeight (40),
                    X = UserManagement.Right + Application.GetRealWidth (200),
                    UnSelectedImagePath = "Item/Right.png",
                    SelectedImagePath = "Item/RightSelected.png",
                    Gravity = Gravity.CenterVertical,
                };
                RowView.AddChidren (btnRight);
 
                var line2 = new Button () {
                    Y = RowView.Height - 1,
                    Height = 1,
                    BackgroundColor = SkinStyle.Current.TitileView,
                };
                RowView.AddChidren (line2);
 
                int currentIndex = i;
                EventHandler<MouseEventArgs> eHandler = (sender, e) => {
                    if (currentIndex == 0) {
                             var currentTime = DateTime.Now;
                            System.Threading.Tasks.Task.Run (() => {
                                try {
                                    Application.RunOnMainThread (() => {
                                        MainPage.Loading.Start ("Please wait...");
                                    });
                                    var sendBytes = new byte [7];
                                    sendBytes [0] = (byte)(currentTime.Year - 2000);
                                    sendBytes [1] = (byte)(currentTime.Month);
                                    sendBytes [2] = (byte)(currentTime.Day);
                                    sendBytes [3] = (byte)(currentTime.Hour);
                                    sendBytes [4] = (byte)(currentTime.Minute);
                                    sendBytes [5] = (byte)(currentTime.Second);
                                    sendBytes [6] = (byte)(currentTime.DayOfWeek);
                                    // string manualSetTime = systemDateManualImprovement.Month + "/" + systemDateManualImprovement.Day + "/" + systemDateManualImprovement.Year + "  " + systemTimeManualImprovement.Hour + ":" + systemTimeManualImprovement.Minute;
                                    var setPasswordInfoBytes = Control.ControlBytesSendHasReturn (Command.SetDoorLockTime, doorLock.SubnetID, doorLock.DeviceID, sendBytes);
                                    if (setPasswordInfoBytes != null && setPasswordInfoBytes [0] == 0xF8) {
                                        Application.RunOnMainThread (() => {
                                            // CurrentTimeText.Text = manualSetTime;
                                            new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SetSuccessfully), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show ((View)sender);
                                        });
                                        return;
                                    } else {
                                        Application.RunOnMainThread (() => {
                                            new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                        });
                                        return;
                                    }
                                } catch (Exception mess) {
                                    string message = mess.Message;
 
                                } finally {
                                    Application.RunOnMainThread (() => {
                                        MainPage.Loading.Hide ();
                                    });
                                }
                            });
                     } 
                    else if (currentIndex == 1) {
                        RemoteUnLockPasswordSetOrModify dView = new RemoteUnLockPasswordSetOrModify (doorLock);
                        UserMiddle.DevicePageView.AddChidren (dView);
                        dView.ShowShowUserRemoteUnLock ();
                        UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;               
                    }  
                };
                btnRight.MouseUpEventHandler += eHandler;
                btnIcon.MouseUpEventHandler += eHandler;
                RowView.MouseUpEventHandler += eHandler;
                UserManagement.MouseUpEventHandler += eHandler;
            }
             
           
            #endregion
        }
    }
}