HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WirelessApSelectNetworkForm.cs
@@ -36,53 +36,88 @@
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameBack);
            //请选择网络
            //请输入WIFI和密码
            var btnTitle = new NormalViewControl(600, 64, true);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.Y = Application.GetRealHeight(30);
            btnTitle.TextSize = 15;
            btnTitle.TextID = R.MyInternationalizationString.uPleaseSelectNetwork;
            btnTitle.TextID = R.MyInternationalizationString.uPleaseInputWifiAndPassword;
            frameBack.AddChidren(btnTitle);
            //WIFI
            var rowWifi = new FrameCaptionInputControl("WiFi", string.Empty);
            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 btnPsw = new FrameCaptionInputControl(Language.StringByID(R.MyInternationalizationString.uPassword), string.Empty);
            btnPsw.Y = rowWifi.Bottom + Application.GetRealHeight(9);
            frameBack.AddChidren(btnPsw);
            btnPsw.InitControl();
            btnPsw.txtInput.SecureTextEntry = true;
            btnPsw.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputWifiPassword);
            var btnView = btnPsw.AddMostRightEmptyIcon(81, 81);
            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";
            btnPsw.ChangedChidrenBindMode(btnView, ChidrenBindMode.NotBind);
            rowPsw.ChangedChidrenBindMode(btnView, ChidrenBindMode.NotBind);
            btnView.ButtonClickEvent += (sender, e) =>
            {
                btnView.IsSelected = !btnView.IsSelected;
                btnPsw.txtInput.SecureTextEntry = !btnPsw.txtInput.SecureTextEntry;
                rowPsw.txtInput.SecureTextEntry = !rowPsw.txtInput.SecureTextEntry;
            };
            var btnMsg = new NormalViewControl(btnPsw.txtInput.Width, false);
            var btnMsg = new NormalViewControl(rowPsw.txtInput.Width, false);
            btnMsg.X = ControlCommonResourse.XXLeft;
            btnMsg.Y = frameBack.Bottom + Application.GetRealHeight(23);
            btnMsg.TextSize = 12;
            btnMsg.Height = Application.GetRealHeight(40);
            btnMsg.TextColor = UserCenterColor.Current.Red;
            btnMsg.TextColor = UserCenterColor.Current.ErrorColor;
            bodyFrameLayout.AddChidren(btnMsg);
            //发送局域网账号、密码
            var btnMsgTitle = new NormalViewControl(500, 60, true);
            btnMsgTitle.TextID = R.MyInternationalizationString.uSendLanAccountAndPassword;
            btnMsgTitle.X = ControlCommonResourse.XXLeft;
            btnMsgTitle.Y = frameBack.Bottom + Application.GetRealHeight(369);
            btnMsgTitle.IsBold = true;
            bodyFrameLayout.AddChidren(btnMsgTitle);
            //1.填写路由器的账号和密码
            //2.点击下一步,将路由器账号和密码发送至网关
            //3.网关接收成功,系统指示灯SYS闪烁
            string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddWirelessApGatewayMsg2).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
            int yy = btnMsgTitle.Bottom + Application.GetRealHeight(23);
            foreach (var msg in ArryMsg)
            {
                var btnTip = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false);
                btnTip.Text = msg;
                btnTip.Y = yy;
                btnTip.X = btnMsgTitle.X;
                btnTip.TextColor = UserCenterColor.Current.TextGrayColor1;
                btnTip.TextSize = 12;
                bodyFrameLayout.AddChidren(btnTip);
                yy = btnTip.Bottom;
            }
            //查看帮助
            var btnHelp = this.AddHelpControl();
            btnHelp.ButtonClickEvent += (sender, e) =>
            {
                var form = new DeviceDirection.DeviceDirectionHelpForm();
                form.AddForm("WirelessUdp");
                var form = new AddGatewayHelpForm();
                form.AddForm("Ap");
            };
            //下一步
@@ -99,17 +134,96 @@
                    btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputHomeWifiAccount);
                    return;
                }
                if (btnPsw.Text == string.Empty)
                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 WirelessApDirection3Form();
                this.AddFromAndRemoveNowForm(form);
                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 - ControlCommonResourse.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 - ControlCommonResourse.BottomLineHeight, false);
                btnWifi.X = ControlCommonResourse.XXLeft;
                btnWifi.Text = "Application Software" + i;
                frameRow.AddChidren(btnWifi, ChidrenBindMode.BindEvent);
                //底线
                var btnLine = new NormalViewControl(frameRow.Width, ControlCommonResourse.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
    }
}