Example #1
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbUserName.Text))
            {
                tbUserName.Focus(FocusState.Keyboard);
                return;
            }
            if (string.IsNullOrEmpty(tbPassword.Password))
            {
                tbPassword.Focus(FocusState.Keyboard);
                return;
            }


            if (user.UserInfo == null)
            {
                user.UserInfo = new UserLoginEntity();
            }
            user.UserInfo.UserName = tbUserName.Text.Trim();
            user.UserInfo.Password = tbPassword.Password.Trim();
            if (radiobtnIpv4.IsChecked == true)
            {
                user.UserInfo.IPMode = IPModeEnum.IPV4;
            }
            else
            {
                user.UserInfo.IPMode = IPModeEnum.IPV6V4;
            }

            //显示等待环
            //progressRing.IsActive = true;
            //SetControlStatus(grid, false);
            ProgressView.ProgressIndicator progress = new ProgressView.ProgressIndicator();

            progress.Show();
            ConnectMode connectMode;

            if (user.UserInfo.IPMode == IPModeEnum.IPV4)
            {
                connectMode = ConnectMode.Ipv4;
            }
            else
            {
                connectMode = ConnectMode.IPv4v6;
            }

            var re = await BjutInternet.Login(user.UserInfo.UserName, user.UserInfo.Password, connectMode);

            await new MessageDialog(re.Msg).ShowAsync();
            if (re.CodeResult == CodeResult.Success)
            {
                user.SaveUserInfo();
                netAccountInfo.GetAccountBasicInfo(user.UserInfo.UserName, user.UserInfo.Password);
            }
            progress.Hide();
        }
Example #2
0
        private async void btnLogout_Click(object sender, RoutedEventArgs e)
        {
            ProgressView.ProgressIndicator progress = new ProgressView.ProgressIndicator();

            progress.Show();
            var re = await BjutInternet.Logout();

            await new MessageDialog(re.Msg).ShowAsync();
            progress.Hide();
            if (re.CodeResult == CodeResult.Fail)
            {
                //添加其他逻辑,例如重新注销或检测网络状况
            }
            else
            {
                //添加其他逻辑
            }
        }