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
182
183
184
using Shared.SimpleControl.Phone;
using System;
using System.Collections.Generic;
using service.hdlcontrol.com_push;
 
namespace Shared.SimpleControl.Pad
{
    public class Register : Dialog
    {
        public EditText Register_Email_Address;
        EditText Register_Password;
 
        /// <summary>
        /// 构造函数
        /// </summary>
        public Register ()
        {
            RegisterShow ();
            Width = Application.GetRealWidth (870);
            Height = Application.GetRealHeight (1000);
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        void RegisterShow ()
        {
            var userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile)));
            if (userInfo != null) {
                if ((System.DateTime.Now - userInfo.LastTime).TotalDays < 7) {
                    Close ();
                    return;
                }
            }
 
            #region Bottom
            Button Register_logo = new Button () {
                Width = Application.GetRealWidth (230),
                Height = Application.GetRealHeight (201),
                X = Application.GetRealWidth(310),
                Y = Application.GetRealHeight(67),
                UnSelectedImagePath = MainPage.RegisterLogoString,
            };
            AddChidren (Register_logo);
 
            Register_Email_Address = new EditText () {
                Width = Application.GetRealWidth (620),
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (120),
                Y = Application.GetRealHeight (380),
                UnSelectedImagePath = "Register/Register_Email_Address.png",
                PlaceholderText = Language.StringByID (R.MyInternationalizationString.EmailAddress),
                PlaceholderTextColor = 0xFB757575,
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight (0),
            };
            Register_Email_Address.MouseUpEventHandler += (sender, e) => {
            };
            AddChidren (Register_Email_Address);
 
            Register_Password = new EditText () {
                Width = Application.GetRealWidth (620),
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (120),
                Y = Register_Email_Address.Bottom + Application.GetRealHeight (50),
                UnSelectedImagePath = "Register/Register_Password_kuang.png",
                PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword),
                PlaceholderTextColor = 0xFB757575,
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight (0),
                SecureTextEntry = true
            };
            Register_Password.MouseUpEventHandler += (sender, e) => {
            };
            AddChidren (Register_Password);
 
            Button register = new Button () {
                Width = Application.GetRealWidth (500 / 2),
                Height = Application.GetRealHeight (85),
                X = Application.GetRealWidth (120),
                Y = Register_Password.Bottom + Application.GetRealHeight (10),
                //BackgroundColor = SkinStyle.Current.SelectedBackgroundColor,
                TextID = R.MyInternationalizationString.Register,
                TextSize = 15,
                TextColor = 0xFFDBDDDF,
                TextAlignment = TextAlignment.CenterLeft,
            };
            register.MouseUpEventHandler += (sender, e) => {
                this.Close ();
                new Register_info ().Show ();
            };
            AddChidren (register);
 
            Button forgot_password = new Button () {
                Width = Application.GetRealWidth (500 / 2),
                Height = Application.GetRealHeight (85),
                X = register.Right + Application.GetRealWidth(120),
                Y = Register_Password.Bottom + Application.GetRealHeight (10),
                TextID = R.MyInternationalizationString.ForgotPassword,
                TextSize = 15,
                //BackgroundColor = SkinStyle.Current.SelectedBackgroundColor,
                TextColor = 0xFFDBDDDF,
                TextAlignment = TextAlignment.CenterRight,
            };
            forgot_password.MouseUpEventHandler += (sender, e) => {
                this.Close ();
                new ForgotPassword ().Show ();
            };
            AddChidren (forgot_password);
            #endregion 
 
            #region save
            Button btnOK = new Button () {
                Width = Application.GetRealWidth (300),
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (100),
                Y = Application.GetRealHeight(810),
                BackgroundColor = 0xFF333333,
                SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                TextID = R.MyInternationalizationString.Login,
                TextSize = 15,
                TextColor = SkinStyle.Current.TextColor1,
            };
            AddChidren (btnOK);
            btnOK.MouseDownEventHandler += (sender, e) => {
                btnOK.IsSelected = true;
            };
 
            btnOK.MouseUpEventHandler += (sender, e) => {
                try {
                    btnOK.IsSelected = false;
 
                    WebServiceLogin service_login = new WebServiceLogin ();
                    var result = Newtonsoft.Json.JsonConvert.DeserializeObject<ResultStatus> (service_login.Login2_0 (Register_Email_Address.Text.Trim (), Register_Password.Text.Trim (), MainPage.SoftSmsType));
                    /// <summary>
                    /// 0:成功
                    /// -1:账号未激活
                    /// -2:账户或者密码错误
                    /// </summary>
                    if (result.Code == -1) {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AccountHasNotBeenActivated),
                                  Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    } else if (result.Code == -2) {
                        new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AccountOrPasswordIsWrong),
                                   Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    } else {
                        var _userInfo = new UserInfo { ID = result.ID,MasterID = result.MasterID, AccountString = Register_Email_Address.Text.Trim (), Password = Register_Password.Text.Trim (), LastTime = DateTime.Now };
                        IO.FileUtils.WriteFileByBytes (UserInfo.GlobalRegisterFile, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (_userInfo)));
                        var se = new service.hdlcontrol.com_push.WebServicePush ();
                        se.VerifySoapHeaderValue = new service.hdlcontrol.com_push.VerifySoapHeader () { Email = _userInfo.AccountString, UserMode = 0 };
                        se.AddRegId (UserConfig.Instance.tokenID, UserConfig.Instance.phoneName);
                        Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (2);
                        MainPage.LoginUser = new UserInfo { ID = result.ID, MasterID = result.MasterID, AccountType = result.AccountType, AccountString = Register_Email_Address.Text.Trim (), Password = Register_Password.Text.Trim (), LastTime = DateTime.Now };
                        Close ();
                    }
                } catch (Exception ex) {
                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
                               Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    string mess = ex.Message;
                }
            };
 
            Button cancel = new Button () {
                Width = Application.GetRealWidth (300),
                Height = Application.GetRealHeight (100),
                X = btnOK.Right + Application.GetRealWidth (60),
                Y = btnOK.Y,
                BackgroundColor = 0xFF333333,
                SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                TextID = R.MyInternationalizationString.Cancel,
                TextSize = 15,
                TextColor = SkinStyle.Current.TextColor1,
            };
            AddChidren (cancel);
            cancel.MouseDownEventHandler += (sender, e) => {
                cancel.IsSelected = true;
            };
 
            cancel.MouseUpEventHandler += (sender, e) => {
                cancel.IsSelected = false;
                Close ();
            };
            #endregion 
        }
    }
}