public HomeClient(string address, int port, string name, Color textColor, Operation operation)
 {
     user = new User(name, textColor, operation);
     try
     {
         client.Connect(IPAddress.Parse(address), port);
     }
     catch
     {
         serverError = true;
         return;
     }
     tcpStream = client.GetStream();
     bf        = new BinaryFormatter();
     bf.Serialize(tcpStream, user);
     existingAccountEventArgs = (ExistingAccountEventArgs)bf.Deserialize(tcpStream);
     ThreadPool.QueueUserWorkItem(o =>
     {
         if (existingAccountEventArgs.ErrorExists == true && existingAccountEventArgs.GetOperation == Operation.LogIn)
         {
             bf.Serialize(tcpStream, new AcceptDisposeServer(true));
         }
         if (existingAccount != null && existingAccountEventArgs.ErrorExists)
         {
             existingAccount(this, existingAccountEventArgs);
         }
         else
         {
             ReceiveMesseges();
         }
     });
 }
 private void ExistingAccount(object o, ExistingAccountEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke(new Action <object, ExistingAccountEventArgs>(ExistingAccount), o, e);
         return;
     }
     if (e.GetOperation == Operation.SingUp)
     {
         MessageBox.Show(string.Format("Error! The username {0} exists. Please try another username or log in.", e.GetUser.UserName), "Sing Up Error!",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MessageBox.Show(string.Format("Error! The username {0} does not exist. Please try again or sing up.", e.GetUser.UserName), "Log In Error!",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     ResultForErorr();
 }