private void btRegisterRegister_Click(object sender, RoutedEventArgs e) { lbRegisterError.Content = ""; if (!new System.Text.RegularExpressions.Regex(@"^.*(?=.{8,})((?=.*[!@#$%^&*()\-_=+{};:,<.>]){1})(?=.*\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$").IsMatch(tbRegisterPassword.Password)) { lbRegisterError.Content = "Insecure Password"; return; } User = new User(tbRegisterUsername.Text, "0:0", tbRegisterPassword.Password); Response response = Exchange(new Document(), "LoginModule", "Register"); switch (response.Header.Code) { case ResponseCode.PlannedError: lbRegisterError.Content = response.Header.Message; break; case ResponseCode.Ok: GetMain.ChangeControl(MainWindow.Controls.Login); break; default: throw new Exception("Invalid response code."); } }
private void CheckConnectionAndSwitchToConnectionScreen() { if (!Client.IsConnected) { GetMain.ChangeControl(MainWindow.Controls.Connection); Abort(); } }
private void btConnectionConnect_Click(object sender, RoutedEventArgs e) { DateTime startWaitTime = DateTime.Now; btConnectionConnect.IsEnabled = false; btConnectionConnect.Content = "Connecting"; lbConnectionError.Content = ""; DoEvents(); try { GetMain.Connect(); } catch (Exception ex) { btConnectionConnect.IsEnabled = true; btConnectionConnect.Content = "Connect"; lbConnectionError.Content = ex.Message; return; } finally { GetMain.UpdateInfoLabel(); } while (!Client.IsConnected) { System.Threading.Thread.Sleep(250); DoEvents(); if (DateTime.Now > startWaitTime.AddSeconds(15)) { btConnectionConnect.IsEnabled = true; btConnectionConnect.Content = "Connect"; lbConnectionError.Content = "Connection timed out"; Client.Close(); return; } } GetMain.UpdateInfoLabel(); GetMain.ChangeControl(MainWindow.Controls.Login); }
protected void ChangeControl(MainWindow.Controls control) { GetMain.ChangeControl(control); }
private void btRegisterLogin_Click(object sender, RoutedEventArgs e) { GetMain.ChangeControl(MainWindow.Controls.Login); }