黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.GatewayManage
{
    /// <summary>
    /// 重新绑定网关的界面
    /// </summary>
    public class GatewayRebindForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_gateway">换绑的网关对象</param>
        /// <param name="i_dicZbGatewayDiv">搜索到的网关类别  0:第一次绑定 1:已经绑定 2:需要换绑</param>
        public void ShowForm(ZbGateway i_gateway, Dictionary<string, int> i_dicZbGatewayDiv)
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddGateway));
 
            var btnLoading = new LoadingControl();
            btnLoading.Y = Application.GetRealHeight(656);
            btnLoading.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnLoading);
            btnLoading.StartAction();
 
            //正在换绑网关,请稍候…
            var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false);
            btnMsg.Y = Application.GetRealHeight(979);
            btnMsg.TextAlignment = TextAlignment.Center;
            btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnMsg.TextID = R.MyInternationalizationString.uIsReBindingPleaseWaiting;
            bodyFrameLayout.AddChidren(btnMsg);
 
            HdlThreadLogic.Current.RunThread(async () =>
            {
                await System.Threading.Tasks.Task.Delay(1000);
                int value = await HdlGatewayLogic.Current.ReBindNewGateway(i_gateway, btnMsg);
                if (value == 1)
                {
                    //成功
                    i_dicZbGatewayDiv[i_gateway.GwId] = 1;
                }
                else if (value == 0)
                {
                    //网关绑定在当前账号下的其他住宅里\r\n请解除绑定后再试
                    string msg = Language.StringByID(R.MyInternationalizationString.uTheGatewayInOtherResidenceMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, "\r\n");
                    }
                    this.ShowMassage(ShowMsgType.Tip, msg);
                }
 
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //成功或者失败都关闭界面
                    this.CloseForm();
                });
            });
        }
 
        #endregion
    }
}