private void LoginButton_Click(object sender, RoutedEventArgs e) { ToastController toastController; string userName = UserNameTextBox.Text; string passWord = PassWordTextBox.Password; Sock sock = new Sock(userName, passWord, testHost, port); Status status = Status.NONE; status = sock.Login(userName, passWord); if (status == Status.LOGIN_AC) { //储存到全局变量中 ConstantVariable.ConstantVariable.sock = sock; Frame root = Window.Current.Content as Frame; //root.Navigate(typeof(CommunicatePage),sock); root.Navigate(typeof(CommunicatePage)); //sock.start(); } else if (status == Status.WRONG_PASSWORD) { toastController = new ToastController("Login Failure!Please check the password"); toastController.Show(); } else if (status == Status.NO_MEMSHIP) { toastController = new ToastController("No Memship!Please register and try again!"); toastController.Show(); } }
private void RegisterSubmit_Click(object sender, RoutedEventArgs e) { ToastController toast; string userName = RegisterUserNameTextBox.Text; string passWord01 = RegisterPassWordTextBox01.Password; string passWord02 = RegisterPassWordTextBox02.Password; Regex regExp = new Regex("[ \\[ \\] \\^ \\-_×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]"); bool isPassWordIllegal = regExp.IsMatch(passWord01); bool isUserNameIllegal = regExp.IsMatch(userName); if (passWord01 != passWord02) { toast = new ToastController("PassWord is not exactly the same!"); toast.Show(); } else if (passWord01.Length >= 32 || passWord01.Length <= 4) { toast = new ToastController("PassWord must be longer than 4 letters and less than 32 letters!"); toast.Show(); } else if (userName.Contains(" ") || isUserNameIllegal || userName == "") { toast = new ToastController("UserName must be without Illegal Character and contains no space!"); toast.Show(); } else if (passWord01 == string.Empty) { toast = new ToastController("PassWord must be without space!"); toast.Show(); } else if (isPassWordIllegal) { toast = new ToastController("PassWord can't contains the illegal character!"); toast.Show(); } else { Status status = sock.Register(userName, passWord01); if (status == Status.REGISTER_AC) { toast = new ToastController("Register Accepted!"); toast.Show(); } else if (status == Status.SAME_NAME) { toast = new ToastController("Register Failure!The username is existed!"); toast.Show(); } else if (status == Status.REGISTER_ERROR) { toast = new ToastController("REGISTER ERROR!"); toast.Show(); } } }
private void InitialHost() { return; ToastController toastController; IPAddress[] iPAddresses = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress iP in iPAddresses) { if (iP.AddressFamily == AddressFamily.InterNetwork) { testHost = iP.ToString(); break; } } toastController = new ToastController("TestHost:" + testHost); toastController.Show(); }