wxr
2023-06-06 592974441a4df95fffd9167c90192da1a390b1c2
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System;
using Shared;
using HDL_ON.UI.CSS;
 
namespace HDL_ON.UI
{
    public class BindingResidencePage : FrameLayout
    {
        public BindingResidencePage()
        {
        }
 
        public void LoadView()
        {
            BackgroundColor = CSS_Color.MainBackgroundColor;
 
            FrameLayout bodyView = new FrameLayout();
            AddChidren(bodyView);
 
            Button btnIcon = new Button()
            {
                X = Application.GetRealWidth(108),
                Y = Application.GetRealWidth(102),
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealWidth(160),
                UnSelectedImagePath = "oRobot.png",
            };
            bodyView.AddChidren(btnIcon);
 
            Button btnWelcome = new Button()
            {
                Y = btnIcon.Bottom,
                Height = Application.GetRealHeight(120),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.WelcomeToOnPlus,
            };
            bodyView.AddChidren(btnWelcome);
 
 
            Button btnAddNewResidence = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(379),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                Radius = (uint)Application.GetRealWidth(22),
                BackgroundColor = CSS_Color.MainColor,
                TextColor = CSS_Color.MainBackgroundColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.Center,
                TextID = StringId.AddNewResidence,
                IsBold = true,
            };
            bodyView.AddChidren(btnAddNewResidence);
 
            Button btnTobeFamily = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(439),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                Radius = (uint)Application.GetRealWidth(22),
                BorderColor = CSS_Color.MainColor,
                BorderWidth = (uint)Application.GetRealWidth(1),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.Center,
                TextID = StringId.TobeFamily,
                IsBold = true,
            };
            bodyView.AddChidren(btnTobeFamily);
 
            Button btnLogout = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = btnTobeFamily.Bottom + Application.GetRealWidth(10),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                TextAlignment = TextAlignment.Center,
                TextID = StringId.Logout,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.TextualColor,
                IsBold = true,
            };
            bodyView.AddChidren(btnLogout);
 
 
 
            btnAddNewResidence.MouseUpEventHandler = (sender, e) =>
            {
                if (Language.CurrentLanguage == "Chinese")
                {
                    Scan.Ins.TipMsg = "您已拒绝App相机访问权限,这将导致您无法使用扫描二维码绑定我的家庭,但您可以通过加入其他用户的家庭,体验智能家居服务,如需启用绑定我的家庭服务,请前往手机系统设置打开相关权限";
                }
                else
                {
                    Scan.Ins.TipMsg = "You have denied access to the app camera, which will make you unable to bind my family with the scanned QR code, but you can experience smart home services by joining other users' families. To enable the bind my family service, please go to the mobile phone system settings to open the relevant permissions";
                }
                Scan.Ins.OpenScan((scanString) =>
                {
                    //执行绑定住宅
                    this.DoBindResidence(scanString);
                });
            };
 
            btnTobeFamily.MouseUpEventHandler = (sender, e) =>
            {
                //我的二维码
                var page = new MyQRCodePage();
                AddChidren(page);
                page.LoadPage(true);
            };
 
            btnLogout.MouseUpEventHandler = (sender, e) =>
            {
                HDLCommon.Current.Logout();
            };
        }
 
        /// <summary>
        /// 执行绑定住宅
        /// </summary>
        public void DoBindResidence(string scanString)
        {
            var pm = new DAL.Server.HttpServerRequest();
            var result = pm.BindingResidence(scanString);
            if (result == null) { return; }
 
            if (result.Code == DAL.Server.StateCode.SUCCESS)
            {
                //调用On原来的方法,刷新住宅列表及其缓存
                pm.GetHomePager(HomeTypeEnum.ALL,scanString);
                //跳转页面----
                MainPage.GoUserPage(true, false, () =>
                {
                    //显示欢迎回家的弹窗界面
                    var form = new WellcomToHomeForm();
                    form.ShowForm();
                });
            }
            //其他情况全部提示失效
            else
            {
                //显示二维码已经过期的弹窗
                this.ShowQrCodeTimeOutView();
            }
        }
 
        /// <summary>
        /// 显示二维码已经过期的弹窗
        /// </summary>
        public void ShowQrCodeTimeOutView()
        {
            //整个界面的灰色背景
            var frameBack = new Dialog();
            frameBack.Show();
 
            //中间白色区域
            var frameWite = new FrameLayout();
            frameWite.Y = Application.GetRealHeight(223);
            frameWite.Height = Application.GetRealHeight(245);
            frameWite.Width = Application.GetRealWidth(288);
            frameWite.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
            frameWite.Radius = (uint)Application.GetRealWidth(12);
            frameWite.Gravity = Gravity.CenterHorizontal;
            frameBack.AddChidren(frameWite);
 
            //Icon图标
            var picIcon = new Button();
            picIcon.Y = Application.GetRealHeight(152);
            picIcon.Height = Application.GetRealWidth(160);
            picIcon.Width = Application.GetRealWidth(160);
            picIcon.Gravity = Gravity.CenterHorizontal;
            picIcon.UnSelectedImagePath = "ErrorIcon.png";
            frameBack.AddChidren(picIcon);
 
            //二维码失效,请重试
            var btnText = new Button();
            btnText.Y = Application.GetRealHeight(98);
            btnText.Height = Application.GetRealHeight(24);
            btnText.TextSize = 16;
            btnText.TextAlignment = TextAlignment.Center;
            btnText.TextColor = CSS.CSS_Color.FirstLevelTitleColor;
            btnText.TextID = StringId.QRCodeIsInvalid;
            frameWite.AddChidren(btnText);
 
            //取消
            var btnCancel = new Button();
            btnCancel.X = Application.GetRealWidth(30);
            btnCancel.Y = btnText.Bottom + Application.GetRealHeight(48);
            btnCancel.Height = Application.GetRealHeight(44);
            btnCancel.Width = Application.GetRealWidth(108);
            btnCancel.TextSize = 16;
            btnCancel.IsBold = true;
            btnCancel.TextAlignment = TextAlignment.Center;
            btnCancel.TextColor = CSS.CSS_Color.MainColor;
            btnCancel.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
            btnCancel.Radius = (uint)Application.GetRealHeight(22);
            btnCancel.TextID = StringId.Cancel;
            btnCancel.BorderWidth = 1;
            btnCancel.BorderColor = CSS.CSS_Color.MainColor;
            frameWite.AddChidren(btnCancel);
 
            btnCancel.MouseUpEventHandler += (sender, e) =>
            {
                frameBack.Close();
            };
 
            //重试
            var btnRedo = new Button();
            btnRedo.Y = btnText.Bottom + Application.GetRealHeight(48);
            btnRedo.Height = Application.GetRealHeight(44);
            btnRedo.Width = Application.GetRealWidth(108);
            btnRedo.TextSize = 16;
            btnRedo.IsBold = true;
            btnRedo.TextAlignment = TextAlignment.Center;
            btnRedo.TextColor = CSS.CSS_Color.MainBackgroundColor;
            btnRedo.BackgroundColor = CSS.CSS_Color.MainColor;
            btnRedo.Radius = (uint)Application.GetRealHeight(22);
            btnRedo.TextID = StringId.Retry;
            frameWite.AddChidren(btnRedo);
            btnRedo.X = frameWite.Width - btnRedo.Width - Application.GetRealWidth(30);
 
            btnRedo.MouseUpEventHandler += (sender, e) =>
            {
                Scan.Ins.OpenScan((scanString) =>
                {
                    frameBack.Close();
                    //执行绑定住宅
                    this.DoBindResidence(scanString);
                });
            };
        }
    }
}