private void btnConnect_Click(object sender, EventArgs e) { if(txtUsername.Text != string.Empty) { StaticValues.self.Username = txtUsername.Text; StaticValues.self.IP = StaticMethods.GetUserIp(); ivApi = new ApiCommunication(); bool success = ivApi.Connect(); if (success) { this.Hide(); var DCSharpForm = new DCSharp(); DCSharpForm.FormClosed += (s, args) => this.Close(); DCSharpForm.Show(); } else { MessageBox.Show("Username taken."); } } else { MessageBox.Show("Invalid username."); } }
public DCSharp() { InitializeComponent(); this.FormClosed += DCSharp_FormClosed; this.listUsers.MouseDoubleClick += ListUsers_MouseDoubleClick; ivApi = new ApiCommunication(); ivClient = new ClientCommunication(); ivListener = new ClientListener(this.listFiles); ivApi.GetUsers(listUsers); }