黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.GatewayAdd
{
    /// <summary>
    /// Mini网关选择网络的界面
    /// </summary>
    public class MiniGatewaySelectNetworkForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            bodyFrameLayout.RemoveAll();
 
            var frameBack = new FrameLayout();
            frameBack.Height = Application.GetRealHeight(409);
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameBack);
 
            //请选择网络
            var btnTitle = new NormalViewControl(600, 64, true);
            btnTitle.X = HdlControlResourse.XXLeft;
            btnTitle.Y = Application.GetRealHeight(30);
            btnTitle.TextSize = 15;
            btnTitle.TextID = R.MyInternationalizationString.uPleaseSelectNetwork;
            frameBack.AddChidren(btnTitle);
 
            //WIFI
            var rowWifi = new FrameCaptionInputControl("WiFi", "");
            rowWifi.Y = Application.GetRealHeight(124);
            frameBack.AddChidren(rowWifi);
            rowWifi.InitControl();
            rowWifi.AddBottomLine();
            rowWifi.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputHomeWifiAccount);
            //下拉图标是偏右的
            rowWifi.RightOffset = -Application.GetRealWidth(18);
            var btnDrop = rowWifi.AddMostRightEmptyIcon(58, 58);
            btnDrop.UnSelectedImagePath = "Item/Down.png";
            rowWifi.ChangedChidrenBindMode(btnDrop, ChidrenBindMode.NotBind);
            btnDrop.ButtonClickEvent += (sender, e) =>
            {
                //显示Wifi下拉列表
                //this.ShowWifiListView(rowWifi);
            };
 
            //密码
            var rowPsw = new FrameCaptionInputControl(Language.StringByID(R.MyInternationalizationString.uPassword), string.Empty);
            rowPsw.Y = rowWifi.Bottom + Application.GetRealHeight(9);
            frameBack.AddChidren(rowPsw);
            rowPsw.InitControl();
            rowPsw.txtInput.SecureTextEntry = true;
            rowPsw.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputWifiPassword);
            var btnView = rowPsw.AddMostRightEmptyIcon(81, 81);
            btnView.UnSelectedImagePath = "Item/HidenPWD.png";
            btnView.SelectedImagePath = "Item/UnHidenPWD.png";
            rowPsw.ChangedChidrenBindMode(btnView, ChidrenBindMode.NotBind);
            btnView.ButtonClickEvent += (sender, e) =>
            {
                btnView.IsSelected = !btnView.IsSelected;
                rowPsw.txtInput.SecureTextEntry = !rowPsw.txtInput.SecureTextEntry;
            };
 
            var btnMsg = new NormalViewControl(rowPsw.txtInput.Width, false);
            btnMsg.X = HdlControlResourse.XXLeft;
            btnMsg.Y = frameBack.Bottom + Application.GetRealHeight(23);
            btnMsg.TextSize = 12;
            btnMsg.Height = Application.GetRealHeight(40);
            btnMsg.TextColor = UserCenterColor.Current.ErrorColor;
            bodyFrameLayout.AddChidren(btnMsg);
 
            //查看帮助
            var btnHelp = this.AddHelpControl();
            btnHelp.ButtonClickEvent += (sender, e) =>
            {
                var form = new AddGatewayHelpForm();
                form.AddForm("Mini");
            };
 
            //下一步
            var btnNext = new BottomClickButton();
            btnNext.TextID = R.MyInternationalizationString.uNextway;
            bodyFrameLayout.AddChidren(btnNext);
 
            btnNext.MouseUpEventHandler += (sender, e) =>
            {
                btnMsg.Text = string.Empty;
                if (rowWifi.Text == string.Empty)
                {
                    //请输入家庭WIFI账号
                    btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputHomeWifiAccount);
                    return;
                }
                if (rowPsw.Text == string.Empty)
                {
                    //请输入Wifi密码
                    btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputWifiPassword);
                    return;
                }
                //发送密码
                var result = HdlWifiLogic.Current.SendApHomeWifiPassword(rowWifi.Text, rowPsw.Text);
                if (result == false)
                {
                    //密码发送失败
                    this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uSendPasswordFail));
                    return;
                }
 
                this.CloseForm();
                var form = new MiniGatewayDirection3Form();
                form.AddForm();
            };
        }
 
        #endregion
 
        #region ■ 显示Wifi下拉列表___________________
 
        /// <summary>
        /// 显示Wifi下拉列表
        /// </summary>
        /// <param name="rowWifi"></param>
        private void ShowWifiListView(FrameCaptionInputControl rowWifi)
        {
            //一个可以遮住Body的东西
            var frameTran = new NormalFrameLayout();
            frameTran.Height = bodyFrameLayout.Height;
            frameTran.BackgroundColor = UserCenterColor.Current.DialogBackColor;
            bodyFrameLayout.AddChidren(frameTran);
            frameTran.ButtonClickEvent += (sender, e) =>
            {
                frameTran.RemoveFromParent();
            };
            //白色背景框
            var frameList = new NormalFrameLayout();
            frameList.Y = rowWifi.Bottom;
            frameList.Gravity = Gravity.CenterHorizontal;
            frameList.Width = frameTran.Width - HdlControlResourse.XXLeft * 2;
            frameList.Height = this.GetPictrueRealSize(1200);
            frameList.Radius = (uint)Application.GetRealWidth(17);
            frameList.BackgroundColor = UserCenterColor.Current.White;
            frameTran.AddChidren(frameList);
            //列表控件
            var listView = new VerticalListControl();
            listView.Height = frameList.Height;
            frameList.AddChidren(listView);
 
            for (int i = 1; i <= 10; i++)
            {
                var frameRow = new FrameRowControl();
                listView.AddChidren(frameRow);
                //wifi名字
                var btnWifi = new NormalViewControl(frameRow.Width, frameRow.Height - HdlControlResourse.BottomLineHeight, false);
                btnWifi.X = HdlControlResourse.XXLeft;
                btnWifi.Text = "Application Software" + i;
                frameRow.AddChidren(btnWifi, ChidrenBindMode.BindEvent);
                //底线
                var btnLine = new NormalViewControl(frameRow.Width, HdlControlResourse.BottomLineHeight, false);
                btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
                btnLine.Y = btnWifi.Bottom;
                frameRow.AddChidren(btnLine, ChidrenBindMode.BindEvent);
                frameRow.ButtonClickEvent += (sender, e) =>
                {
                    rowWifi.Text = btnWifi.Text;
                    frameTran.RemoveFromParent();
                };
            }
        }
        #endregion
 
        #region ■ 界面关闭___________________________
 
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseFormBefore()
        {
            //关闭Tcp链接
            HdlWifiLogic.Current.CloseApTcpConnection();
 
            base.CloseFormBefore();
        }
 
        #endregion
    }
}