private void BestScores_Click(object sender, EventArgs e) { this.Hide(); Form myStatusForm = new BestScores(clientSocket, this); myStatusForm.Show(); }
private void SignIn_Click(object sender, EventArgs e) { try { if (userNameBox.Text.Length == 0 || passwordBox.Text.Length == 0) { msgToUser.Text = "Please fill all fields"; msgToUser.Visible = true; return; } string signInMsg = "200" + userNameBox.Text.Length.ToString().PadLeft(2, '0') + userNameBox.Text + passwordBox.Text.Length.ToString().PadLeft(2, '0') + passwordBox.Text; NetworkStream serverStream = clientSocket.GetStream(); byte[] outStream = System.Text.Encoding.ASCII.GetBytes(signInMsg); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); byte[] inStream = new byte[4]; serverStream.Read(inStream, 0, 4); string returndata = System.Text.Encoding.ASCII.GetString(inStream); //msg(returndata); switch (returndata.Substring(0, 4)) { case "1020": //Success Sign_up_outB.Text = "Sign out"; UserNameLable.Hide(); PasswordLable.Hide(); userNameBox.Hide(); passwordBox.Hide(); SignIn.Hide(); GreetingsLable.Text = "Hello " + userNameBox.Text; GreetingsLable.Visible = true; TriviaLogoTop.Image = Properties.Resources.Trivia; TriviaLogoRight.Image = Properties.Resources.Trivia; TriviaLogoLeft.Image = Properties.Resources.Trivia; JoinRoom.Enabled = true; CreateRoom.Enabled = true; MyStatus.Enabled = true; BestScores.Enabled = true; JoinRoom.Show(); CreateRoom.Show(); MyStatus.Show(); BestScores.Show(); msgToUser.Text = ""; msgToUser.Visible = false; break; case "1021": //Wrong Details msgToUser.Text = "Wrong Details"; msgToUser.Visible = true; //set trivia to red TriviaLogoTop.Image = Properties.Resources.ErrorTriviaLogo; TriviaLogoRight.Image = Properties.Resources.ErrorTriviaLogo; TriviaLogoLeft.Image = Properties.Resources.ErrorTriviaLogo; break; case "1022": //User is already connected msgToUser.Text = "User is already connected"; msgToUser.Visible = true; //set trivia to red TriviaLogoTop.Image = Properties.Resources.ErrorTriviaLogo; TriviaLogoRight.Image = Properties.Resources.ErrorTriviaLogo; TriviaLogoLeft.Image = Properties.Resources.ErrorTriviaLogo; break; default: msg("Got unknown code: " + returndata); break; } } catch (Exception exc) { msg(exc.Message); } }