private void btnConnect_Click(object sender, EventArgs e)
 {
     btnConnect.Enabled = false;
     Properties.Settings.Default.Username = txtUsernm.Text;
     Properties.Settings.Default.Password = txtPasswd.Text;
     Properties.Settings.Default.Server = txtSvr.Text;
     Properties.Settings.Default.Port = int.Parse(txtPort.Text);
     Properties.Settings.Default.Save();
     updaterProgressBar1.EndColor = Color.FromArgb(0, 211, 40);
     updaterProgressBar1.StartColor = Color.FromArgb(0, 211, 40);
     updaterProgressBar1.Value = 0;
     Server s = new Server(txtSvr.Text, txtSvr.Text, int.Parse(txtPort.Text));
     Connection = s.GetConnection();
     Connection.RegisterUser(txtUsernm.Text, txtPasswd.Text);
     TaskManager.AddAsyncTask(delegate
     {
         Connection.ProgressChange += new Connection.ProgressChangeEvent(c_ProgressChange);
         try
         {
             Connection.Connect();
         }
         catch (LoginFailedException ex)
         {
             failReason = ex.Message;
         }
     });
 }
 public Connection(Server s)
 {
     Server = s;
     ProgressChange += new ProgressChangeEvent(OnProgressChange);
 }